
Triton Kernels
Author Triton kernels - vector ops, fused reductions, tiled matmul, layernorm, and FlashAttention - and run them against torch references on real GPU hardware.
What you will learn
Triton lets you write GPU kernels in Python, one block of data at a time, instead of managing individual threads as in CUDA. This plan has 30 problems in six sections. You start with element-wise kernels, then write reductions, tiled matrix multiplication, normalization layers and attention kernels, and finish with the performance patterns used in production matmuls.
Prerequisites
You should be comfortable with Python and with PyTorch tensors, shapes and strides. No CUDA experience is required. If you want to see how the same ideas look at the thread level first, start with the CUDA study plan. For the tensor basics, see the PyTorch study plan.
The kernels, in order
- Foundations and the block model: vector addition, fused multiply-add and activation kernels such as ReLU, GELU and SiLU.
- Reductions: sums, maxima, single-pass mean and variance, L2 norm, row-wise softmax and log-sum-exp.
- Matrix multiply and autotuning: tiled and autotuned matmul, transpose, matrix-vector product and a fused matmul with bias and ReLU.
- Normalization and training ops: LayerNorm and RMSNorm forward, dropout, cross-entropy loss and the LayerNorm backward pass.
- Attention and LLM kernels: FlashAttention forward, scaled dot-product attention, rotary position embeddings, KV cache append and online softmax.
- Performance patterns: grouped program IDs, split-K and block-pointer matmuls, and vectorized loads.
How the GPU tests work
Your kernel runs on real GPU hardware, and its output is compared with a PyTorch reference implementation of the same operation. Each section ends with a short quiz on the concepts behind the kernels.
Where to go next
Take these kernels into model serving with the Inference Engineering study plan, which covers attention variants, KV caching and quantization. To understand why attention kernels are built the way they are, read FlashAttention explained and the KV cache. For the CUDA side of the same kernels, see the CUDA practice problems guide and TensorTonic vs LeetGPU.