Unit 9 of 10 · about 4 hours · explain

CuTe copy and MMA atoms, tiled MMAs and pipelines

Atoms separate what moves data from what computes on it. Pipelines then overlap the two, and every overlap bug is an ownership bug.

You'll be able to

  • Select copy and MMA atoms for a GEMM tile and explain what each atom fixes: instruction, types and partitioning.
  • Build tiled copies and tiled MMAs from atoms and connect each partition to its tensor fragment.
  • Reason about pipeline stages, barriers and producer-consumer ownership in an async mainloop.

Covers

Copy and MMA atoms, tiled copies and tiled MMAsPipeline stages, barriers and producer-consumer ownership
1

Read

In this order, only the parts listed

0 of 3 done

  1. CuTe GEMM tutorial: atoms and pipelined mainloopsCUTLASS 3.x Design and CuTe Layout Algebra

    Mainloop with copy, cp_async_fence, cp_async_wait and __syncthreads; TiledCopy with Copy_Atom, partition_S, partition_D and make_fragment_like; TiledMMA with UniversalFMA, partition_A, partition_B, partition_C and make_fragment_C; Other changes with padded shared layouts; sgemm_sm80.cu for the async Ampere pipeline

  2. Warp specialization and software pipeliningAI Systems Performance Engineering - Chapter 14

    Chapter 14, Warp Specialization with Triton (warp_specialize=True on tl.range; the book's num_consumer_groups and num_buffers_warp_spec config keys are rejected by triton.Config in Triton 3.8.0) and Software Pipelining and Double Buffering with Triton (prefetch-next then compute-current with the commit-then-wait handshake, num_stages against occupancy)

  3. Persistent matmulTriton Programming Guide and Tutorials

    Persistent versus naive kernel structure with @triton.autotune configs and proton.scope benchmark regions

    Study the persistent structure and the config tables. Skip the CLC variants, which need compute capability 10.0, and run only configurations that fit your GPU.

2

Focus on

  • An atom binds one instruction to fixed types. UniversalCopy with uint128_t demands vectorizable fragments or the build fails statically.
  • partition_S and partition_D can differ across source and destination. The fragment names record which partitioning each tensor uses.
  • The first MMA mode holds one instruction worth of elements. Its size varies per atom and per tensor, so read it off the atom.
  • Overlap needs the current tile to stay live while the next tile prefetches. Overwriting it lets the compiler reorder copies past uses and silently serializes the loop.
Common mistakes · 3
  • The book handshake names tl.commit and tl.wait, which do not exist in Triton 3.8.0. The real overlap mechanism is the pipelined tl.range with num_stages over descriptor loads, so treat those two names as author pseudocode.
  • Adding stages for free. Each extra stage costs shared memory and can cut occupancy below the point where overlap pays.
  • Copying the 16 by 16 UniversalFMA tiling numbers onto a tensor-core MMA. Real MMAs have their own thread coverage and fragment shapes.
3

Try it yourself

Closed-book, before checking anything

Closed-book, write the tutorial mainloop order for one K tile: copy with the thread partitions, cp_async_fence, cp_async_wait, __syncthreads, gemm on the MMA partitions, __syncthreads. State what each barrier waits for.
4

Quiz yourself

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

0 got · 0 missed

  1. 1.The TiledCopy uses UniversalCopy over uint128_t for fp32 data. How many elements per thread must the partition deliver?Answer

    Four: 128 bits hold four fp32 values. A partition that cannot vectorize to that width fails at compile time.

  2. 2.What does thr_mma.make_fragment_C allocate, and why not make_tensor_like?Answer

    Accumulator fragments shaped by the MMA partitioning, which need not match the global tile layout element for element. The MMA view, not the tensor view, sets the shape.

  3. 3.The pipelined loop is no faster than the naive one, but profiles show copies and math serialized. What is the first suspect?Answer

    The current tile reference dies before its consumer runs, so the compiler hoists the next copy past the current use. Keep the current tile live across the swap.

  4. 4.When does warp specialization beat simply adding stages?Answer

    On long K loops where dedicated producer and consumer warps keep memory and math busy together. Short loops cannot amortize the partition.

5

Practice

  • TensorTonic: Fused Tiled Matmul and ReLU

    Fused tiled matrix multiplication and ReLU for strided float16 or bfloat16 CUDA inputs and preallocated outputs

    Map your kernel to the atom picture first: which loads are the copy stage, where the MMA equivalent accumulates in fp32, and where the ReLU epilogue fuses. Rerun with non-multiple M, N and K.

You're done when

You can label every fragment in your fused kernel as a copy or MMA partition, and your pipeline keeps overlap under a stage count you justify from occupancy.

Only when you can do this without notes.

Leads to

Notes

Resources · 3 for this unit, 9 more in the 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.

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

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

Also in this section

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

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

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