Skip to content
Inference Academy

Write, profile and speed up CUDA and Triton kernels

GPU Kernels for Inference

Write the kernels inference engines run: bandwidth-bound copies and transposes, a tiled and register-blocked matmul, warp-shuffle reductions for softmax and RMSNorm, tensor cores, streams and CUDA graphs, then Triton: an autotuned matmul, fused RMSNorm and SwiGLU registered with PyTorch, and a paged, split-KV decode-attention kernel. Ends with Nsight profiling and a capstone that makes a real layer faster. Every lab runs on a free Colab T4.

4 tracks · 14 lessons · about 6 hours · 2 free lessons · 16 animated diagrams

Share

What you will be able to do

  • ✓Write coalesced, tiled and tensor-core CUDA kernels and explain their speed
  • ✓Write and autotune Triton kernels, and plug them into PyTorch and torch.compile
  • ✓Implement paged, split-KV decode attention and test it on ragged batches
  • ✓Profile with Nsight Systems and Nsight Compute and turn findings into fixes

Who it is for

Engineers who want to read, write and profile the GPU kernels behind vLLM, SGLang and PyTorch.

Prerequisites

C or C++ basics, Python with a little PyTorch, and the roofline idea from Inference Engineering.

Curriculum

Why kernel skills matter for inference, getting a free GPU, and the CUDA programming model: threads, blocks, warps and SMs, with your first kernel launched and timed.

  1. 1What you will build, and the planFree12 min
  2. 2The CUDA programming model: threads, blocks, warps and SMs1 diagramFree22 min

CUDA Kernels

Advanced

Coalescing and bandwidth-bound kernels, shared-memory tiling and a register-blocked matmul, occupancy and latency hiding, warp-shuffle reductions for softmax and RMSNorm, tensor cores with WMMA, and streams, events and CUDA graphs.

  1. 1Memory coalescing and bandwidth-bound kernels: copy, stride and transpose2 diagramsPro24 min
  2. 2Shared memory tiling and a tiled matmul1 diagramPro28 min
  3. 3Occupancy, registers and latency hiding1 diagramPro22 min
  4. 4Warp shuffles and reductions: softmax and RMSNorm kernels2 diagramsPro26 min
  5. 5Tensor cores: WMMA, MMA and why fast GEMMs need big tiles1 diagramPro24 min
  6. 6Streams, events and CUDA graphs: timing, overlap and launch overhead1 diagramPro24 min

The Triton programming model, a tensor-core matmul with autotuning, grouped ordering and fused epilogues, fused residual-add RMSNorm and SwiGLU registered as PyTorch custom ops, and a paged, split-KV decode-attention kernel.

  1. 1The Triton programming model: blocks, masks and pointers1 diagramPro24 min
  2. 2A Triton matmul: tl.dot, autotuning, grouped ordering and fused epilogues1 diagramPro26 min
  3. 3Fused residual-add RMSNorm and SwiGLU, plugged into PyTorch1 diagramPro26 min
  4. 4A decode-attention kernel in Triton: paged KV cache, GQA and split-KV2 diagramsPro32 min

Nsight Systems timelines, Nsight Compute speed of light, memory charts, occupancy and stall reasons, then a capstone that makes a real decoder layer measurably faster.

  1. 1Profiling kernels with Nsight Systems and Nsight Compute2 diagramsPro26 min
  2. 2Capstone: make a real layer faster, and prove itPro20 min