Skip to content

[Triton/Gluon] [Perf] Cache gfx1250 Gluon MXFP4 preshuffle GEMM layouts - #6480

Merged
Boss2002n merged 1 commit into
mainfrom
qichu/gluon-fp4-preshuffle-layout-cache
Oct 13, 2026
Merged

Boss2002n merged 1 commit into
mainfrom
qichu/gluon-fp4-preshuffle-layout-cache

Conversation

@qichu-yun

@qichu-yun qichu-yun commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

On gfx1250, every gemm_afp4wfp4_preshuffle call (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_layouts builds every layout from scratch on each call; most of the time goes to get_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

  • Single MI455X GPU: host time per gemm_afp4wfp4_preshuffle call, averaged over 50 calls, before and after. Output compared bit-for-bit against layouts rebuilt on every call, for M = 2048, 300 and 1.
  • Kimi-K3 DP8EP8 in ATOM (2× MI455X): 8k in / 1k out at concurrency 32 (128 prompts), plus GSM8K 5-shot (1319 questions).
  • black and ruff==0.16.0 on the changed file.

Test Result

M, N, K host time before host time after output
2048, 3584, 7168 1110 µs 32.6 µs bit-identical
2048, 7168, 3584 1100 µs 29.2 µs bit-identical
1, 3584, 7168 1078 µs 30.8 µs bit-identical
Kimi-K3, 8k/1k, concurrency 32 before after
mean TTFT (ms) 6038 3239
mean TPOT (ms) 81.02 79.63
output throughput (tok/s) 362.8 380.5
GSM8K strict 0.9606 0.9583 (within noise)

Submission Checklist

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.
@qichu-yun
qichu-yun requested a review from a team October 13, 2026 12:43
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the gfx1201 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 6480 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

@github-actions github-actions Bot changed the title [Triton] [Perf] Cache gfx1250 Gluon MXFP4 preshuffle GEMM layouts [Triton/Gluon] [Perf] Cache gfx1250 Gluon MXFP4 preshuffle GEMM layouts Oct 13, 2026
@Boss2002n
Boss2002n requested a balanced review from Copilot October 13, 2026 13:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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.

@azaidy
azaidy self-requested a review October 13, 2026 17:05
@azaidy azaidy self-assigned this Oct 13, 2026

@azaidy azaidy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants