Triton, CuTe and Compiler Paths

Modern kernel work spans CUDA, tile languages, template libraries and graph compilers. This stage implements the same mechanisms through multiple abstraction levels, inspects lowering and makes autotuning, dispatch and fallback correctness explicit.

Section 7 of 10 · 10 units · about 40 hours

0/10

By the end you can Implement the same nontrivial kernel in CUDA and Triton, reconstruct the lowering and resource behavior, correctness-gate autotuning and dispatch, and preserve compiler or library fallback across unseen shapes and one version change.

Units

Build it

Mini project · about 12 to 16 hours

Matched CUDA and Triton paths with lowering and dispatch gates

Implement the same mechanisms in CUDA and Triton: blocked programs, reductions, autotuning, codegen inspection, a custom op, one CuTe GEMM reconstruction and versioned dispatch with fallback. Paths your toolchain or GPU lacks are read, not run.

  1. 1Write a Triton vector-add kernel with its grid function, checked against x + y on shapes you choose, including non-multiples of the block size. Add a masked approximate GELU checked against torch.nn.functional.gelu in two dtypes, each with a matched CUDA twin under identical tests.
  2. 2Implement tiled row sums and stable row-wise softmax for strided inputs with padding and partial tiles, checked against fp32 references. Show where tl.dot precision flags change the error against float64, and name which rounding dominates.
  3. 3Run the CSE 291A PA2 Part 1 fused kernel under student_local_test.py, with an autotuning search gated on correctness. Separate cold compile cost from warm launch cost with interleaved timings against the PyTorch reference.
  4. 4Inspect one compiled kernel from Triton IR down to PTX, quoting register and shared-memory usage from your own build. Compile one CUDA source file with -arch=native and compare cuobjdump -sass and cuobjdump -res-usage output with the Triton report.
  5. 5Use torch._dynamo.explain to contrast a data-dependent branch with its branch-free rewrite, quoting graph and break counts from your own run. Register a Triton LayerNorm as a custom op with gradient checks against the framework, and record its higher-order limitation.
  6. 6Reconstruct one GEMM configuration down to layouts, copy atoms and MMA atoms, and compare it stage by stage with the equivalent Triton blocked program. Wrap the Triton softmax from LeetGPU challenge 5 in versioned dispatch with a tested fallback and a register-change regression.
What you hand in
  • Matched CUDA and Triton kernels with shared tests, pinned precision and kept losing shapes.
  • Autotune and compile evidence: cold against warm costs, codegen dumps and dynamo break reports.
  • The CuTe GEMM reconstruction, the custom LayerNorm op and versioned dispatch with fallback.
How to check it
How it's graded

Parity with pins

Pass: CUDA and Triton twins pass identical tests from your own harness including tails and non-powers of two, with precision pinned before timing and losing shapes kept.

Great: Register and shared-memory lines are quoted from your own build, with the flags that produced them.

Autotune and lowering honesty

Pass: The second autotuned launch skips benchmarking, cold and warm costs are separated, and break counts come from your own run.

Great: Each recompile names the guard that triggered it.

Reconstruction and dispatch

Pass: The CuTe reconstruction reaches layouts, copy atoms and MMA atoms, and dispatch tests cover native, forced fallback and register-change branches.

Great: The LayerNorm gradient derivation states its row-mean terms and its higher-order limit is tested.

Resources

  • Triton Programming Guide and TutorialsTriton Project

    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

    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.

  • AI Systems Performance Engineering - Chapter 14Chris Fregly

    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

    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

    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.

  • TensorTonic Language Modeling from Scratch - Triton problemsTensorTonic

    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

    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.

  • GPU MODE - Triton, CuTe and Machine CodeGPU MODE

    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.

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

    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.

  • CUDA Tile IR Programming ModelNVIDIA

    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

    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.

  • PTX ISA and CUDA Binary UtilitiesNVIDIA

    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.