Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Converts cuTile GPU kernels (@ct.kernel) to Triton (@triton.jit), including dual-layout kernels and debugging of failed translations.
Use this skill ↓68% 82%+14 ptsof test cases passed
Passed 18 of 22 test cases with the skill, and 15 of 22 without it.
3 of 3 safety checks passed
Not used yet
Purpose: One-page strategy distilled from translations/advanced-patterns.md and optimizing-reference.md. Agents must apply this when converting attention / FMHA / Gemma-style kernels (e.g. gemma_attention) or any kernel where Triton is expected to match an optimized in-repo baseline.
Full detail: Use this file for what to do and in what order; open the two linked docs for proofs, code samples, and edge cases.
| Trigger | Action |
|---|---|
| Converting attention, FMHA, sliding window, soft cap, or GQA (e.g. Gemma) | Read §4 Gemma / FMHA checklist below before writing the Triton inner loop. |
Host exposes transpose / transpose_v or MLA-style layout modes | Read §1 + advanced-patterns §1; use two kernels, not one + tl.trans in the KV loop. |
Kernel uses @triton.autotune | Read §2 + advanced-patterns §2; grid lambda META: (...); never freeze BLOCK_* from Python in a way that ignores autotune. |
| After TMA is in place but Triton still >20% slower than cuTile / baseline | Walk §3 + optimizing-reference sections 1–7 and §9 as applicable. |
| 10–50× regression | translations/workflow.md — CRITICAL PERFORMANCE PATTERNS first (raw tl.load vs TMA). |
transpose / transpose_v): Implement separate @triton.jit kernels when math and TMA layouts differ per mode (MLA: qk [H,N] vs [N,H], different V descriptor). Reusing the transpose path with extra tl.trans per KV block → 3–15× on the other mode.grid = lambda META: (triton.cdiv(..., META["BLOCK_M"]), ...) — tile sizes come from META, not hard-coded forward() kwargs that bypass tuning.TensorDescriptor vs in-kernel tl.make_tensor_descriptor: If descriptors must track autotuned block sizes, use a pre_hook to set block_shape per config (see Gemma FMHA host side), or follow mla_decoding.py in-kernel style — do not freeze wrong tile sizes on the host.program_id(1) selects tensor) — optimizing-reference §8, advanced-patterns §5.Apply in roughly this order after all 2D+ tile paths use TMA (or justified exceptions):
| Priority | Pattern | Impact (typical) | Pointer |
|---|---|---|---|
| 1 | Autotune breadth + backend/GPU split — get_available_triton_backend(), torch.cuda.get_device_capability(), num_stages, num_warps, occupancy, warp_specialize where the stack supports it | 10–20%+ | optimizing-reference §4 |
| 2 | EVEN_K / EVEN_* heuristics — skip masks in inner loop when divisible | 5–15% | §1 |
| 3 | Transpose — pointer/layout encoding; avoid tl.trans inside the K/V loop when avoidable | 5–15% | §2 |
| 4 | 2D grid for pointer BMM — (num_mn_blocks, batch) + grouped M for L2 | 0–10% | §3 |
| 5 | Epilogue subtile (large TMA stores) | 5–15% | §5 |
Skills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.