amd-agi/geak/mla-tilelang-to-triton
Claude Code and agent skill by amd-agi/geak
- community
Checking that the SKILL.md file is still in the repository.
Install
npx vskill@latest install amd-agi/geak/mla-tilelang-to-tritonSKILL.md
When to use
The MLA (multi-head latent attention) decode path is the bottleneck on a DeepSeek-class model on MI300X (gfx942) and the live implementation is a TileLang kernel. Port it to Triton to (a) get an editable, CUDA-graph-capturable core the workflow can further tune, and (b) close the gap to the hand-tuned aiter/asm path while staying author-friendly.
Mechanism
MLA decode is memory-bound on the KV-latent read with a low-rank up-projection fused into the attention. TileLang expresses the tiling explicitly but is harder to autotune inside the kernel layer and can carry a host-sync / graph-capture hazard. A Triton port lets you: keep the latent in registers/LDS across the absorbed up-proj, pick MFMA-friendly BLOCK_M/BLOCK_N for the small decode M, and split the KV loop (split_k / flash-style online softmax) — all as Triton autotune knobs. The win is removing the per-step host sync and matching the MFMA tile to the latent head_dim, not raw FLOPs.
Procedure
- Extract the MLA decode op into the immutable unittest task dir (shapes spanning decode M∈{1,64} and
the latent dims; bf16 and fp8_e4m3_fnuz operands; reference I/O oracle from the TileLang core).
- Author a Triton kernel: flash-style online softmax over the KV-latent loop; absorb the up-projection
(W_UK/W_UV) into the QK / OV matmuls so the latent never expands to full head_dim in HBM.
- Graph-capture safety is mandatory (this kernel overlays the live decode path): steady-state hot
path must be host-sync-free — no .item()/.cpu()/.synchronize(), no Python branch on a GPU scalar. Cache any weight prep (preshuffle/requant) once by weight.data_ptr(), never per call.
- Tune:
BLOCK_Msmall (decode),BLOCK_N/split_kover the KV loop,num_warps,kpack, fp32
accumulate. Keep the fp8 path fused (fold block-scale into the operand scale → one fp8 MFMA).
- Gate isolated vs the oracle; then let the e2e layer overlay it (bare core, capture-safe).
Knobs & pitfalls
- Decode M is tiny — wide tiles waste lanes; start
BLOCK_M=16/32. split_k>1reductions with smallBLOCK_Mcan go numerically wrong on this build — verify parity per
config, not just speed.
- Do NOT re-materialize bf16 weights for the absorbed proj across all layers (memory blow-up → forces
mem-fraction down → KV-cache starves → net e2e regression even if the kernel is faster).
Do-no-harm notes
- This is a decode-regime skill; do not apply the decode tiling to prefill MLA (different shape regime).
- If parity fails at any candidate config, drop that config — never trade correctness for speed.
Sources
- Recipe distilled from the MLA / DeepSeek case studies in `perf_knowledge/case_studies/by_model/
deepseek_mla_mi300x.md and deepseek_v3v4_attention.md`.
- STATUS: draft — needs on-box validation. Run `_contribute/validate_skill.py mla_tilelang_to_triton
--emit-plan then --record` with the kernel_workflow isolated A/B eval dir.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingperf_knowledge/expert_skills/skills/mla_tilelang_to_triton/skill.md
Popularity
- Repository stars
- 157
- Repository forks
- 42
- 7-day trend score
- 25
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/amd-agi/geak/mla-tilelang-to-triton)