Unit 6 of 10 · about 6 hours · explain, implement
Asynchronous copies, multistage pipelines and warp specialization
Overlapping future loads with current arithmetic can hide latency only if a stage is complete before consumption and no producer overwrites live data.
You'll be able to
- Implement an Ampere two-stage global-to-shared copy pipeline with a correct prologue and drain.
- Explain completion, visibility and buffer-reuse dependencies independently.
- Describe Hopper producer-consumer warp specialization, running its hardware-specific instructions only on Hopper or newer GPUs.
Covers
Read
In this order, only the parts listed
0 of 4 done
- Buffer lifetimes and producer-consumer rolesAI Systems Performance Engineering - Chapters 9 and 10
Chapter 10: Intra-Kernel Pipelining Techniques; Cooperative Tiling and Double-Buffering with the CUDA Pipeline API; Warp Specialization and the Producer-Consumer Model
Read for the schedule and ownership. Skip cluster, cooperative-grid and Blackwell mechanisms.
- Ampere multistage mainloopCuTe GEMM Tutorial
gemm_device: async-copy prefetch,smem_pipe_read/smem_pipe_write,cp_async_fenceandcp_async_wait, CUTLASS v4.2.1Trace the three-stage source, then implement a simpler two-stage pipeline in your existing scalar GEMM. Add predicates and zero-fill tails; the tutorial assumes divisible dimensions.
- What an async-copy wait guaranteesCUDA 13.0 matrix programming and PTX references
PTX ISA 9.0:
cp.async,cp.async.commit_groupandcp.async.wait_group/cp.async.wait_allRead the
sm_80requirement, 4/8/16-byte sizes, source-size zero fill and per-thread group completion. - Ampere schedule versus Hopper specializationMIT 6.S894 Accelerated Computing (Fall 2025) - Lectures 6 and 8 and Labs 4 to 6
Fall 2025 Lecture 8 slides 7-9 and 11-21
Skip slide 10's arithmetic-intensity formula. Hopper TMA, WGMMA and register redistribution are explanation-only unless matching hardware is available.
Focus on
- Model each stage as free, filling, ready, consuming and free again. Completion must precede reads, and the last consumer must finish before reuse.
- A
cp.asyncwait completes the issuing thread's selected groups; a block barrier coordinates cross-thread consumption. A barrier alone is not an async-copy completion operation. - Two stages double the one-stage shared allocation before padding. Additional stages consume resources and do not guarantee faster execution.
- Warp specialization assigns copy and compute roles to different warps. Separate role-specific readiness and release signals from a barrier requiring all block threads.
Common mistakes · 3
- Waiting on the wrong group count in the final iteration and consuming an unfinished stage.
- Reusing a buffer after copy completion but before all computation using it has finished.
- Putting a full-block barrier only in producer or consumer code.
Try it yourself
Closed-book, before checking anything
cp.async.ca copies (.cg takes only 16 bytes) with zero source size for masked FP32 inputs. Test shapes (17,19,0), (17,19,1), (17,19,16), (17,19,17) and (17,19,65) with reduction tile 16 against CPU double products of integers cycling -2 to 2. Run memory, race and synchronization sanitizers, then compare synchronous and pipelined event intervals without assuming a speedup.Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.Why test fewer reduction tiles than pipeline stages?Answer
The prologue must not load nonexistent tiles, and the drain must wait for the groups actually issued rather than a steady-state assumption.
2.Does
cp.asyncremove shared-memory synchronization?AnswerNo. Completion and cross-thread visibility must still be established, and consumers must release storage before overwrite.
3.Why might three stages lose to two?Answer
Extra shared memory can reduce resident blocks, while copy latency may already be hidden and extra scheduling can add overhead.
You're done when
All stage-count and tail cases pass correctness and sanitizer checks, and every wait and reuse barrier has a stated ownership dependency.
Only when you can do this without notes.
Leads to
Notes
Resources · 4 for this unit, 8 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.
- 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.
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.
- 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.