Unit 8 of 10 · about 5 hours · derive

The CUTLASS hierarchy and CuTe layout algebra

CuTe layouts are the vocabulary that CUTLASS, Triton and Tile IR all translate into. Reading them turns template errors into indexing facts.

You'll be able to

  • Read a CUTLASS 3.x GEMM from device down to atoms through layouts, strides and tiles.
  • Evaluate CuTe layouts as functions: shape, stride, index mapping, size and cosize.
  • Partition global, shared and register tiles across CTAs and threads with local_tile and local_partition.

Covers

CUTLASS device, kernel, collective, tiled MMA and atom hierarchyCuTe layouts, coordinates, composition and logical division
1

Read

In this order, only the parts listed

0 of 3 done

  1. CUTLASS 3.0 designCUTLASS 3.x Design and CuTe Layout Algebra

    CUTLASS 3.0 design goals, A new Conceptual GEMM Hierarchy (layers detached from hardware generations), Adoption of CuTe Layout and Tensors, and Reducing the number of named types and iterator concepts

  2. CuTe GEMM tutorial: tensors, tiles and partitionsCUTLASS 3.x Design and CuTe Layout Algebra

    High-level interface (problem shape, CTA tiler, strides); The Full Tensors with (M,K), (N,K), (M,N) modes and the M-major, N-major, K-major table; CTA Partitioning with local_tile over zipped_divide; SMEM tensors with cosize allocation; Copy partitioning and Math partitioning with local_partition

    Work through sgemm_1.cu only. Leave sgemm_2.cu atoms, the SM70/SM80 pipelines and GETT for the atoms unit.

  3. GPU MODE Lecture 103: CuTe layout algebraGPU MODE - Triton, CuTe and Machine Code

    Slides on layout definitions, composition and the composition algorithm

2

Focus on

  • A layout is a function from logical coordinates to offsets. size measures the domain and cosize the codomain, and allocation uses cosize.
  • CuTe stores B as (N,K), not (K,N). Both inputs reduce over their second mode, so read every stride pair against that convention.
  • Majorness names the stride-1 mode: M-major, N-major or K-major. It replaces the BLAS transposed and non-transposed flags.
  • local_tile slices the rest mode to give each CTA its tile; local_partition slices the tile mode to give each thread its share.
Common mistakes · 3
  • Reading B strides as (K,N). Under the (N,K) convention the reduction mode sits second in both inputs, and every partition assumes it.
  • Using size for the shared allocation. Padded layouts have cosize larger than size, and allocating size overflows the padding.
  • Treating NT and TN labels as layout facts. They describe BLAS calling convention; only the inspected layout tells you the stride-1 mode.
3

Try it yourself

Closed-book, before checking anything

Closed-book, give the byte-free element address of for layout , then compute the cosize of the padded shared-memory layout with shape and stride : maximum offset , so cosize 1031. State why allocation needs 1031 elements and not 1024.
4

Quiz yourself

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

0 got · 0 missed

  1. 1.For layout , which index runs over contiguous elements?Answer

    The index : address advances by 1 per row step, so the matrix is M-major.

  2. 2.What breaks if the shared allocation uses size for the padded , layout?Answer

    Seven elements of padding per column go unallocated. Writes to padded offsets land out of bounds even though every logical index is in range.

  3. 3.What do local_tile and local_partition each slice, and what mode does each leave behind?Answer

    local_tile slices the rest mode with the CTA coordinate and leaves the tile modes plus the K rest index, giving (BLK_M,BLK_K,k) so the CTA can loop over its K tiles. local_partition slices the tile mode with the thread index and leaves the rest mode, giving each thread its elements repeated across the tile.

  4. 4.A kernel is labeled TN for both inputs. What are the two layouts?Answer

    Both K-major: A is and B is . Confirm by inspecting the layouts, not the label.

You're done when

You can hand-evaluate any static layout in the tutorial to addresses and partition coordinates, and defend each CTA and thread tile against the code.

Only when you can do this without notes.

Leads to

Notes

Resources · 2 for this unit, 10 more in the section
  • CUTLASS 3.x Design and CuTe Layout AlgebraNVIDIA · required

    Study the collective and kernel hierarchy, then the CuTe layout algebra guide. Reconstruct one GEMM configuration down to layouts, copy atoms and MMA atoms and compare it with the equivalent Triton blocked program.

  • GPU MODE - Triton, CuTe and Machine CodeGPU MODE · support

    Use Lectures 14, 15, 29, 37, 57, 86, 103, 104 and 114 selectively. Assign one lecture to each actual implementation question rather than watching the collection linearly.

Also in this section

  • Triton Programming Guide and TutorialsTriton Project · primary

    Complete the vector add, fused softmax, matrix multiplication, LayerNorm and fused-attention tutorials that run on your hardware. For each, add adversarial tails, independent references, cold and warm timing, resource inspection and a correct fallback.

  • UCSD CSE 291A/DSC 291 (Spring 2026) PA2 Part 1 - Triton matmul, add and ReLUUC San Diego · required

    Implement the fused kernel and its configuration search, and test with student_local_test.py on your own GPU. The remote grader needs a course token, so replace its speedup score with your own interleaved timing against the PyTorch reference.

  • TensorTonic Language Modeling from Scratch - Triton problemsTensorTonic · support

    Solve Masked Triton GELU Kernel, Tiled Triton Row Sum, Triton Row-Wise Softmax and Fused Tiled Matmul and ReLU, and rerun each with your own adversarial shapes.

  • AI Systems Performance Engineering - Chapter 14Chris Fregly · required

    Read Chapter 14 on the PyTorch compiler, OpenAI Triton and XLA backends. Trace one framework operation from graph capture through generated GPU code, and identify graph breaks and specialization guards.

  • AI Systems Performance Engineering companion code - Chapters 9, 10, 13 and 14Chris Fregly · support

    Use code/ch09, code/ch10, code/ch13 and code/ch14 selectively for Triton, warp specialization, persistent kernels and compiler comparisons. Strip local compatibility shims when diagnosing upstream failures and record every guard in the measurement context.

  • LeetGPU - CUDA and Triton Parity SetAlphaGPU · required

    Re-solve one primitive, one GEMM and one transformer challenge from GPU-4 through GPU-6 in Triton. Compare CUDA, Triton, compiler and library paths on identical tests and hardware; leaderboard rank does not replace local raw evidence.

  • PTX ISA and CUDA Binary UtilitiesNVIDIA · reference

    Inspect generated PTX and SASS for the matched CUDA and Triton kernels. Check instruction, memory-space and target assumptions in the versioned ISA and use binary tools to confirm which device code ships.

  • CUDA Tile IR Programming ModelNVIDIA · depth

    Read the programming model and inspect the official repository after CUDA, Triton and CuTe mappings are clear. Implement one tiny parity kernel only if the toolchain supports it and record compiler-version constraints.

  • Modern GPU Programming for MLSys - TIRxMLC · depth

    Use Parts II and III plus the compiler reference as a Blackwell-specific comparison of layouts, dispatch, TMA pipelines and persistent scheduling. Do not make TIRx a required dependency for the portable track.

  • MIT 6.S894 Lecture 10 - Domain Languages and AcceleratorsMIT · support

    Use the Higher-level kernel languages slides comparing Triton, Pallas, cuTile (Tile IR) and the CuTe DSL on mapping, effort and performance for the programming-model comparison. Do not use the TPU lab.