Chapter 8: Advanced Kernels & Optimization
Bring it all together with the kernels that matter in real models: fused layer normalization, memory-efficient seeded dropout, the ideas behind fused attention (FlashAttention), persistent kernels, and a roadmap for going further with Triton.
- Topics
- 5
- Videos
- 3
Chapter Overview
You now have the full toolkit — the hardware model, the Triton programming model, fusion, reductions, tiling, and tuning. This final chapter applies it to the kernels that show up in every transformer, and points you toward what's next.
Fused layer normalization combines the softmax-style row reduction (mean, variance) with element-wise scale-and-shift in a single pass — the same fusion principle, applied again. Low-memory dropout shows a beautiful trick: instead of storing a giant random mask, regenerate it on the fly from a seed, trading a little compute for a lot of memory. Fused attention (FlashAttention) is the capstone idea: it combines tiling, the online-softmax running-max/running-sum trick from Chapter 6, and fusion to compute attention without ever materializing the score matrix — the optimization that made long-context transformers practical. Persistent kernels keep programs resident and loop over work to amortize launch overhead.
The meta-message: you won't memorize these kernels — you'll recognize the principles in them. Every one is keep-data-on-chip, reuse-it, fuse-the-chain, hide-the-latency, tune-empirically. That's the durable skill this course was building toward.
This chapter covers:
- Fused Layer Normalization: reduction + scale/shift in one pass
- Low-Memory Dropout: regenerate the mask from a seed
- Fused Attention (FlashAttention): attention without the N×N matrix
- Persistent Kernels: amortizing launch overhead
- Where to Go Next: extending your Triton skills
Chapter Roadmap
Click any topic to jump in
Fused Layer Normalization
Per-row mean/variance reduction + affine transform fused into one DRAM round-trip, like softmax.
Low-Memory Dropout
Regenerate the random mask from a seed instead of storing it — recompute to save memory.
Fused Attention (FlashAttention)
Tiling + online softmax compute attention with O(N) memory — no N×N score matrix in DRAM.
Persistent Kernels
Launch SM-filling programs that loop over work to amortize launch overhead and reuse state.
Where to Go Next
Apply the principles: diagnose the regime, fuse memory-bound chains, tune against the roofline.
Fused Layer Normalization
Low-Memory Dropout
Fused Attention (FlashAttention)
Sign up to unlock this chapter
This chapter is part of PixelBank Premium. Create a free account, then upgrade to read the full lesson — concepts, walkthroughs, and exercises.