Unit 9 of 10 · about 5 hours · implement
Epilogue fusion and persistent or grouped GEMM
Fusion can remove intermediate traffic, while persistence can amortize scheduling across tiles. Both can lose if resource pressure or scheduling overhead outweighs the saved work.
You'll be able to
- Implement bias, scale and ReLU directly in a GEMM epilogue and verify operation order.
- Distinguish batched, grouped and persistent execution schedules.
- Implement an optional bounded persistent tile scheduler and compare the complete fused operation with an unfused baseline.
Covers
Read
In this order, only the parts listed
0 of 3 done
- Fusion and long-lived work schedulingAI Systems Performance Engineering - Chapters 9 and 10
Chapter 9: Kernel Fusion; Chapter 10: Persistent Kernels and Megakernels, Common Workloads for Persistent Kernels
Implement a bounded GEMM epilogue, not a megakernel or cooperative-grid runtime. Persistence and grouped GEMM are optional extensions after the fused operation passes.
- GEMM lifecycle and persistenceMIT 6.S894 Accelerated Computing (Fall 2025) - Lectures 6 and 8 and Labs 4 to 6
Fall 2025 Lecture 8 slides 25-31
Extract scheduling and prologue/epilogue arguments. Do not implement Hopper-only cluster or warpgroup instructions for this unit.
- A coordinate-aware epilogueCuTe GEMM Tutorial
Predication: GEMM epilogue example and coordinate predicates, documentation dated September 21, 2026
Reuse output predicates when adding column bias and activation. Ensure the bias index is the logical column, not a fragment-array index.
Focus on
- Define the fused contract as , where is the accumulator product. Omit reconstruction factors for unquantized inputs. Apply output conversion only after this epilogue.
- For a separate elementwise epilogue, fusion removes one intermediate write and one intermediate read, or requested bytes. Bias, old-output reads and final-output writes remain; caches can change actual DRAM savings.
- Batched GEMM has a regular family of products; grouped GEMM can vary shapes and pointers. Persistence describes long-lived blocks taking multiple tiles, not a different mathematical operation.
- A bounded persistent scheduler can assign flattened tile IDs with a grid-stride loop. Reset accumulators for every tile, map group boundaries explicitly, and retain a nonpersistent fallback.
Common mistakes · 3
- Applying activation before bias or reconstruction and thereby changing the operation.
- Reading the old output when the overwrite contract has and may supply uninitialized storage.
- Assuming persistence guarantees load balance or that grouped GEMM is identical to a uniform strided batch.
Try it yourself
Closed-book, before checking anything
Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.Which traffic does an in-register epilogue remove?Answer
The intermediate product's write and subsequent epilogue read. It does not remove required bias, old-output or final-output traffic.
2.Can a persistent block keep the previous tile's accumulator?Answer
Not for an independent output tile. Reset it or load the new tile's required initial state before computing.
3.Why can fusion reduce bytes but still lose?Answer
Added registers, instructions or shared-memory use can reduce throughput or residency; small intermediates may already stay in cache.
You're done when
The fused epilogue passes edge and operation-order tests, its traffic savings are derived, and the report compares complete fused and unfused operations; optional scheduling has its own ownership check.
Only when you can do this without notes.
Leads to
Notes
Resources · 3 for this unit, 9 more in the section
- AI Systems Performance Engineering - Chapters 9 and 10Chris Fregly · primary
Read Chapter 9 on arithmetic intensity, tiling and fusion, and Chapter 10 on intra-kernel pipelining, warp specialization and thread-block clusters. Separate what applies to every NVIDIA GPU from what needs Hopper or Blackwell.
- MIT 6.S894 Accelerated Computing (Fall 2025) - Lectures 6 and 8 and Labs 4 to 6MIT · required
Use Lecture 6 for tensor cores and arithmetic intensity and Lecture 8 (Evolving Ampere to Hopper) for the production GEMM schedule. Do Lab 4 (tiling and reuse), Lab 5 (scheduling and problem sizes) and Lab 6 (tensor cores through inline PTX) built for your own GPU; each harness checks results against bundled test data. Lab 6 needs sm_80 or newer.
- CuTe GEMM TutorialNVIDIA CUTLASS · required
Work through tiling, layouts, copy atoms and MMA atoms. Draw the logical and physical ownership for one tile, then modify a shape or layout and verify both generated mapping and numerical output.
Also in this section
- AI Systems Performance Engineering companion code - Chapters 9 and 10Chris Fregly · required
Inspect and run compatible baseline and optimized paths from
code/ch09andcode/ch10. Verify whether each path is a custom kernel, compiler selection or library dispatch, then add an independent correctness and timing wrapper. - How to Optimize a CUDA Matmul Kernel for cuBLAS-like Performance: a WorklogSimon Boehm · support
Read kernels 1 to 6, 9 and 10 with the companion repository. Its numbers come from an RTX A6000 (Ampere); remeasure on your GPU before comparing your kernels with them.
- OCP 8-bit Floating Point SpecificationOpen Compute Project · required
Study E4M3 and E5M2 encodings, exceptional values and conversion behavior. Build value-boundary tests and separate format correctness from the scaling policy chosen by a framework or kernel.
- LeetGPU - GEMM and Quantized Matmul ChallengesAlphaGPU · required
Solve 2 Matrix Multiplication and 22 GEMM, then choose 30 Batched Matrix Multiplication or 57 FP16 Batched Matmul. Attempt 32 INT8 Quantized Matmul or 81 INT4 Matmul only after scale and accumulator tests pass. Preserve local baselines and shape matrices.
- GPU MODE - CUTLASS, Tensor Cores and CuTeGPU MODE · support
Use Lectures 15, 23, 36, 57, 86, 103 and 114 selectively. Pair each chosen lecture with one implemented layout, instruction or pipeline change and compare it against a vendor-library baseline.
- DeepGEMMDeepSeek · depth
After the portable GEMM passes, reconstruct one Hopper FP8 path from source, identify its hardware, layout and scaling assumptions, and test a bounded modification only on supported hardware. Do not generalize repository benchmarks to other shapes or GPUs.
- Modern GPU Programming for MLSysMLC · depth
Read the performance, data-layout, tensor-core, TMA, tensor-memory, barrier and GEMM chapters for a Blackwell-depth route. Execute only with sm_100a and the pinned TIRx toolchain; otherwise use it for derivation and code reading.
- CUDA 13.0 matrix programming and PTX referencesNVIDIA · reference
Coverage and correctness gap: the pool lacks a precise WMMA contract, and Lab 6 relies on TF32 conversion and register behavior the PTX ISA leaves unspecified. Use Programming Guide 10.24 and PTX ISA 9.0
mma.m16n8k8fragments,mmaandcvt, archived with CUDA 13.0.0; also consultcp.asynccompletion semantics. - TensorRT quantization schemes and workflowsNVIDIA · reference
Coverage gap: the existing pool does not derive scale granularity and reconstruction conventions precisely. Read INT8/FP8 equations, per-tensor/per-channel/block quantization and dynamic quantization in documentation dated October 5, 2026. Skip engine building and replace the block pseudocode's floor-divided scale count with ceiling division.