Tilegym Converting Cutile To Triton
Converts cuTile GPU kernels (@ct.kernel) to Triton (@triton.jit). Handles standard in-repo conversion, debugging (cudaErrorIllegalAddress, shape mismatch, numerical mismatch), and mapping cuTile idioms (ct.load/ct.store, ct.Constant, ct.launch) to Triton equivalents. Covers dual-kernel layout flags (e.g. transpose=True/False + autotune grid via META) per translations/advanced-patterns.md. Use when converting, porting, or translating cuTile kernels to Triton, or debugging existing Triton translations.
- Skill ID
- nvidia/skills/tilegym-converting-cutile-to-triton
- Publisher
- nvidia
- Repository
- skills
- Installs
- 0
- Files
- 25
- License
- CC-BY-4.0 AND Apache-2.0
- Synced
- Sep 23, 2026
Open any RiverX project, open the Skills panel in the chat, and search for this identifier. The files are fetched from the source repository at install time.
nvidia/skills/tilegym-converting-cutile-to-tritonInstalls these files- BENCHMARK.md
- SKILL.md
- evals/evals.json
- examples/01_vector_add/cutile_kernel.py
- examples/01_vector_add/triton_kernel.py
- examples/02_softmax/cutile_kernel.py
- examples/02_softmax/triton_kernel.py
- examples/03_layernorm/cutile_kernel.py
- examples/03_layernorm/triton_kernel.py
- examples/04_matmul/cutile_kernel.py
- examples/04_matmul/triton_kernel.py
- examples/05_attention/cutile_kernel.py
- examples/05_attention/triton_kernel.py
- references/api-mapping.md
- references/debugging.md
- references/gotchas.md
- references/harness-integration.md
- references/optimization-strategy.md
- references/optimizing-reference.md
- references/performance-gotchas.md
- skill-card.md
- skill.oms.sig
- translations/advanced-patterns.md
- translations/file-structure.md
- translations/workflow.md
What this skill tells the agent
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](./references/optimization-strategy.md) before converting the inner loop, then apply [§4 Gemma FMHA checklist](./references/optimization-strategy.md#4-gemma-fmha--gemma_attention-conversion-checklist-mandatory). 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 <code>kernel[grid](args)</code> with tuple orlambda META: (…)for autotune; noct.launch.
- Validate — Syntax-check the new Triton module; run the relevant TileGym pytest targets for the op:
pytest tests/ops/test_<op>.py -k "triton" -vs. Fix failures before benchmarking.
- Benchmark — Compare Triton vs cuTile on perf tests. If Triton is clearly slower, follow PERFORMANCE ANALYSIS (Phase c2t-5) in translations/workflow.md and references/optimizing-reference.md for GEMM/BMM/attention; use references/optimization-strategy.md as the ordered checklist. If you see 10–50× slowdowns, read CRITICAL PERFORMANCE PATTERNS in that same workflow file first.
Execution rules (MUST):
- Create and track the conversion checklist (e.g. TodoWrite) before editing kernel code; complete steps in order—do not skip pre-flight or TMA decisions.
- For attention / FMHA / Gemma / GQA / soft cap / sliding window: read references/optimization-strategy.md and apply §4 before treating the conversion as optimized.
- Do not ship raw pointer+mask 2D+ tile loads where TMA applies; document any intentional exception.
- If tests or benchmarks fail a gate, stop and fix before declaring the conversion done—do not stack unverified changes.
Workflow Selection
- Existing TileGym op → Standard Mode: translations/workflow.md
- Errors (
cudaErrorIllegalAddress, shape mismatch, numerical mismatch) → references/debugging.md - Advanced patterns (TMA, dual layout flags
transpose, autotune +METAgrid, Array.slice, ct.gather().item()) → [translations/advanced-patterns.md](./translations/advanced-patterns.md) (MLA-style two kernels, avoid 3–15× regression ontranspose=False). - Performance (Triton kernel slower than cuTile, autotuning, profiling) → translations/workflow.md (section PERFORMANCE ANALYSIS (Phase c2t-5))
- Optimization strategy hub (ordered checklist: advanced-patterns + optimizing-reference) → [references/optimization-strategy.md](./references/optimization-strategy.md) — read first for attention/FMHA/Gemma; then drill into the two source docs as needed
- Optimizing GEMM/BMM/attention (after TMA, or Triton 10–20% slower) → [references/optimizing-reference.md](./references/optimizing-reference.md) — EVEN_K fast path, transpose via pointer arithmetic, grid layout, autotune breadth, epilogue subtile; use these patterns during conversion and before perf sign-off (summarized in optimization-strategy §2–§3)
- Gemma attention / GQA FMHA conversion → [references/optimization-strategy.md §4](./references/optimization-strategy.md#4-gemma-fmha--gemma_attention-conversion-checklist-mandatory)
- Blackwell optimization (complex kernels with iterative algorithms, register pressure, loop unrolling) → [references/optimizing-reference.md](./references/optimizing-reference.md) §9 — TMA descriptors,
loop_unroll_factor, occupancy autotuning, TMEM-friendly block sizes, slab allocator, dual-path kernel design - ⚠️ 10-50x REGRESSION (catastrophic slowdown after conversion) → [translations/workflow.md](./translations/workflow.md) — section CRITICAL PERFORMANCE PATTERNS (AVOID 10-50x REGRESSION)
- ⚠️ Good perf on `transpose=True` only, collapse on `transpose=False` (or opposite) → [translations/advanced-patterns.md](./translations/advanced-patterns.md) — §1 Dual layout flag; two
@triton.jitkernels +grid = lambda META: (... META["BLOCK_H"] ...)
Pre-flight Analysis (Run BEFORE converting)
# Count kernels (only main kernel gets @triton.jit, helpers stay plain def)
grep "@ct\.kernel" source.py | wc -l
# Check for patterns needing special handling
grep "ct\.transpose\|ct\.permute" source.py # → use tl.trans/tl.permute
grep "ct\.astype" source.py # → use .to(dtype)
grep "ct\.load\|ct\.store" source.py # → TMA for 2D+ (tl.make_tensor_descriptor), NOT raw tl.load(ptr+offs)
grep "ct\.launch" source.py # → bracket launch: kernel then [grid] then (args)
grep "ct\.Constant\|ct\.ConstInt" source.py # → tl.constexpr
grep "ct\.cdiv" source.py # → triton.cdiv (host) or Python (a+b-1)//b
grep "ct\.bid\|ct\.num_blocks" source.py # → tl.program_id/tl.num_programs
grep "1 << .*\.bit_length" source.py # → triton.next_power_of_2 if needed
grep "transpose\|transpose_v" source.py # → if hit, read translations/advanced-patterns.md (dual kernels + META grid)Conversion Checklist
Copy this checklist and track progress:
Conversion Progress:
[ ] Step 0 (attention / Gemma FMHA / GQA / soft cap / sliding window): Read [references/optimization-strategy.md](./references/optimization-strategy.md) and apply §4 checklist before inner-loop Triton
[ ] Step 1: Pre-flight — run grep commands above, note special patterns and 2D+ loads (→ TMA)
[ ] Step 2: Analyze source cuTile kernel (identify patterns, shapes, dtypes)
[ ] Step 3: Create Triton file with correct structure (see translations/file-structure.md)
[ ] Step 4: Convert kernel signature (tensor args → pointer args, Constant → constexpr)More from nvidia
Use this skill in a project
Open any RiverX project, search the Skills panel for nvidia/skills/tilegym-converting-cutile-to-triton, and install it in one click.
