Unit 4 of 10 · about 4 hours · derive
Block, warp and instruction tiling with swizzled shared-memory layouts
A tile shape does not specify which lane owns each value. Explicit ownership and address maps connect the algorithm to shared-memory transactions and MMA operands.
You'll be able to
- Derive block, warp and instruction tiles without conflating copy ownership with compute ownership.
- Enumerate shared-memory addresses and banks for a specified access pattern.
- Explain how padding or a bijective swizzle changes physical placement without changing the product.
Covers
Read
In this order, only the parts listed
0 of 2 done
- Independent copy and compute partitionsCuTe GEMM Tutorial
sgemm_1.cu: CTA Partitioning through Math partitioning;sgemm_2.cu: TiledCopy, TiledMMA and Other changes, documentation dated September 21, 2026Draw one thread's logical coordinates before expanding to the whole block. CuTe represents the second operand as , not conventional .
- A concrete swizzled Ampere layoutCuTe GEMM Tutorial
gemm_tn:sA,sBandSwizzle<3,3,3>;gemm_device:partition_Sandpartition_Dfor the copies,partition_Candpartition_fragment_A/partition_fragment_Bfor the MMA, CUTLASS v4.2.1Read the half specialization's 128 by 128 by 64 block tile and three shared stages. Its default accumulator is half, not FP32; do not use its timing harness as a correctness oracle.
Focus on
- Derive which block tile contains an output, which warp computes it, and which instruction and lane own its fragment. Copy threads can use a different partition from compute threads.
- For scalar 32-bit shared accesses on the usual 32-bank mapping, bank index is the word address modulo 32. Different addresses in the same bank can conflict; the same address can broadcast.
- A swizzle permutes offsets; both stores and loads must use the same map. Analyze instruction-sized access groups rather than assuming a scalar bank proof also proves an
ldmatrixaccess conflict-free.
Common mistakes · 3
- Treating a warp tile as a per-thread tile. An MMA instruction distributes its operands and results across participating lanes.
- Changing the shared layout at load time but not at store time.
- Calling every same-bank access a conflict, including same-word broadcasts.
Try it yourself
Closed-book, before checking anything
Swizzle<3,3,3> on offsets 0 through 511: it maps each offset once and is its own inverse. Keep that bijection proof separate from a bank-conflict claim for a particular instruction.Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.Why may copy and compute ownership differ?Answer
Copies should follow global-memory and copy-instruction constraints; computation should follow MMA operand ownership. Shared memory connects the two partitions.
2.Does padding change the logical matrix?Answer
No. It changes physical stride and allocation size while preserving logical coordinates and values.
3.Does a bijective swizzle prove conflict freedom?Answer
No. It proves distinct logical slots do not alias. Conflict freedom also depends on the addresses issued together and the hardware instruction's access grouping.
You're done when
Your address enumerator verifies both bank examples and the swizzle bijection, and your diagram separates block, warp, instruction and copy ownership.
Only when you can do this without notes.
Leads to
Notes
Resources · 1 for this unit, 11 more in the section
- 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 - 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.
- 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.
- 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.