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

cuBLAS or framework library baselines and dispatch contextShape-aware tuning, dispatch and unseen-shape fallbackRoofline, instruction, resource and end-to-end residual analysis
1

Read

In this order, only the parts listed

0 of 3 done

  1. 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.cu is a naive custom kernel, not the vendor baseline.

  2. 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.

  3. 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.

2

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.
3

Try it yourself

Closed-book, before checking anything

Compare naive, shared, register-tiled, async and vendor GEMM on (64,96,32), (256,256,256), (16,512,64) and (257,129,65), first with small integer FP32 inputs and then with declared random-input tolerances. Hold out (31,67,33) from tuning and require fallback correctness. For each candidate save useful FLOPs, compulsory-byte model, event distribution, compiled resources and complete-operation latency. Derive the row-major cuBLAS mapping by computing the transposed output with swapped operands and dimensions; verify it on a nonsquare product before timing. Show one losing regime and a falsifiable residual hypothesis, without promising a custom-kernel win.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 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. 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. 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

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.m16n8k8 fragments, mma and cvt, archived with CUDA 13.0.0; also consult cp.async completion 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.