Skip to content

[Config] [DSv4.1] gfx950 FP8 fused_moe: retune TP4 prefill rows (token 4096-16384) - #7656

Merged
zufayu merged 3 commits into
ROCm:mainfrom
cpersson-amd:dsv41-tp4-prefill-moe-rows
Nov 12, 2026
Merged

zufayu merged 3 commits into
ROCm:mainfrom
cpersson-amd:dsv41-tp4-prefill-moe-rows

Conversation

@cpersson-amd

@cpersson-amd cpersson-amd commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Replaces three rows of aiter/configs/model_configs/dsv41_fp8_tuned_fmoe.csv (DeepSeek-V4.1-Flash target MoE, TP4: E=384, topk=6, inter_dim=640, FP8 activations, FP4 weights) for the 4096, 8192 and 16384 token buckets. Each new row reuses a bm64 kernel pair that is already in this table. On MI355X this gives 2-3% higher prefill throughput when serving DeepSeek-V4.1-Flash TP4, and the output is bit-identical to the current rows.

Motivation

The rows from #6125 for these buckets were picked by the v2 (FlyDSL mxfp4) tuner, which builds its routing with balanced_score: every expert gets exactly token * topk / E rows. At a power-of-two token count that is itself a block_m candidate (8192 * 6 / 384 = 128), so the bm128 kernels run with no padding tile and win. Real routing never lines up like that. I replayed topk_ids / topk_weights dumped from a live vLLM server through the op. Real routing is within about 3% of torch.randn routing, even for layers where one expert takes most of the tokens. Under real routing the bm128 picks are 10-16% slower than bm64 pairs already in the table. The tuner itself is fixed in a separate PR.

Changes

token before (block_m, stage 1 / stage 2) after
4096 64, t64x256x256_w2_gui_fp8 / layout_t64x256x128_reduce_nt_sbm64 64, t64x128x256_w2_bnt0_gui_fp8 / layout_t64x256x128_reduce_sbm64 (the pair from the E=128 row at token 8192)
8192 128, t128x128x256_w2_gui_fp8 / layout_t64x256x128_reduce_sbm128 64, t64x128x256_w4_bnt0_gui_xcd4_fp8 / layout_t64x256x128_reduce_sbm64 (the pair from the E=384 row at token 32768)
16384 128, t128x256x256_w2_bnt0_gui_fp8 / layout_t64x256x128_reduce_sbm128 same as 8192
  • The 32768 row names stage 1 t64x256x256_w4_bnt0_gui_xcd4_fp8, but at inter_dim=640 tile_n=256 is forced down to 128 ("tile=256 is NOT usable/tunable"). The new rows name the tile that actually runs, t64x128x256_w4_bnt0_gui_xcd4_fp8, which compiles to the same kernel symbol (mfma_moe1_silu_mul_afp8_wfp4_fp8_t64x128x256_pm1_fp8q_sort_async_gui_xcd4_v2out_v33).
  • As with the hand-picked rows in [HIP] gfx950 A8W4 fused_moe configs for DSv4.1 TP-sharded experts #6125, us1 / us2 / err are left empty and us is the measured op time under real routing.
  • The token 2048 row and all E=128 (draft) rows are unchanged.

Performance

Op time, fused_moe 2-stage (quant+sort, stage 1, stage 2, reduction). MI355X, one GPU, real DeepSeek-V4.1-Flash layer activations and routing. Median over three dumped routings (with three repeats for the 4096 bucket), measured after a 512 MiB L2/MALL flush.

Hardware Workload/configuration Before After Change
MI355X token 4096 (bucket 4096) 789 us 709 us -10.1%
MI355X token 2100 / 2600 / 3155 (bucket 4096) 540 / 598 / 665 us 505 / 587 / 611 us -6.5% / -1.9% / -8.1%
MI355X token 8192 (bucket 8192) 1204 us 1026 us -14.8%
MI355X token 4200 / 5000 / 6500 (bucket 8192) 820 / 909 / 1039 us 722 / 811 / 922 us -11.9% / -10.8% / -11.2%
MI355X token 16384 (bucket 16384) 2027 us 1706 us -15.8%
MI355X token 8400 / 10000 / 12500 (bucket 16384) 1206 / 1379 / 1598 us 1077 / 1210 / 1452 us -10.7% / -12.2% / -9.2%

End to end, vLLM serving DeepSeek-V4.1-Flash TP4 on 4x MI355X. The flags are --block-size 64 --max-num-batched-tokens 16384 --monokernel --moe-backend aiter --kv-cache-dtype fp8, DSpark k=5 speculative decoding, VLLM_ROCM_USE_AITER_MOE=1, and vllm bench serve random dataset with range ratio 0.8. Total token throughput is the mean of four paired runs: both GPU sets, both arm orders.

Hardware Workload/configuration Before After Change
4x MI355X 8k in / 1 out, c64 (prefill only) 101.7k tok/s 104.1k tok/s +2.3% (+1.4 to +3.1 in each run)
4x MI355X 60k in / 1 out, c16 (prefill only) 101.2k tok/s 103.2k tok/s +2.0% (+1.3 to +3.0)

Decode TPOT (8k/1k, 60k/600) is unchanged within run-to-run noise. Those buckets don't use these rows.

Testing

  • Unit tests added or updated
  • Performance benchmarks run
  • Tested on MI250X
  • Tested on MI300X

The table only applies to gfx950. Each new pair was checked against the current row on the same inputs: relative error is 0, i.e. bit-identical output, since both old and new rows use the reduce stage-2 variant. During serving, the [fused_moe] using 2stage log lines show the new kernels selected for 4096, 8192 and 16384.

Accuracy on 4x MI355X, DeepSeek-V4.1-Flash TP4 (--moe-backend aiter --max-num-batched-tokens 16384, lm_eval 0.4.13). Before is this branch with AITER_CONFIG_FMOE pointing at main's dsv41_fp8_tuned_fmoe.csv, after is this branch:

Task Before After
niah_single_2, 32k (500 samples) 1.000 1.000
niah_single_2, 64k (500 samples) 1.000 1.000
gsm8k 5-shot, thinking, flexible-extract 0.9219 ± 0.0074 0.9227 ± 0.0074
gsm8k 5-shot, thinking, strict-match 0.9212 ± 0.0074 0.9234 ± 0.0073

Per sample, gsm8k has 39 questions only before got right and 40 only after got right. That is run-to-run serving nondeterminism, not a bias.

Documentation

  • No documentation change is needed: tuned-config rows only.

Dependencies

  • No new third-party dependencies added

Breaking Changes

None.

PR Self-Review

Reviewed revision

cd6d84a

Behavior and intent

The DSv4.1 FP8 TP4 target MoE at token buckets 4096, 8192 and 16384 now dispatches bm64 kernel pairs instead of the current bm64 / bm128 picks. The current picks were tuned under perfectly balanced routing, which over-rates block_m equal to token * topk / E.

Validation and unverified scope

  • Routing was captured with an env-guarded hook in vLLM's rocm_aiter_fused_moe (8k random prompts plus four natural-text prompts) and replayed through fused_moe with AITER_CONFIG_FMOE set to a one-row CSV per candidate. Results are in the op-time table above; each new pair's output was compared with the current row on the same inputs (relative error 0, bit-identical).
  • The end-to-end A/B pointed AITER_CONFIG_FMOE at the default merge list with this file swapped in (vllm bench serve, flags above); the [fused_moe] using 2stage log lines show the new kernels selected for 4096, 8192 and 16384. Accuracy: lm_eval gsm8k 5-shot and niah_single_2 32k/64k, table above.
  • Unverified:
    • The E=128 draft rows: no real draft routing was captured, and they are unchanged.
    • The token 2048 row: no candidate beat it across 1100-2048 tokens, and it is unchanged.
    • TP8 / other inter_dim tables.
    • Token 32768.

PR-specific question

Exactly three lookup keys consume the change, all in aiter/configs/model_configs/dsv41_fp8_tuned_fmoe.csv. The key columns are gfx,cu_num,token,model_dim,inter_dim,expert,topk,act_type,dtype,q_dtype_a,q_dtype_w,q_type,use_g1u1,doweight_stage1, and the changed rows are:

  • gfx950,256,{4096,8192,16384},5120,640,384,6,ActivationType.Silu,torch.bfloat16,torch.float8_e4m3fn,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0

That is DeepSeek-V4.1-Flash TP4 target MoE (E=384, topk=6, inter_dim=640), FP8 activations with MXFP4 weights, on gfx950 with 256 CUs, for the 4096, 8192 and 16384 token buckets.

Evidence that unrelated shapes keep their selection:

  • The diff is 3 lines removed and 3 added in this one CSV; the other 74 rows (token 2048 and 32768, and every E=128 draft row) are byte-identical.
  • The only other tuned fmoe CSV with rows at the same token / model_dim / inter_dim / E / topk is dsv41_fp4_tuned_fmoe.csv, whose rows have q_dtype_a=torch.float4_e2m1fn_x2, a different key, and it is not modified.

Changed op tests

None. No op_tests/ file changes; this PR only edits tuned-config rows.

The shipped rows for tokens 4096-16384 were picked under the v2 tuner's
balanced routing, where each expert gets exactly token*topk/E rows and a
block_m of that size has no padding tile. With real routing (dumped from a
DSv4.1 Flash TP4 server) those rows are 6-16% slower than bm64 pairs
already in this table. Op time, median over real routings:
  4096  (draft 8192 pair)    789 -> 709 us
  8192  (target 32768 pair) 1204 -> 1026 us
  16384 (target 32768 pair) 2027 -> 1706 us
and 2-12% faster across each bucket (M 2100-12500). Output is
bit-identical to the current rows.
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

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

Extended tests (opt-in via labels):

Label Tests
ci:mi300x Run Aiter standard tests on MI300X in PRs; main branch always runs them
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 Radeon R9700 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 7656 --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.

Reviews:
A reviewer is usually assigned within one working day after the PR is ready for review (see Code Review Process). If nobody has responded for about a week, mention the area contact listed in CONTACTS.md. Want to help review? See REVIEWERS.md.

@aiter-bot

aiter-bot commented Nov 9, 2026 •

Copy link
Copy Markdown

READY FOR HUMAN REVIEW

PR Self-Review

Revision cd6d84afd2c0 · mode shadow

Author self-review accepted. Readiness report:

Author answers

  • PASS — current-SHA answers are present and structurally specific
Show the author's self-review answers

Behavior and intent

The DSv4.1 FP8 TP4 target MoE at token buckets 4096, 8192 and 16384 now dispatches bm64 kernel pairs instead of the current bm64 / bm128 picks. The current picks were tuned under perfectly balanced routing, which over-rates block\_m equal to `token * topk / E`.

Validation and unverified scope

* Routing was captured with an env-guarded hook in vLLM's `rocm_aiter_fused_moe` (8k random prompts plus four natural-text prompts) and replayed through `fused_moe` with `AITER_CONFIG_FMOE` set to a one-row CSV per candidate. Results are in the op-time table above; each new pair's output was compared with the current row on the same inputs (relative error 0, bit-identical).
* The end-to-end A/B pointed `AITER_CONFIG_FMOE` at the default merge list with this file swapped in (`vllm bench serve`, flags above); the `[fused_moe] using 2stage` log lines show the new kernels selected for 4096, 8192 and 16384. Accuracy: `lm_eval` gsm8k 5-shot and `niah_single_2` 32k/64k, table above.
* Unverified:
  * The E=128 draft rows: no real draft routing was captured, and they are unchanged.
  * The token 2048 row: no candidate beat it across 1100-2048 tokens, and it is unchanged.
  * TP8 / other `inter_dim` tables.
  * Token 32768.

PR-specific question

Exactly three lookup keys consume the change, all in `aiter/configs/model_configs/dsv41_fp8_tuned_fmoe.csv`. The key columns are `gfx,cu_num,token,model_dim,inter_dim,expert,topk,act_type,dtype,q_dtype_a,q_dtype_w,q_type,use_g1u1,doweight_stage1`, and the changed rows are:

* `gfx950,256,{4096,8192,16384},5120,640,384,6,ActivationType.Silu,torch.bfloat16,torch.float8_e4m3fn,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0`

That is DeepSeek-V4.1-Flash TP4 target MoE (E=384, topk=6, inter\_dim=640), FP8 activations with MXFP4 weights, on gfx950 with 256 CUs, for the 4096, 8192 and 16384 token buckets.

Evidence that unrelated shapes keep their selection:

* The diff is 3 lines removed and 3 added in this one CSV; the other 74 rows (token 2048 and 32768, and every E=128 draft row) are byte-identical.
* The only other tuned fmoe CSV with rows at the same token / model_dim / inter_dim / E / topk is `dsv41_fp4_tuned_fmoe.csv`, whose rows have `q_dtype_a=torch.float4_e2m1fn_x2`, a different key, and it is not modified.

Changed op tests

None. No `op_tests/` file changes; this PR only edits tuned-config rows.

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply
  • ADVISORY — Copilot did not review the current head SHA

Code and op-test hygiene

  • PASS — no committed artifact or conflict marker detected

Required CI

  • PASS — Black: passed
  • PASS — Ruff: passed
  • PASS — Repository dependency: passed
  • PASS — Aiter Test Gate: passed

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

@zufayu
zufayu self-requested a review November 10, 2026 01:23
@zufayu zufayu self-assigned this Nov 10, 2026
@github-actions github-actions Bot changed the title [DSv4.1] gfx950 FP8 fused_moe: retune TP4 prefill rows (token 4096-16384) [Config] [DSv4.1] gfx950 FP8 fused_moe: retune TP4 prefill rows (token 4096-16384) Nov 11, 2026
@zufayu
zufayu merged commit 0d23938 into ROCm:main Nov 12, 2026
vpietila-amd pushed a commit that referenced this pull request Nov 12, 2026
)

The shipped rows for tokens 4096-16384 were picked under the v2 tuner's
balanced routing, where each expert gets exactly token*topk/E rows and a
block_m of that size has no padding tile. With real routing (dumped from a
DSv4.1 Flash TP4 server) those rows are 6-16% slower than bm64 pairs
already in this table. Op time, median over real routings:
  4096  (draft 8192 pair)    789 -> 709 us
  8192  (target 32768 pair) 1204 -> 1026 us
  16384 (target 32768 pair) 2027 -> 1706 us
and 2-12% faster across each bucket (M 2100-12500). Output is
bit-identical to the current rows.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants