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
Use this reference when converting or optimizing GEMM/BMM/attention-style Triton kernels so the result is within ~20% of cuTile (or of an existing optimized Triton implementation). Patterns below are derived from real comparisons (e.g. BMM: pointer + TMA kernels) and apply to batched matmul, attention, and block-level matmul.
Prerequisites: TMA is already applied for all 2D+ tile loads (complete TMA OPTIMIZATION (Phase c2t-4) and read CRITICAL PERFORMANCE PATTERNS in translations/workflow.md). This document covers post-TMA optimizations that can still yield ~10–20% gains.
Strategy hub: optimization-strategy.md condenses this file and advanced-patterns.md into an ordered checklist; use it for attention / Gemma FMHA (§4) and for §2–§3 fast-vs-slow patterns before deep-diving here.
Impact: ~5–15% for GEMM/BMM when the reduced dimension (usually K) is divisible by the tile size.
Problem: In the K-loop (or any reduction loop), using a mask on every load when the remaining length equals the block size adds branches and prevents the compiler from emitting a single bulk load.
Pattern:
EVEN_K: K % BLOCK_K == 0).k_remaining (or equivalent).@triton.heuristics({"EVEN_K": lambda args: args["K"] % args["BLOCK_SIZE_K"] == 0})
@triton.jit
def kernel(..., EVEN_K: tl.constexpr):
for k in range(0, tl.cdiv(K, BLOCK_SIZE_K)):
if EVEN_K:
a = tl.load(a_ptrs)
b = tl.load(b_ptrs)
else:
k_remaining = K - k * BLOCK_SIZE_K
a = tl.load(a_ptrs, mask=offs_k[None, :] < k_remaining, other=0.0)
Skills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.