Repository navigation
[Triton/Gluon] [Perf] Cache gfx1250 Gluon MXFP4 preshuffle GEMM layouts - #6480
Conversation
get_gemm_afp4wfp4_preshuffle_layouts rebuilt every Gluon layout on each gemm_afp4wfp4_preshuffle call on gfx1250, ~1.1-1.8 ms of Python (mostly get_wmma_scale_layout) -- longer than the GEMM itself, so eager callers leave the GPU idle. The layouts depend only on (num_warps, BLOCK_M, BLOCK_N, BLOCK_K, num_ctas): build them once per config and return a copy of the cached dict. gemm_afp4wfp4_preshuffle host time drops to ~30 us/call; output is bit-identical to the uncached path.
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
There was a problem hiding this comment.
🔵 Needs a closer look
Reusing compiler layout objects across GPU launches requires final human validation despite no identified code defects.
0 open findings
What changed in this PR
Caches gfx1250 Gluon MXFP4 GEMM layouts to reduce repeated Python launch overhead.
Changes:
- Adds a memoized layout builder keyed by kernel configuration.
- Returns a shallow dictionary copy to prevent cache mutation.
| File | Description |
|---|---|
aiter/ops/triton/_gluon_kernels/gfx1250/gemm/basic/gemm_mxfp4.py |
Caches preshuffled GEMM layouts. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Motivation
On gfx1250, every
gemm_afp4wfp4_preshufflecall (Gluon path) spends ~1.1–1.8 ms of Python rebuilding its Gluon layouts. That is longer than the GEMM itself, so eager callers leave the GPU idle between launches. HIP-graph replay is not affected.Seen in Kimi-K3 serving on MI455X with
ATOM_USE_TRITON_GEMM=1. Its latent MoE MXFP4 projections make 184 such calls per forward. In a 2048-token prefill step, the GPU was busy for only ~200 ms of the ~580 ms step, and mean TTFT doubled.Technical Details
get_gemm_afp4wfp4_preshuffle_layoutsbuilds every layout from scratch on each call; most of the time goes toget_wmma_scale_layout. The result depends only on(num_warps, BLOCK_M, BLOCK_N, BLOCK_K, num_ctas).The layouts are now built once per config with
functools.cache. The public function returns a copy of the cached dict so callers cannot mutate it. Its only caller,aiter/ops/triton/gemm/basic/gemm_afp4wfp4.py, is unchanged.Test Plan
gemm_afp4wfp4_preshufflecall, averaged over 50 calls, before and after. Output compared bit-for-bit against layouts rebuilt on every call, for M = 2048, 300 and 1.blackandruff==0.16.0on the changed file.Test Result
Submission Checklist