Unit 10 of 10 · about 4 hours · implement

Other programming models, dispatch with fallback and compiler regression tests

A kernel that wins on one stack and breaks on the next is a demo. Dispatch plus regression tests turn it into infrastructure.

You'll be able to

  • Compare Triton, Pallas, cuTile (Tile IR) and the CuTe DSL on mapping, scheduling and effort for one kernel.
  • Build device, dtype, shape and layout dispatch with a tested fallback for every unvalidated path.
  • Write compiler-version, generated-code and performance regression tests that fail on real drift.

Covers

Pallas, ROCm and NKI programming-model comparisonDevice, dtype, shape and layout dispatch with fallbackCompiler-version, generated-code and performance regression tests
1

Read

In this order, only the parts listed

0 of 3 done

  1. Higher-level kernel languagesMIT 6.S894 Lecture 10 - Domain Languages and Accelerators

    Lecture 10, Higher-level kernel languages slides: Triton blocked matmul with tl.program_id and pointer arithmetic, the Pallas block-reference form (pl.BlockSpec, pallas_call), and the Triton against CUDA against SASS effort-performance ordering with cuTile and the CuTe DSL

  2. Tile IR programming modelCUDA Tile IR Programming Model

    Section 3 through 3.1.2: tile kernels, tile-blocks as the unit of execution, and how tile programming differs from SIMT thread mapping

    Read the model and inspect the official repository. Implement a parity kernel only if your toolchain supports it, and record the compiler-version constraint.

  3. Binary checks for dispatch and regressionsPTX ISA and CUDA Binary Utilities

    Sections 2.1.2 (listing embedded binaries to confirm the shipped arch) and 2.1.3 (resource usage to pin down register and shared-memory drift across versions)

2

Focus on

  • Triton maps programs explicitly to blocks and schedules inside blocks automatically. Pallas names programs with its own IDs and indexes block references declared with pl.BlockSpec instead of raw pointers, and Tile IR abstracts the thread mapping into the compiler.
  • Dispatch keys on device, dtype, shape and layout together. Any untested combination must route to the validated fallback, never to the fast path.
  • Pin the compiler and library versions in every regression test. A Triton or CUDA update can change tiling, precision defaults and resource use.
  • Keep negative results: shapes where the custom kernel loses to the library decide the dispatch boundary.
Common mistakes · 3
  • Dispatching on shape alone. A new dtype or a non-contiguous layout can take the fast path into unvalidated code.
  • Testing only the winning shapes. Regressions hide on the shapes you stopped running, so keep a held-out shape set.
  • Treating Pallas or Tile IR snippets as runnable practice here. Without their toolchains they are reading for the comparison, not implementations.
3

Try it yourself

Closed-book, before checking anything

Closed-book, write a dispatch sketch for a softmax kernel: fast Triton path for contiguous fp32 rows under 8192 columns, library fallback otherwise, plus a regression test that fails when cuobjdump -res-usage registers change across a compiler update. State the fallback condition first.
4

Quiz yourself

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

0 got · 0 missed

  1. 1.What is the essential mapping difference between the Triton and Pallas matmul forms?Answer

    Triton names programs with tl.program_id and builds raw pointers with strides. Pallas names programs with its own IDs and indexes block references declared with pl.BlockSpec instead of pointers.

  2. 2.A new GPU generation doubles shared memory. Does your dispatch change?Answer

    Only after measurement: re-run the shape matrix, confirm the pipeline still wins within resources, and update the boundary. New hardware does not move it by itself.

  3. 3.What must a compiler regression test record besides pass or fail?Answer

    Compiler and library versions, the shipped arch from the embedded binaries, resource usage, tolerances, and the raw timings with warmup stated.

  4. 4.When is the library path the right production choice over your faster kernel?Answer

    When dispatch cannot cover the shape, dtype, layout or arch mix, when maintenance owns the risk, or when the measured end-to-end gain vanishes outside the benchmark.

5

Practice

  • LeetGPU 5 Softmax in Triton with dispatch and fallback

    Public challenge.py at challenges/medium/5_softmax/challenge.py: max-trick reference with atol=1e-05, rtol=1e-05, free tier

    Wrap your kernel in device, dtype, shape and contiguity dispatch with a torch.softmax fallback, and add a version-pinned regression test over held-out shapes including non-multiples. Run it on LeetGPU or locally against reference_impl from challenge.py.

You're done when

Your dispatch routes every held-out shape, dtype and layout to a tested path, and a compiler update fails loudly instead of silently.

Only when you can do this without notes.

Leads to

Notes

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

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

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.

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

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

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