Unit 10 of 10 · about 6 hours · measure
Library baselines, shape-aware dispatch and residual analysis
A custom kernel needs a strong, equivalent baseline and evidence for where it wins or loses. Dispatch converts isolated tuning results into a bounded usable implementation.
You'll be able to
- Build a correctness-gated cuBLAS or cuBLASLt baseline with matching layout, precision and epilogue semantics.
- Select kernels by shape and contract with a safe fallback for unseen inputs.
- Explain measured time beyond the roofline lower bound using resource, instruction and complete-operation evidence.
Covers
Read
In this order, only the parts listed
0 of 3 done
- Library descriptors and candidate timingAI Systems Performance Engineering companion code - Chapters 9 and 10
main: matrix layouts, CUBLAS_COMPUTE_32F descriptor, workspace preference, heuristic candidate loop and fallback, at commit b57e4c6
Extract a small rectangular wrapper. Skip PDL. The file's tensor-core label does not prove tensor execution, and
baseline_cublaslt_gemm.cuis a naive custom kernel, not the vendor baseline. - Bounded tuning and instruction evidenceHow to Optimize a CUDA Matmul Kernel for cuBLAS-like Performance: a Worklog
Kernel 9: Autotuning; Kernel 10: Warptiling
Use a small candidate set, not the published A6000 timing table as a target. Add held-out shapes and edge-safe fallbacks.
- Problem sizes and schedulingMIT 6.S894 Accelerated Computing (Fall 2025) - Lectures 6 and 8 and Labs 4 to 6
Fall 2025 Lab 5 Part 0: Understanding Occupancy; Part 1: Improving Performance; Part 2: Handling More Problem Sizes
Use the shape and occupancy questions; do not adopt the course GPU's expected times.
Focus on
- Match operand storage, transpose flags, strides, batch count, input and accumulator types, /, output dtype and epilogue. Include required conversions and separate epilogue kernels when comparing complete operations.
- Use stream events after warmup, interleave candidates, retain distributions and recheck correctness after selection. Record GPU, compiler, driver, library versions, workspace and math mode; timing tuning is separate from steady-state dispatch.
- Key dispatch by shape, layout/alignment, dtype and numerical contract. A tuned aligned kernel is invalid for an unaligned view even if its dimensions match.
- Use as a lower-bound model under stated compute and traffic assumptions. Positive residual is not itself a diagnosis; test launch, tails, issue rate, spills, occupancy and epilogue hypotheses.
Common mistakes · 3
- Comparing a strict FP32 kernel with an unconstrained TF32 library path while reporting only speed.
- Timing allocation, tuning or host dispatch for one candidate but only device computation for another.
- Naming a bottleneck from roofline position alone or inventing profiler counters when access is denied.
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.Is the first cuBLASLt heuristic guaranteed fastest?Answer
No. It proposes eligible candidates; measure them under the same contract and workspace limit, after correctness checks.
2.What does a negative residual suggest?Answer
At least one model assumption or measurement is inconsistent: FLOP count, byte model, attainable rates, cache residency or timing scope. It does not prove the hardware exceeded a valid bound.
3.What should dispatch do on an unseen or unsupported layout?Answer
Select a validated general kernel or vendor fallback, rather than reusing a specialization whose preconditions are not satisfied.
You're done when
Every dispatched path and held-out fallback passes its numerical contract, and your reproducible comparison identifies a losing regime with evidence or an explicitly untested counter hypothesis.
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 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. - 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.
- 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.
Also in this 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.
- 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.
- 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.