Skip to content

[Config] [Perf] Add gfx950 DSV4.1 Flash TP4 fused-shared-expert a8w4 FMoE tuning - #6433

Open
kevin-mii wants to merge 4 commits into
ROCm:mainfrom
kevin-mii:dsv41-fused-shared-tp4-a8w4-fmoe
Open

kevin-mii wants to merge 4 commits into
ROCm:mainfrom
kevin-mii:dsv41-fused-shared-tp4-a8w4-fmoe

Conversation

@kevin-mii

@kevin-mii kevin-mii commented Oct 12, 2026 •

Copy link
Copy Markdown

Summary

Add six gfx950 TP4 A8W4 tuning rows for DeepSeek-V4.1-Flash with the shared expert fused into routed MoE: target 385 experts/top-7 at M=1,128,256 and draft 129 experts/top-4 at M=1,2,32. Each has model_dim=5120, inter_dim=640 (576 plus 64 zero-padded lanes), interleaved gate/up and SiLU limit 10. Matching untuned shapes are included.

Current SGLang explicitly uses FP8 activations for V4.1 on gfx950, so these remain applicable after the BF16-bound workaround was removed. These are different shapes from the unfused 384/6 and 128/3 rows already upstream.

Revalidation against current main

Base: 1dd826c42. Device: otherwise idle MI355X VF, gfx950 / 256 CUs, ROCm 10 / PyTorch 2.11 / FlyDSL 0.4.

Use the production fused_moe dispatcher with explicit FP8 activations. The baseline is the merged main config: remove only the PR's new keys, preserving all other upstream rows and the heuristic. Identical tensors are used for both arms. Capture ten whole-MoE calls per CUDA graph; measure 31 replays per arm in each of six alternating rounds, excluding warm-up/JIT. Report the median of round medians. Repeat with seeds 42 and 123.

Weights are synthetic. Routing always includes the last shared expert: top-6 among 384 routed experts plus shared, or top-3 among 128 plus shared. This matters: the earlier generic synthetic test sampled all top-k experts randomly, which did not reproduce this PR's shared-expert workload.

Experts/top-k M Seed 42 main → PR (µs) Seed 123 main → PR (µs) Latency reduction
385/7 1 28.95 → 28.61 29.20 → 28.40 1.2% / 2.8%
385/7 128 320.30 → 312.79 314.57 → 309.08 2.3% / 1.7%
385/7 256 367.32 → 356.95 364.54 → 353.02 2.8% / 3.2%
129/4 1 28.39 → 26.69 28.25 → 26.52 6.0% / 6.1%
129/4 2 29.64 → 26.88 29.32 → 27.37 9.3% / 6.7%
129/4 32 93.95 → 85.27 91.89 → 81.63 9.2% / 11.2%

Dropped target M=32 (1.0% gain in one seed, tied in the other) and M=64 (about 3.9% slower in both). The six retained choices are unchanged. CSV us values remain historical measurements; per-stage timing/error fields remain blank where no consistent stage measurements exist.

Correctness and limits

  • All eight pre-trim shapes passed the repository's strict accuracy criterion in both shared-routing seeds, including 64 zero-padded lanes and no biases; no NaNs. Main/PR output cosine differences also passed <1e-3.
  • The elementwise 1% comparison reports differences; the test accepts these through its cosine criterion. This does not claim bitwise equality.
  • Runtime config merge/collision passed. All six retained rows select the expected kernel pairs; the two removed shapes select exactly main's heuristic again.
  • These results justify the retained operator choices. They do not establish current production-checkpoint or end-to-end serving gains; those remain a separate validation step.

DeepSeek-V4.1-Flash served with the shared expert fused into the MoE (SGLang
--enforce-shared-experts-fusion) runs 385 experts / top-7 (target) and 129 / top-4
(DSpark draft) at TP4 inter 640, which had no tuned rows and fell back to the heuristic.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kevin-mii
kevin-mii requested review from a team and a balanced review from Copilot October 12, 2026 11:15

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@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 6433 --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 [Perf] Add gfx950 DSV4.1 Flash TP4 fused-shared-expert a8w4 FMoE tuning [Config] [Perf] Add gfx950 DSV4.1 Flash TP4 fused-shared-expert a8w4 FMoE tuning Oct 12, 2026
@zufayu
zufayu requested a review from yzhou103 October 13, 2026 01:40
gfx950,256,16384,5120,1152,384,6,ActivationType.Silu,torch.bfloat16,torch.float8_e4m3fn,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0,128,0,1280.4706,flydsl_moe1_afp8_wfp4_bf16_t128x128x256_w3_bnt0_gui_fp8,0.0%,877.0679,flydsl_moe2_layout_afp8_wfp4_bf16_t64x256x128_atomic_sbm128,0.0%,2157.5385,0,0,0,1612.45,3265.96,0
gfx950,256,32768,5120,1152,384,6,ActivationType.Silu,torch.bfloat16,torch.float8_e4m3fn,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0,128,0,2459.5951,flydsl_moe1_afp8_wfp4_bf16_t128x128x256_w3_bnt0_gui_fp8,0.0%,1626.4346,flydsl_moe2_layout_afp8_wfp4_bf16_t64x256x128_atomic_sbm128,0.0%,4086.0297,0,0,0,1702.84,1786.11,0
gfx950,256,1,5120,640,385,7,ActivationType.Silu,torch.bfloat16,torch.float8_e4m3fn,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0,32,0,18.6867,flydsl_moe1_afp8_wfp4_bf16_t32x64x256_w4_gui_kw4,0.0%,10.992,flydsl_moe2_afp8_wfp4_bf16_t32x128x128_reduce_bnt2,0.0%,35.1,0,0,0,0,0,0
gfx950,256,32,5120,640,385,7,ActivationType.Silu,torch.bfloat16,torch.float8_e4m3fn,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0,16,0,103.7206,flydsl_moe1_afp8_wfp4_bf16_t16x128x256_w4_gui,0.0%,57.0628,flydsl_moe2_afp8_wfp4_bf16_t16x128x128_reduce_persist,0.0%,135.5,0,0,0,0,0,0

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.

us1(57)+us2(135)> us(135.5)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed the inconsistent metadata in 4877cea (current head 3d91219). The three rows with contradictory stage measurements now leave us1/us2/err1/err2 blank, like the other whole-operator-measured rows. us remains the historical whole-MoE measurement; it is not the sum of those removed stage samples. I also normalized two stage-1 names to t16x128x256, which is the tile the runtime already selected for inter_dim=640.

Current-main validation on gfx950 / ROCm 10 / PyTorch 2.11 / FlyDSL 0.4:

  • Configuration merge/collision test passed.
  • All eight shapes passed the repository’s strict accuracy gate using synthetic weights, 64 zero-padded intermediate lanes (576→640), no bias, and SiLU limit 10. Cosine differences were 3.36e-6–6.25e-6; the elementwise 1% check did report differences, so this is the suite’s cosine-based acceptance rather than elementwise equality.

The fresh synthetic timing comparison does not reproduce the old gains consistently: three target buckets improved by roughly 1–4%, while target M=128/256 and draft M=32 were roughly 3–4% slower than today’s heuristic. Other draft buckets were essentially tied. These are short operator measurements, not the original checkpoint workload. The rows are still missing upstream, but they need a controlled retune with the production checkpoint before merge. I am keeping this open and leaving the review thread for your reassessment; the metadata correction should not be read as a new performance claim.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Follow-up after a current-main comparison: pushed b32062ec9, removing target M=32 and M=64 and leaving six rows.

The routing pattern matters. A generic random top-k test did not consistently reproduce the original gains, but this PR targets top-6 routed experts plus an always-active shared expert (or top-3 plus shared for the draft). I repeated that routing pattern with synthetic weights, 64 zero-padded lanes, explicit FP8 activations and SiLU limit 10, on current main 1dd826c42 / gfx950 MI355X VF. Two seeds, six alternating timing rounds each, 31 graph replays per arm, ten whole-MoE calls per replay.

Target M=1/128/256 improved 1.2–3.2%; draft M=1/2/32 improved 6.0–11.2%. Target M=32 was inconclusive across seeds, and M=64 was about 3.9% slower in both, so those rows are removed. The body has the per-shape timings and retains the distinction between whole-op and per-stage measurements.

All shapes passed the repository's strict numerical criterion without NaNs in both shared-routing seeds. Final config merge/collision and retained-kernel dispatch checks passed; removed target shapes use main's heuristic again. These are operator results, not a current production-checkpoint/end-to-end claim. Human review and current-head CI remain outstanding.

Copilot AI balanced review requested due to automatic review settings October 28, 2026 00:03

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

Copilot AI balanced review requested due to automatic review settings October 28, 2026 00:57

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@aiter-bot

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision b32062ec903f · mode shadow

Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision.

Questions to answer in the PR description

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. Which exact workload keys consume these configuration changes, and what evidence shows that unrelated shapes keep their previous selection?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — missing ### Reviewed revision in the PR description
  • FAIL — missing ### Behavior and intent in the PR description
  • FAIL — missing ### Validation and unverified scope in the PR description
  • FAIL — missing ### PR-specific question in the PR description
  • FAIL — missing ### Changed op tests in the PR description
  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA
  • FAIL — Behavior and intent has no substantive answer
  • FAIL — Validation and unverified scope has no substantive answer
  • FAIL — PR-specific question has no substantive answer

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

@amd-pedghazi

Copy link
Copy Markdown
Contributor

Thanks for these rows. Our draft #6363 adds rows for the same DeepSeek-V4.1 MoE setting, and both PRs add an M=256 row, so they will conflict in dsv41_fp8_tuned_fmoe.csv. Our rows gave no end-to-end gain in our serving tests, so I'm happy to close #6363 in favour of yours, or to merge both sets into one PR if you prefer.

@yzhou103

Copy link
Copy Markdown
Contributor

Hi, Could we address the padding issue before enabling these three tile_n=64 configurations (E385/top7/M1 and E129/top4/M1,2)?

I ran the original base (1dd826c) and PR head (b32062e) back-to-back on the same gfx950/CU256 GPU, using the public fused_moe entry and each revision’s natural configuration selection—no tile overrides.

With finite inputs, zero-padded weights, and the stage1 output workspace pre-filled with Inf to expose uninitialized reads:

Shape Base final output Head final output
E385 / top7 / M1 No NaN/Inf 5120/5120 values are NaN
E129 / top4 / M1 No NaN/Inf 5120/5120 values are NaN
E129 / top4 / M2 No NaN/Inf 10240/10240 values are NaN

For inter_dim=640 and intermediate_pad=64, the new stage1 configurations write only 19 × 32 = 608 columns. The remaining a2[..., 608:640] retains the workspace contents, but quantization and stage2 still consume those columns. The resulting NaNs reach the final [M, 5120] tensor returned by fused_moe, without an exception.

The base selects tile_n=128 / k_wave=1 and overwrites the full consumed width. On head, clearing only a2[..., 608:640] before quantization restores results bitwise identical to the zero-initialized control. Since the two source trees differ only in these CSV files, the new tuning rows expose an existing kernel padding bug.

Please fix the GUI grid calculation or initialize the consumed padding and add a regression test. Alternatively, remove or retune these three rows before merging.

Tested with PyTorch 2.10 / ROCm 7.2.4 / FlyDSL 0.4.0. This is an Inf-poison reproduction, not a claim that every ordinary invocation fails; NaN-only poisoning did not fail on this head

@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 Nov 27, 2026

This branch has not been deployed

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

Labels

Config stale The PR hasn't been updated in 2 weeks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants