Skip to content

[fix] Key GLM-5 MXFP4 EP4 fused-MoE rows on topk 9 and add prefill rows - #6392

Merged
yzhou103 merged 3 commits into
ROCm:mainfrom
xiaofei-zheng:feature/xiaofei/glm5-fp4-ep4-fmoe-topk9
Oct 14, 2026
Merged

yzhou103 merged 3 commits into
ROCm:mainfrom
xiaofei-zheng:feature/xiaofei/glm5-fp4-ep4-fmoe-topk9

Conversation

@xiaofei-zheng

Copy link
Copy Markdown
Contributor

#5734 removed topk -= int(is_ep) from get_2stage_cfgs, so an EP4 rank with the shared expert fused looks up topk_ids.shape[1] = 9 (8 routed + 1 shared). The GLM-5 MXFP4 EP4 decode rows added in #5986 are keyed 65,8, so they never match on main and decode falls back to the heuristic pair, which writes BF16 and pays a second quant-sort. #5986's dispatch test passed because it calls get_2stage_cfgs(..., 65, 8, ...) directly.

  • Rekey the four decode rows (tuned and untuned) to 65,9.
  • Add rows for the 16384 and 32768 prefill tiers (runtime M 8193 and up).
  • The dispatch test uses topk 9 and covers the prefill tiers. It fails 8/8 against main's CSV and passes 8/8 with this change.

MI355X (gfx950, 256 CU), aiter main with and without this change: real fused_moe at the EP4 shape (E=257, 65 local experts via expert_mask, model_dim 6144, inter_dim 2048, per-1x32 MXFP4), CUDA graph over 8 layers with distinct weights, us per layer, mean of two ABAB pairs.

M main this PR
5 58.5 55.8 (-4.7%)
12 88.3 84.2 (-4.6%)
32 156.7 151.0 (-3.6%)
64 199.0 193.0 (-3.0%)
8193 926.7 853.3 (-7.9%)
16384 1654.5 1557.7 (-5.9%)
32768 3187.4 2938.3 (-7.8%)
65536 6347.2 5736.0 (-9.6%)

M = 1, 2, 4, 128 and 8192 have no row and are unchanged. Relative error against an fp32 dequant reference matches main at every M (M=12: 0.2080 vs 0.2076). test_moe_2stage.py --no-legacy restricted to the six rows passes its logits_diff check.

End to end, GLM-5.3 MXFP4 TP4/EP4 agentic replay on the SGLang 0.5.21 image (CONC 10, 1 h): P50 interactivity +2.3% [-0.3, +4.7] over stock, GSM8K 0.9750 for both.

Only GLM-5-family MXFP4 models with EP4 and fused shared experts on gfx950 reach these keys.

@xiaofei-zheng
xiaofei-zheng requested review from a team and a balanced review from Copilot October 11, 2026 03:49
@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: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 6392 --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.

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

Architecture-specific GPU correctness and performance require final gfx950 hardware validation.

0 open findings

What changed in this PR

Rekeys GLM-5 MXFP4 EP4 fused-MoE dispatch for shared-expert top-k 9 and adds gfx950 prefill configurations.

Changes:

  • Rekeys four decode tiers from top-k 8 to 9.
  • Adds 16K and 32K prefill tiers.
  • Expands dispatch tests across decode, prefill, and tier fallback.
File Description
op_tests/​test_moe_glm5_fp4_ep_dispatch.py Verifies expected kernels and block sizes across tiers.
aiter/​configs/​model_configs/​glm5_fp4_untuned_fmoe.csv Updates tuning inputs for top-k 9 and prefill.
aiter/​configs/​model_configs/​glm5_fp4_tuned_fmoe.csv Adds corrected gfx950 dispatch rows.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI balanced review requested due to automatic review settings October 12, 2026 03:36

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.

🟢 Approval recommended

The configuration keys match the runtime fused-shared-expert shape, and targeted tests cover all changed dispatch tiers.

0 open findings

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 13, 2026 06:13

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

Hardware-specific kernel correctness and performance require final human confirmation of the reported gfx950 validation.

0 open findings

🧠 Review effort: Balanced

@zufayu

zufayu commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

@aiter-bot review

@aiter-bot

Copy link
Copy Markdown

ROCm/aiter PR #6392 — [fix] Key GLM-5 MXFP4 EP4 fused-MoE rows on topk 9 and add prefill rows

Rekeys the GLM-5 MXFP4 EP4 fused-MoE config rows from topk 8 to topk 9 — the lookup key fused_moe has actually used since #5734 removed the is_ep decrement — and adds 16384/32768 prefill rows, so the tuned fp4-fused kernel pairs match again instead of falling back to the slower bf16-intermediate heuristic.

Review (advisory): ⚠️ NEEDS WORK
Validation (deterministic): NOT RUN — REVIEW_AUTO_VALIDATE=0 (auto-validation disabled), and this box has no torch env to run op_tests/test_moe_glm5_fp4_ep_dispatch.py manually; PR-head CI is green on both arches, including the mi35x standard-test shard where test_moe_2stage.py walks these CSV rows through its accuracy check
Perf (advisory): NOT RUN — target exposes no benchmark entry point (op_tests/test_moe_glm5_fp4_ep_dispatch.py is metadata-only); this gfx942 box with no torch could not run a manual measurement either

⚠️ [verified] The rekey makes these rows invisible to CI's tuned-op bench comparison — .github/scripts/compare_benchmark.py joins baseline vs current on every column except us and the kernel names, so the base (topk=8) and head (topk=9) rows can never match — and the shipped test target op_tests/test_moe_glm5_fp4_ep_dispatch.py asserts kernelName strings without launching or timing a kernel, so the -3%..-9.6% table is the only base-vs-head timing these rows have and a perf regression in them would ship green. Reviewer should ask for a test_moe_2stage.py bench run over the six rows on a gfx950 box so the numbers are reproducible off the author's machine.
📝 [verified] The rekeyed rows in aiter/configs/model_configs/glm5_fp4_tuned_fmoe.csv cover only padded M 8–64 and 16384/32768, so runtime M 65–8192 and 1/2/4 keep the heuristic bf16-intermediate pair — the PR's own covered tiers gain 3–9.6%, so mid-size prefill batches (e.g. a 2048-token chunk) leave a similar margin unmeasured. Reviewer should ask whether follow-up tuning rows for the 128–8192 tiers are planned.

@zufayu

zufayu commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Where that review came from — I ran the bot on your PR to show what it does. It is not an automatic hook; nothing reviews your PR unless somebody asks.

Any reviewer on the aiter allowlist can ask for one, on any PR including their own. The trigger is a comment containing the words below — shown quoted here, because quoted lines deliberately do not trigger it:

@aiter-bot review

  • Reviews the PR at its current head. Comment again after pushing fixes for a fresh pass; a repeat on the same commit is deduped.
  • One review runs at a time on one box, roughly 20 minutes. If work is ahead of you the bot replies with your place in the queue, and if the runner is down it says so rather than leaving you waiting for a review that will never start.
  • The card is advisory. It never blocks a merge, 🔴 included — it is there to be argued with.

Feedback on the review itself is welcome; it is how the rules get better.

@xiaofei-zheng

Copy link
Copy Markdown
Contributor Author

Thanks for the review. The per-layer numbers in the description come from the real EP4 fused_moe call (E=257 with expert_mask, 65 local experts), which test_moe_2stage.py and the tuned-op bench cannot reproduce because they route every token to local experts. The 128–8192 tiers keep the heuristic pair; this PR only fixes the #5986 keys and adds the measured prefill tiers.

@xiaofei-zheng

Copy link
Copy Markdown
Contributor Author

@yzhou103 I added the measured timings for the 16384 and 32768 rows as you suggested. CI is green and the branch merges cleanly. Could you please approve and merge when you have a moment? Thank you!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants