Repository navigation
[ASM] [HIP] [MoE] Run the FLAT and EMSORT MXFP4 fmoe tiles on padded intermediate widths - #7611
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
READY FOR HUMAN REVIEWPR Self-ReviewRevision Author self-review accepted. Readiness report: Author answers
Show the author's self-review answersBehavior and intentValidation and unverified scopePR-specific questionChanged op testsPR state
Copilot findings
Code and op-test hygiene
Required CI
Shadow mode reports what would block but keeps the status successful. Set |
|
|
We need to test this path in CI, but right now it is not being picked up. CI never reaches the new path. The a4w4 default -hip is still (0, 0) /op_tests/test_moe_2stage.py:1356). Neither the padded launch nor the logical-width retry is tested. Add one small CI case, for example -dim 2560,384 -hip 0,64 with a few token counts. That would cover FLAT 16x160 and 16x320, EMSORT, and the retry. |
025ebcb to
080a278
Compare
…ed rows in CI Review follow-up on ROCm#7611. - FLAT and EMSORT launch round_up(inter_dim - intermediate_pad, sub_GU) columns and raise only if that exceeds the stored width. Requiring the logical width to be tile-aligned rejected rows tuned at the stored width that ran correctly before, e.g. 16x256 at 256 with pad 64. launch_kernel, grid_inter_dim() and kernel_fits() share one helper. - _iter_csv_cases reruns each SiLU/GELU MXFP4 FLAT/EMSORT row with a pad: rows not a multiple of 128 at vLLM's stored layout (logical-width retry), and once per kernel and shape at the row's own width with pad 64. Co-authored-by: Cursor <[email protected]> Signed-off-by: Mikko Tukiainen <[email protected]>
|
@mjkvaak-amd , this PR contains improvements for con 128 and 256 |
Thanks! FLAT and EMSORT now launch |
Rather than one fixed
On MI355X, all pass (35 cases, |
P2: SiLU/GELU padded tests can pass without running FLAT/EMSORT_iter_padded_flat_cases sets expected_kernel1. However, test_fmoe checks it only inside the SwiGLU branch. The SiLU and GELU padded cases therefore test accuracy but not which kernel I confirmed this by disabling the logical-width retry in a scratch copy:
So if the retry or the kernel picker broke later, CI would lose the speedup without failing. Fix: for every activation, assert that expected_kernel1 is dispatched and that run_1stage is used. |
… rows for inter_dim=256, M>=1024 TP4 stores the per-rank MoE intermediate (160) padded to 256. Gate (513, 2560, 256, 11) and add tuned 2-stage FlyDSL rows for M = 1024..16384, with the same scope as the TP2 rows: smaller M is left to the 160-keyed rows that ROCm#7611 reaches. Signed-off-by: Mikko Tukiainen <[email protected]> Co-authored-by: Cursor <[email protected]>
…ctivation Review follow-up on ROCm#7611. expected_kernel1 was only checked on the SwiGLU OAI path, so the padded SiLU/GELU FLAT/EMSORT cases passed on accuracy alone when fused_moe fell back to 2-stage. test_fmoe now records every aiter.fmoe_g1u1 launch during the timed fused_moe calls and asserts that the expected kernel is the only one launched. Co-authored-by: Cursor <[email protected]> Signed-off-by: Mikko Tukiainen <[email protected]>
You're right, thanks for checking. My earlier SiLU/GELU cases checked accuracy but not dispatch. Now fixed: whenever Let me know what you think. |
…DSL rows for padded inter_dim, M>=1024 (#8123) * [Config][MoE] Qwen3.8-Flash-Next MXFP4 TP2: aux shape gate and FlyDSL rows for inter_dim=384, M>=1024 vLLM stores the TP2 MoE intermediate (320) padded to 384 with intermediate_pad=64. Add (513, 2560, 512, 11) to the MXFP4 aux shape gate and tuned 2-stage FlyDSL rows for M = 1024..16384. Smaller M is left to the 320-keyed rows that #7611 reaches: the inline-sort winners at M <= 512 are rejected under a pad and would shadow them. Signed-off-by: Mikko Tukiainen <[email protected]> Co-authored-by: Cursor <[email protected]> * [Config][MoE] Qwen3.8-Flash-Next MXFP4 TP4: aux shape gate and FlyDSL rows for inter_dim=256, M>=1024 TP4 stores the per-rank MoE intermediate (160) padded to 256. Gate (513, 2560, 256, 11) and add tuned 2-stage FlyDSL rows for M = 1024..16384, with the same scope as the TP2 rows: smaller M is left to the 160-keyed rows that #7611 reaches. Signed-off-by: Mikko Tukiainen <[email protected]> Co-authored-by: Cursor <[email protected]> --------- Signed-off-by: Mikko Tukiainen <[email protected]> Co-authored-by: Cursor <[email protected]>
…diate widths vLLM stores the MoE intermediate width padded (Qwen3.8-Flash-Next: 320 stored as 384 at TP2, 160 as 256 at TP4) and passes the zero-filled delta as intermediate_pad. The FLAT 16x32/16x160/16x320 tiles and the EMSORT 16x160/16x320 persistent tiles need the logical width, so a padded call never reached them. - fmoe_g1u1 takes intermediate_pad. The FLAT and EMSORT branches keep the stored inter_dim in KernelArgs (gate/up row offset, w1 scale offset, w2 scale pitch) and size the grid, and the EMSORT ps_deno and total_tgs, from inter_dim - intermediate_pad. - POST_REDUCE keeps the stored width. The logical-width grid is NO_SORT and EMSORT only. - get_heuristic_kernel matches FLAT and EMSORT tiles on the logical width. - get_2stage_cfgs falls back to the FLAT or EMSORT MXFP4 1-stage row tuned at inter_dim - intermediate_pad when the stored width has no row. - The pertokenMXfp4 manifests gain a dim_align column. Kernels without the 512-column tail drain declare 1024, and fmoe_g1u1 passes model_dim to the kernel picker, so the alignment applies per kernel. The conc512 EMSORT limits on the upmerged base are unchanged. - test_moe_2stage passes -hip through for a4w4. Co-authored-by: Cursor <[email protected]> Signed-off-by: Mikko Tukiainen <[email protected]>
…ed rows in CI Review follow-up on ROCm#7611. - FLAT and EMSORT launch round_up(inter_dim - intermediate_pad, sub_GU) columns and raise only if that exceeds the stored width. Requiring the logical width to be tile-aligned rejected rows tuned at the stored width that ran correctly before, e.g. 16x256 at 256 with pad 64. launch_kernel, grid_inter_dim() and kernel_fits() share one helper. - _iter_csv_cases reruns each SiLU/GELU MXFP4 FLAT/EMSORT row with a pad: rows not a multiple of 128 at vLLM's stored layout (logical-width retry), and once per kernel and shape at the row's own width with pad 64. Co-authored-by: Cursor <[email protected]> Signed-off-by: Mikko Tukiainen <[email protected]>
…ctivation Review follow-up on ROCm#7611. expected_kernel1 was only checked on the SwiGLU OAI path, so the padded SiLU/GELU FLAT/EMSORT cases passed on accuracy alone when fused_moe fell back to 2-stage. test_fmoe now records every aiter.fmoe_g1u1 launch during the timed fused_moe calls and asserts that the expected kernel is the only one launched. Co-authored-by: Cursor <[email protected]> Signed-off-by: Mikko Tukiainen <[email protected]>
Conflicts in the SiLU/GELU MXFP4 manifests, where ROCm#7901 appended the emsort 16x320_stk rows: keep this branch's dim_align column and give the new rows 512, as for the other EMSORT rows. Signed-off-by: Mikko Tukiainen <[email protected]> Co-authored-by: Cursor <[email protected]>
Conflicts in the SiLU/GELU MXFP4 manifests from the ROCm#7901 revert (ROCm#8489): drop the emsort 16x320_stk rows it removes, keeping this branch's dim_align column on the rest. Signed-off-by: Mikko Tukiainen <[email protected]> Co-authored-by: Cursor <[email protected]>
|
@valar-cop review |
Align the three affected legacy MoE golden snapshots with the explicit intermediate_pad=0 keyword introduced by #7611. Exact baseline and PR-head CPU snapshots are byte-identical across all four simulated architectures; all 2130 changed records only add this keyword. Preserve frozen tuning inputs, normalization, assertions and gfx1201.
…termediate_pad a8de641 (#7611) passes intermediate_pad to fused_moe.fused_moe_1stage, so every 1-stage record now carries `"intermediate_pad": 0` in stage1.kw and tests/test_moe_dispatch_snapshot.py fails on main. No dispatch decision changed: stripping that kwarg, all records match the previous golden on every arch (and the old golden has no intermediate_pad anywhere). `python tests/moe_dispatch/snapshot.py --update`: gfx942: 26191 keys, 610 changed, 0 new, 0 missing gfx942_cu80: 32928 keys, 674 changed, 0 new, 0 missing gfx950: 32363 keys, 846 changed, 0 new, 0 missing gfx1201: 25684 keys, unchanged All 2130 changed keys are fused_moe_1stage records gaining intermediate_pad=0, for example: ~ changed: grid|base|M=1024|H=2048|I=768|E=128|k=8|Gelu|bfloat16|float8_e4m3fnuz|float8_e4m3fnuz|per_Token|g1u1=1|dw=0|gate=SEPARATED golden: {..., "stage1": {"fn": "fused_moe.fused_moe_1stage", "kw": {"activation": "ActivationType.Gelu", "flat": 0, "kernelName": "", ...}}, ...} now: {..., "stage1": {"fn": "fused_moe.fused_moe_1stage", "kw": {"activation": "ActivationType.Gelu", "flat": 0, "intermediate_pad": 0, "kernelName": "", ...}}, ...} Co-Authored-By: Claude Opus 5.5 <[email protected]>
…termediate_pad (#8790) a8de641 (#7611) passes intermediate_pad to fused_moe.fused_moe_1stage, so every 1-stage record now carries `"intermediate_pad": 0` in stage1.kw and tests/test_moe_dispatch_snapshot.py fails on main. No dispatch decision changed: stripping that kwarg, all records match the previous golden on every arch (and the old golden has no intermediate_pad anywhere). `python tests/moe_dispatch/snapshot.py --update`: gfx942: 26191 keys, 610 changed, 0 new, 0 missing gfx942_cu80: 32928 keys, 674 changed, 0 new, 0 missing gfx950: 32363 keys, 846 changed, 0 new, 0 missing gfx1201: 25684 keys, unchanged All 2130 changed keys are fused_moe_1stage records gaining intermediate_pad=0, for example: ~ changed: grid|base|M=1024|H=2048|I=768|E=128|k=8|Gelu|bfloat16|float8_e4m3fnuz|float8_e4m3fnuz|per_Token|g1u1=1|dw=0|gate=SEPARATED golden: {..., "stage1": {"fn": "fused_moe.fused_moe_1stage", "kw": {"activation": "ActivationType.Gelu", "flat": 0, "kernelName": "", ...}}, ...} now: {..., "stage1": {"fn": "fused_moe.fused_moe_1stage", "kw": {"activation": "ActivationType.Gelu", "flat": 0, "intermediate_pad": 0, "kernelName": "", ...}}, ...} Co-authored-by: Claude Opus 5.5 <[email protected]>
Pick up ROCm#8790's regenerated MoE-dispatch golden (intermediate_pad field from ROCm#7611) so the shard-2 'test_legacy_dispatch_matches_golden_snapshot' gate clears. This branch only touches the a16wfp4 Triton path, disjoint from the golden. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Summary
vLLM stores Qwen3.8-Flash-Next's MoE intermediate width padded (320 → 384 at TP2, 160 → 256 at TP4), so the FLAT and EMSORT MXFP4 1-stage tiles from #5757 never run. This PR launches them over
inter_dim - intermediate_pad, which raises TP2 output throughput by 14.1% at concurrency 1 and 6.9% geomean over concurrency 1–128 on an unmodified vLLM nightly, with GSM8K unchanged.Replaces #7012, which GitHub closed when its base branch
qwe38_flash_mxfp4_asmwas deleted after #5757 merged. Unblocks vllm-project/vllm#64025.Motivation
At TP2 vLLM calls
fused_moe(inter_dim=384, intermediate_pad=64). #5757's tuned rows are keyed at 320, so the lookup misses and 2-stage runs. Forcing a FLAT tile at 384 gives wrong results for 16x160 and 16x320 (relative error 0.66 to inf); 16x32 is correct but computes the 64 pad columns.Not a duplicate: searched open PRs for "intermediate_pad fmoe", "FLAT MXFP4 padded", "asm_fmoe model_dim 1024". #6184 changes 2-stage inline-sort dispatch and #6598 the FlyDSL stage-1 grid.
Changes
fmoe_g1u1gainsintermediate_pad(default 0). FLAT and EMSORT MXFP4 SiLU/GELU kernels keep the storedinter_diminKernelArgs, which sets the gate-to-up offset, the w1 scale offset and the w2 scale pitch. They size the grid, and EMSORT'sps_denoandtotal_tgs, frominter_dim - intermediate_padrounded up to whole tiles, which only adds zero-pad columns. They raise an error only if that exceeds the stored width, so every row that ran at its stored width before still runs. Host-sorted kernels, and the Situv2 and SwiGLU OAI tiles (whose manifests have nodim_align), get no pad and run over the stored width as before.get_2stage_cfgsretries a missed lookup atinter_dim - intermediate_padand accepts only a FLAT or EMSORT MXFP4 SiLU/GELU 1-stage row.fused_moe_1stagepasses the pad through, and the heuristic matches on the logical width.dim_align, fixes a silent bug: FLAT 16x128, 16x256 andvs16x32 (SiLU and GELU) have no 512-column tail, so atmodel_dim2560 they skipped 512 output columns. They now declare 1024 and are rejected there. Other rows declare 512, and manifests without the column keep the old 512 rule.test_moe_2stage.py -hipnow applies to a4w4. Its default (0, 0) is unchanged. The tuned-CSV pass, which CI runs, reruns each SiLU/GELU MXFP4 FLAT/EMSORT row with a pad. Rows whose width is not a multiple of 128 run at vLLM's stored layout (Flash-Next 320 as 384/64, 160 as 256/96). Each kernel and shape also runs once at its own width with pad 64 (e.g. 16x256 at 256).test_fmoerecords everyfmoe_g1u1launch and asserts that the row's kernel was the only one launched, so a 2-stage fallback fails.This does not help at TP1 (640 stored unpadded, no rows) or for prefill chunks above #5757's 512-token rows. At TP4 vLLM rounds the pad of 96 down to 64; vllm-project/vllm#64025 passes the true pad and stays in draft until this PR is merged and released. 2-stage MXFP4, non-MXFP4 fmoe and the MXFP4 Situv2 and SwiGLU OAI tiles are untouched.
Performance (if applicable)
MI355X (gfx950, 256 CUs),
fused_moethroughtest_moe_2stage.py, E = 513, top-k 11,model_dim2560, mean of two runs. Before ismainwith #5757 merged (measured ata10f4be, whose MoE files equalmain@581579a) on the same padded call, which runs 2-stage.TP2 M=32 depends on the routing draw. Over eight draws (the test's RNG state after different preceding cases, identical in both arms), EMSORT 16x320 took 64–67 µs in seven and 99 µs in one, against 93–102 µs for 2-stage. Every other point repeats within 2%.
Serving,
amd/Qwen3.8-Flash-Next-Quark-MXFP4(revisionb2091c38), TP2, MI355X,vllm/vllm-openai-rocm:nightly-4fab5a07475822c6eaa971dceb2e2220d0446808. Both arms build AITER from source: the control ata10f4be(#5757, identical tomainin the files this PR touches), the candidate with this PR on top. This nightly stores 320 as 384 and passesintermediate_pad=64unchanged. The candidate server logs FLAT 16x32 / 16x160 / 16x320 and EMSORT 16x320; the control logs none of them.Two rounds, the arms side by side on HIP 0,1 and 2,3, swapping pairs for the second round. Output throughput is the mean of the two rounds:
Concurrency 2 is round 1 only: round 2 was contended in both arms (mean TPOT 1.4× the median). Concurrency 64 gained 4.6% and 1.7% in the two rounds. The gain is largest at concurrency 1–4, where FLAT runs, and flat at 128, where 8k prefill chunks are 2-stage in both arms and take most of each step. TTFT is unchanged.
Accuracy, GSM8K on the round-2 servers: all 1319 questions, thinking off, paired per question with an exact McNemar test. 84.5% of generations differ textually, so the claim is no directional change.
Testing
Documentation
fmoe_g1u1has no docstring, andintermediate_padhas the same meaning as the existingfused_moeargument it is passed from.Dependencies
Breaking Changes
None.
intermediate_paddefaults to 0. FLAT 16x128, 16x256 andvs16x32 forced atmodel_dim2560 now raise an error instead of returning wrong output.PR Self-Review
Reviewed revision
74835b1
Behavior and intent
A padded MXFP4
fused_moecall (storedinter_dim, non-zerointermediate_pad) with SiLU or GELU now reaches #5757's FLAT and EMSORT 1-stage rows tuned at the logical width. Those kernels launch over the logical columns, rounded up to whole tiles, while striding over the stored ones. Rows tuned at the stored width keep running with a pad. Before, the lookup missed and 2-stage ran, and forcing the tiles gave wrong results. FLAT tiles without a 512-column tail are now rejected atmodel_dim % 1024 != 0instead of skipping columns.Validation and unverified scope
MI355X (gfx950, 256 CUs). The performance, serving and GSM8K numbers above were measured on the first commit's patch (
4c0ffeb, basea10f4be). The control ran this PR'stest_moe_2stage.py, so both arms build the same padded weights. On080a278(rebased ontomain@8b13d52, with the round-up), the same two ladders dispatch the same rows. They time within the run-to-run spread of the table (TP2 13.0–123 µs, TP4 11.5–66.6 µs,logits_diff≤ 1.2e-3):On
fb7d8f2(080a278plus amainmerge and the launch assertion), all 35 padded CSV cases launch their expected kernel, withlogits_diff≤ 1.0e-3. With the logical-width retry disabled, the suite fails on the first padded Flash-Next case ("expected 1-stage …flat_novs_silu_16x32E, launched no fmoe_g1u1"). On025ebcb, the stored-width cases raise (16x128 at 512, pad 64: "needs inter_dim - intermediate_pad divisible by sub_GU").AITER_MOE_2STAGE_CI_PROFILE=standard python op_tests/test_moe_2stage.py --csv-filter ""passes. The empty filter lifts the FlyDSL AOT run-only guard, because the image JIT-builds FlyDSL. The run had 1326 cases, plus 30 large shapes skipped for free memory on a shared GPU; none of the skips were padded cases.On
31100d9(e620d659, rebased ontomain@31f72a4081, plus the SiLU/GELU gate), a probe callsget_2stage_cfgson a padded layout whose logical width has a tuned FLAT row. Before the gate, MiniMax-M3 SwiGLU OAI (stored 896, pad 128) took the retry ontoflat_vs_swiglu_oai_16x32tuned at 768. With the gate it does not, and Flash-Next SiLU (256, pad 96) still does. The MXFP4 CSV suite runs the same 90 cases as onfb7d8f2, with 40 padded lookups resolved by the retry, and passes. The CI profile passes with 1374 cases; one unpadded 32768-token case is skipped by the existing FlyDSL 32-bit workspace guard.On
74835b1(merge ofmain@6a0a23ff3a, which includes the #7901 revert #8489), the SiLU/GELU MXFP4 manifests are again identical to31100d9's. The MXFP4 CSV suite (90 cases, 40 padded lookups) and the CI profile (1406 cases, the same one skip) pass.The padded FLAT and EMSORT
logits_diffis 2.2e-4 to 1.2e-3, against about 1.2e-5 for 2-stage; the test fails above 1e-2. The gap is the 1-stage kernels' in-register activation quantization: on the FLAT-only revision, unpadded 320 gave 4.9e-4 to 1.4e-3. (checkAllclose ... failed!prints for every MXFP4 case, 2-stage included:atol=0.01is tighter than MXFP4.)Earlier revision (2026-10-27, FLAT only): padded vs unpadded weights and the model_dim check
The same tile on padded and on unpadded weights, M = 1–64, max abs diff. The reference is an unpadded rerun, since the top-k accumulation is atomic. On #5757 alone, padded 16x160 and 16x320 give relative error 0.66 to inf.
At
model_dim2560, FLAT 16x128, 16x256 andvs16x32 went from relative error 0.45 to rejected; at 3072 they give 0.03–0.04. Thetest_moe.pyint8/fp8 g1u1 cases behaved as on stock.What remains unverified: serving and GSM8K were not rerun on
080a278orfb7d8f2; the latter changes only the test since080a278. The round-up leaves the Flash-Next grid unchanged, because 320 and 160 are whole numbers of their tiles. The padded-vs-unpadded probe, themodel_dimtable andtest_moe.pyare from the FLAT-only revision and were not rerun. The EMSORT probe against unpadded weights was not run; its accuracy evidence islogits_diffand GSM8K. GPQA-Diamond was not rerun (0.904 → 0.914 on the FLAT-only revision). TP4 serving needs vllm-project/vllm#64025 and was not run here. Not tested on MI250X or MI300X, because the kernels are gfx950-only. NIAH was not run. The new CSV cases cover SiLU/GELU rows only, which is now also the only scope of the change. No padded Situv2 or SwiGLU OAI kernel launch was run; those calls take the stored-width launch thatmainuses.PR-specific question
What would each changed op test fail on before this PR, and why does an existing canonical test not cover it?
Before this PR, the a4w4 cases of
test_moe_2stage.pyhard-codedintermediate_pad=0and ignored-hip, so no test could build a padded MXFP4 call. With-dim 2560,384 -hip 0,64the case reaches the FLAT and EMSORT rows. Without thefmoe_g1u1change, 16x160 and 16x320 return wrong results on that layout. No existing test passes a non-zerointermediate_padto an a4w4fused_moe. The new tuned-CSV cases would fail onmain, because the padded lookup misses and the expected kernel is not dispatched. They would also fail on this PR's first head, where the stored-width cases raise.Changed op tests
op_tests/test_moe_2stage.py:-hip(hidden and intermediate pad) now also applies to the a4w4 cases, which used to hard-code (0, 0). The bf16/fp8 defaults (192, 128) and the a4w4 default (0, 0) are unchanged._iter_csv_casesadds 35 padded MXFP4 FLAT/EMSORT cases to CI's tuned-CSV pass: 20 at vLLM's stored layout and 15 stored-width rows with pad 64. Each asserts the launched 1-stage kernel, for every activation, and the accuracy against the torch reference.Co-authored-by: Cursor [email protected]