tilegym-converting-cutile-to-triton
cuTile → Triton Conversion
Convert @ct.kernel kernels to @triton.jit. API mapping: references/api-mapping.md (cuTile → Triton).
In this skill’s Markdown, Triton launch syntax kernel[grid](…) uses Unicode brackets so link checkers do not parse [grid](…) as a hyperlink; use normal ASCII brackets in real Triton code.
Instructions
Follow the phase-gated workflow in translations/workflow.md. Every conversion should go through analyze → convert → validate → test → benchmark, with explicit gates before moving on. Use the documents in Workflow Selection when the task matches a special case (errors, layout flags, perf).
-
Optimization strategy (perf-sensitive / attention) — If the op is attention, FMHA, sliding window, soft cap, or GQA (e.g. Gemma
gemma_attention), read references/optimization-strategy.md before converting the inner loop, then apply §4 Gemma FMHA checklist. For other GEMM/BMM/attention-adjacent kernels, still skim §2–§3 of that file after TMA is done. -
Select path — Existing TileGym op: standard mode in
translations/workflow.md. If the cuTile source usestranspose/transpose_v, dual layouts, or MLA-style paths, read translations/advanced-patterns.md before writing Triton (two kernels +METAgrid, not one kernel +tl.trans). -
Pre-flight — Run the Pre-flight Analysis grep commands on the cuTile source. Count
@ct.kerneldefinitions; note TMA-relevantct.load/ct.store,ct.launch,Constant, and layout flags. -
Read mapping — Keep references/api-mapping.md open for cuTile → Triton API pairs. For runtime failures (illegal address, dtype, strides), use references/debugging.md.
-
Convert — Copy the Conversion Checklist into a todo list and execute in order. Structure and file placement: translations/file-structure.md. Mandatory: any 2D+ block-shaped tile load/store uses
tl.make_tensor_descriptor(TMA), not rawtl.load(ptr+offs, mask=…)for full tiles—skipping this is the most common source of large regressions. Host side: Triton bracket launch kernel[grid](args) with tuple orlambda META: (…)for autotune; noct.launch.