Skip to content

[Config] [DSv4] DeepSeek-V4 EP8 a8w4 MXFP4 fused-MoE rows for gfx950 - #5821

Merged
zufayu merged 3 commits into
ROCm:mainfrom
heachary:heachary/dsv4/tune_moe_stage1
Oct 29, 2026
Merged

zufayu merged 3 commits into
ROCm:mainfrom
heachary:heachary/dsv4/tune_moe_stage1

Conversation

@heachary

@heachary heachary commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

DeepSeek-V4 EP8 (Mori) dispatches AITER's a8w4 MXFP4 fused-MoE operator with this gfx950 runtime signature:

  • model/intermediate dimensions: (7168, 3072)
  • experts/top-k: (49, 6)
  • BF16 output, FP8 (e4m3fn) activations, MXFP4 (float4_e2m1fn_x2) weights
  • QuantType.per_1x32, G1U1, doweight_stage1=0, SiLU

On main no tuned table carries this key, so every token bucket falls through to
AITER's heuristic FlyDSL fallback. The same table already covers E=48 and E=24
at (7168, 3072); the E=49 keys are disjoint from both.

What this adds

Six gfx950/cu256 rows in the existing DSV4 FP8-FP4 table, M = {512, 1024, 2048, 4096, 8192, 16384}:

  • block_m=64 at M=512, block_m=128 above
  • stage1 flydsl_moe1_afp8_wfp4_bf16_*, stage2 flydsl_moe2_layout_afp8_wfp4_bf16_*
  • two-stage throughout (run_1stage=0, ksplit=0)

All six were tuned with the standard fused-MoE tuner over the FlyDSL a8w4 stage1 and
stage2 families (248 candidates per shape). Both stages are tuned; every column is
tuner output, including us1/err1, us2/err2, us, tflops and bw. Only rows
improving the production operator by at least 3% in both verification runs were
retained — all six clear that bar, the weakest at +5.1%.

Validation

Per-bucket default-vs-tuned through the production fused_moe, decode-like routing,
two independent runs. "Default" is the heuristic fallback on main — verified from
the dispatch log, which emits using heuristic FlyDSL fallback for all six buckets
when the rows are absent and never emits it when they are present.

decode-like routing (router scores from torch.randn — uneven per-expert load)

M default r1 (us) default r2 (us) tuned r1 (us) tuned r2 (us) speedup r1 speedup r2 min gain kept
512 567.6 566.6 410.7 409.0 1.38x 1.39x +27.7% yes
1024 958.9 954.9 643.1 644.3 1.49x 1.48x +32.5% yes
2048 1127.4 1132.6 1024.0 1074.5 1.10x 1.05x +5.1% yes
4096 2093.6 2047.5 1841.7 1829.2 1.14x 1.12x +10.7% yes
8192 3739.9 3737.6 3270.9 3274.8 1.14x 1.14x +12.4% yes
16384 7272.7 7253.7 6369.7 6372.0 1.14x 1.14x +12.2% yes

prefill-like routing (balanced round-robin, AITER_MOE_EXPERT_BALANCE=1)

M default r1 (us) default r2 (us) tuned r1 (us) tuned r2 (us) speedup r1 speedup r2 min gain kept
512 496.5 499.2 337.5 333.1 1.47x 1.50x +32.0% yes
1024 887.9 890.5 487.6 489.7 1.82x 1.82x +45.0% yes
2048 1070.4 1058.9 955.5 945.9 1.12x 1.12x +10.7% yes
4096 1948.4 1990.5 1713.8 1724.7 1.14x 1.15x +12.0% yes
8192 3668.4 3745.5 3209.4 3196.6 1.14x 1.17x +12.5% yes
16384 7292.9 7309.4 6314.0 6304.6 1.16x 1.16x +13.4% yes

Speedup over the fallback at M=512/1024/2048/4096/8192/16384, mean of two runs:

  • decode-like routing: 1.38x / 1.49x / 1.08x / 1.13x / 1.14x / 1.14x
  • prefill-like routing: 1.49x / 1.82x / 1.12x / 1.15x / 1.16x / 1.16x

Routing definitions, since these rows are merged for both prefill and decode:
decode-like draws router scores from torch.randn, giving the uneven per-expert
token distribution typical of decode; prefill-like uses balanced round-robin
assignment (AITER_MOE_EXPERT_BALANCE=1), approximating a large uniform prefill
chunk. Both were measured at every bucket, and every bucket is positive in both
regimes and both runs, so no row is prefill-regressing.

Correctness, same runs, against the harness's torch reference (threshold 1e-2):
logits_diff is 3.98e-4 to 4.08e-4 for the fallback and 4.11e-4 to 4.17e-4 for the
tuned rows, at every bucket in both routings. All rows carry err1=0.0% and
err2=0.0% from the tuner.

  • test_config_shape_collision.py and test_csv_validation.py: 46 passed, 50
    subtests passed. All six rows survive the AITER_CONFIG_FMOE merge.
  • No other fused-MoE table on main carries the gfx950 / (7168, 3072) / E=49, topk=6 dispatch key.

Hardware: MI355X (gfx950, 256 CUs). Latency was measured on a single pinned GPU
with the other seven idle; the tuner sweep used all eight.
Image: lmsysorg/sglang-rocm:v0.5.22-rocm724-mi35x-20261025 (ROCm 7.2.4,
torch 2.11.0+rocm7.2).
Tuning base: upstream ROCm/aiter main at 905967361.

@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; main branch always runs both MI35X and MI300X
multigpu 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: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
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 5821 --add-label <label>

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 opt this PR out.

@heachary
heachary marked this pull request as ready for review September 25, 2026 16:54
@heachary
heachary requested a review from a team September 25, 2026 16:54
@zufayu
zufayu self-requested a review September 26, 2026 00:19
@zufayu zufayu self-assigned this Sep 26, 2026
@valarLip

Copy link
Copy Markdown
Collaborator

let's consider other ways

Under --ep-size 8 with shared-expert fusion aiter resolves expert=49
(48 local routed experts plus this rank's fused shared expert), a shape
the shipped DSv4 table carries no rows for, so it falls back to the
heuristic. Serving deployments have been supplying these six rows
out-of-band; carrying them here lets the tuning travel with aiter.

Measured on MI355X at 8k/1k, concurrency 128, TP8/DP8/EP8 with DSpark,
against the same table with these rows removed: +2.25% output token
throughput and -2.55% mean TPOT.

Co-authored-by: Cursor <[email protected]>
@heachary
heachary force-pushed the heachary/dsv4/tune_moe_stage1 branch from 8f3c1d6 to 344d4d9 Compare September 30, 2026 10:03
@github-actions github-actions Bot changed the title [DSv4] Tuned decode moe kernels for mori-EP backend- #41119 [Config] [DSv4] Tuned decode moe kernels for mori-EP backend- #41119 Sep 30, 2026
@heachary

Copy link
Copy Markdown
Contributor Author

let's consider other ways

@valarLip i checked how much the prefill tokens overlap with decode and i think its a very small % of the time this happens in the agent-x runs (for smaller chunks), but for most of the time when we run at chunk-size 8192 prefill should not look up the solutions that we add for decode and shouldnt require separate tuning tables.

I have now removed the logic we had previously to allow for separate prefill and decode tuning tables. This is the A/B testing at fixed length (8k1k, conc-128) which still shows the gains:

Metric Unit Without tuning With tuning Delta
Output token throughput tok/s 2959.81 3026.50 +2.25% ✅
Total token throughput tok/s 26638.33 27238.51 +2.25% ✅
Request throughput req/s 2.89 2.96 +2.25% ✅
Benchmark duration s 442.84 433.08 -2.20% ✅
Mean TTFT ms 3389.84 3311.73 -2.30% ✅
Median TTFT ms 2473.92 1598.75 -35.38% ✅
Mean TPOT ms 39.50 38.49 -2.55% ✅
Median TPOT ms 41.15 39.92 -3.00% ✅
P99 TPOT ms 42.29 41.79 -1.20% ✅
Mean ITL ms 2755.87 2744.73 -0.40%
Mean E2EL ms 43793.43 42683.67 -2.53% ✅

@zufayu

zufayu commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Since the regime approach was intentionally removed after the earlier review, please validate the replacement as a default-table tune. These rows are merged for both prefill and decode; for example, prefill with M=8192, H=7168, I=3072, E=49, topk=6 exactly matches the new 8192 row.

The referenced #5500/#5953 established a stronger bar: compare every bucket against the current default, reproduce the result across two runs, keep only stable improvements, and drop marginal or regressing rows. Here the six rows contain only tuned us1/err1; there is no default baseline, us2/err2/us are blank, and no balanced-prefill measurements or exact expert=49 regression test are provided.

Please provide per-bucket default-vs-tuned correctness and latency for both decode-like and prefill-like routing, keep only consistently positive rows, add an exact lookup/correctness test, and update the stale PR description and linked SGLang contract. Please also rebase and run the SGLang downstream CI.

@github-actions

Copy link
Copy Markdown
Contributor

No activity for 15 days, so this is now labelled stale. A push or a comment clears it; keep-open exempts it. Nothing is closed automatically.

@github-actions github-actions Bot added the stale The PR hasn't been updated in 2 weeks label Oct 26, 2026
heachary and others added 2 commits October 26, 2026 06:09
…e_stage1

Co-authored-by: Cursor <[email protected]>

# Conflicts:
#	aiter/configs/model_configs/dsv4_fp8fp4_tuned_fmoe.csv
Re-tuned the six expert=49 (7168x3072, topk=6) rows with the standard fused-MoE
tuner on main, replacing the stage1-only rows. Every column is now tuner output:
us1/err1, us2/err2, us, tflops and bw.

Stage2 moves from the plain flydsl_moe2_afp8_wfp4_bf16_* family to
flydsl_moe2_layout_*, which the tuner selects at every bucket.

Co-authored-by: Cursor <[email protected]>
@heachary heachary changed the title [Config] [DSv4] Tuned decode moe kernels for mori-EP backend- #41119 [Config] [DSv4] DeepSeek-V4 EP8 a8w4 MXFP4 fused-MoE rows for gfx950 Oct 26, 2026
@heachary

Copy link
Copy Markdown
Contributor Author

Since the regime approach was intentionally removed after the earlier review, please validate the replacement as a default-table tune. These rows are merged for both prefill and decode; for example, prefill with M=8192, H=7168, I=3072, E=49, topk=6 exactly matches the new 8192 row.

The referenced #5500/#5953 established a stronger bar: compare every bucket against the current default, reproduce the result across two runs, keep only stable improvements, and drop marginal or regressing rows. Here the six rows contain only tuned us1/err1; there is no default baseline, us2/err2/us are blank, and no balanced-prefill measurements or exact expert=49 regression test are provided.

Please provide per-bucket default-vs-tuned correctness and latency for both decode-like and prefill-like routing, keep only consistently positive rows, add an exact lookup/correctness test, and update the stale PR description and linked SGLang contract. Please also rebase and run the SGLang downstream CI.

@zufayu : I have rerun the tuner to fill in the missing details in the tuned csv. Rerun the microbench for the updated solutions and remade the results table in the format you requested. I have updated the stale PR description as well + pasted the updated microbench results there. Can you please take a look again?

@github-actions github-actions Bot removed the stale The PR hasn't been updated in 2 weeks label Oct 27, 2026
@zufayu
zufayu merged commit d32530d into ROCm:main Oct 29, 2026
90 of 92 checks passed
solinzby1 pushed a commit that referenced this pull request Nov 2, 2026
…5821)

* [Config] Add DSV4 EP8 stage1 tuned fmoe rows for gfx950

Under --ep-size 8 with shared-expert fusion aiter resolves expert=49
(48 local routed experts plus this rank's fused shared expert), a shape
the shipped DSv4 table carries no rows for, so it falls back to the
heuristic. Serving deployments have been supplying these six rows
out-of-band; carrying them here lets the tuning travel with aiter.

Measured on MI355X at 8k/1k, concurrency 128, TP8/DP8/EP8 with DSpark,
against the same table with these rows removed: +2.25% output token
throughput and -2.55% mean TPOT.

Co-authored-by: Cursor <[email protected]>

* [Config] Retune DSV4 EP8 fmoe rows on gfx950: full stage1+stage2 data

Re-tuned the six expert=49 (7168x3072, topk=6) rows with the standard fused-MoE
tuner on main, replacing the stage1-only rows. Every column is now tuner output:
us1/err1, us2/err2, us, tflops and bw.

Stage2 moves from the plain flydsl_moe2_afp8_wfp4_bf16_* family to
flydsl_moe2_layout_*, which the tuner selects at every bucket.

Co-authored-by: Cursor <[email protected]>

---------

Co-authored-by: Cursor <[email protected]>
shantipriya-amd pushed a commit to shantipriya-amd/aiter that referenced this pull request Nov 18, 2026
…OCm#5821)

* [Config] Add DSV4 EP8 stage1 tuned fmoe rows for gfx950

Under --ep-size 8 with shared-expert fusion aiter resolves expert=49
(48 local routed experts plus this rank's fused shared expert), a shape
the shipped DSv4 table carries no rows for, so it falls back to the
heuristic. Serving deployments have been supplying these six rows
out-of-band; carrying them here lets the tuning travel with aiter.

Measured on MI355X at 8k/1k, concurrency 128, TP8/DP8/EP8 with DSpark,
against the same table with these rows removed: +2.25% output token
throughput and -2.55% mean TPOT.

Co-authored-by: Cursor <[email protected]>

* [Config] Retune DSV4 EP8 fmoe rows on gfx950: full stage1+stage2 data

Re-tuned the six expert=49 (7168x3072, topk=6) rows with the standard fused-MoE
tuner on main, replacing the stage1-only rows. Every column is now tuner output:
us1/err1, us2/err2, us, tflops and bw.

Stage2 moves from the plain flydsl_moe2_afp8_wfp4_bf16_* family to
flydsl_moe2_layout_*, which the tuner selects at every bucket.

Co-authored-by: Cursor <[email protected]>

---------

Co-authored-by: Cursor <[email protected]>
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