Repository navigation
[HIP] [MoE] Qwen3.8-Flash-Next MXFP4 TP2/TP4: aux shape gates and FlyDSL rows for padded inter_dim, M>=1024 - #8123
Conversation
… 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 ROCm#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]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
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 |
… 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]>
Resolve the conflict with #8123, which added tuned FlyDSL rows for intermediate 384 at 1024..16384 tokens to the Flash MXFP4 config: - keep the FlyDSL 8192 row. It serves 4097..8192 tokens, where the producer is 3% faster at 8192 but 8-22% slower at 4097..6000; - the producer replaces the FlyDSL 16384 row and keeps its new 32768 row, so intermediate 384 uses it from 8193 tokens, as intermediate 640 already does. The intermediate 640 rows, both code objects and the manifest rows are unchanged.
Summary
Adds MXFP4 aux shape-gate entries and tuned FlyDSL 2-stage rows for the Qwen3.8-Flash-Next MoE in the shapes vLLM passes at TP2 (
inter_dim=384) and TP4 (inter_dim=256), both withintermediate_pad=64. The rows cover M = 1024..16384, so through M bucketing they serve runtime M = 513..16384, which is prefill. For M <= 512, the rows keyed at the true widths 320 and 160 (#5757, #7901) remain in charge; #7611 is what reaches them.Motivation
moe_intermediate_size=640gives 320 per rank at TP2 and 160 at TP4. vLLM pads W4A4 MoE weights to a multiple of 128, so AITER sees 384 and 256. Neither width has tuned rows, and neither aux shape ((513, 2560, 512, 11)and(513, 2560, 256, 11)) is gated. As a result every FlyDSL MXMOE row is rejected, and each prefill batch runs the heuristic fallback (flydsl_moe1_afp4_wfp4_*).Not a duplicate: I searched the open PRs for Qwen3.8-Flash-Next,
2560/384,2560/256andinter_dim. #5757 and #7901 add rows at the true widths for M <= 512, and none of the others covers the padded widths.Changes
aiter/ops/moe_mxfp4_aux.pyandcsrc/kernels/mxfp4_moe/moe_aux/codegen/gen_instances.py: gate(513, 2560, 512, 11)for TP2 and(513, 2560, 256, 11)for TP4.aiter/configs/model_configs/qwen3_8_flash_fp4_{tuned,untuned}_fmoe.csv: five rows per TP for M = 1024, 2048, 4096, 8192 and 16384. The rows were tuned withgemm_moe_tune.py --mxfp4-flydsl, which needs [CK] [Tune][MoE] Clear inherited rocprofiler env before the MXFP4 FlyDSL tuner spawns shape workers #8121. Theuscolumn holds CUDA-graph replay medians.There are no M <= 512 rows on purpose. The winners there are BM16
f16in(inline-sort) kernels, and_mxfp4_inline_sort_unsupporteddiscards those under any pad. vLLM always sets a pad here, so the rows would never run, and they would also shadow #7611's retry atinter_dim - pad. All ten shipped rows are non-inline-sort (BM 32/64/128).This does not help decode, and it does not cover TP1 (
inter_dim=640, which needs no pad).Performance (if applicable)
Kernel benchmark:
fmoe_pad_bench.py(attached under Validation below) times one wholefused_moecall, including sorting, activation quantization and both stages, set up the way vLLM sets it up.vllm/vllm-openai-rocm:nightly-rocm100-8ca766326652(AITER 0.1.29), one GPU per arm. The before arm is the image unchanged. The after arm bind-mounts two files over the installed package:moe_mxfp4_aux.pywith this PR's gate entries, and this PR'sqwen3_8_flash_fp4_tuned_fmoe.csv. Nothing else differs.intermediate_pad=64. Routing comes from random scores throughfused_topk, so expert load is close to uniform. The seed is fixed per M.max(4, min(50, 20000 // M))back-to-back calls (39 at M=512, 4 at M>=4096), one warm-up replay and 9 timed replays with HIP events. A run reports the median replay time divided by the calls per graph.AITER_LOG_MORE=1. In the before arm every M logsno tuned FlyDSL config ... heuristic FlyDSL fallback. In the after arm M>=1024 logs this PR's kernel names, and M=512 logs the fallback in both arms. M=512 is the control: it has no row here.The relative L2 error against an fp32 MoE computed at the true width is unchanged to the fourth decimal at every M: about 0.289, which is the combined W4A4 quantization error and is identical in both arms. At TP4, passing the true pad of 96, as vllm#64025 would, gives the same times and errors.
Serving, TP2: vLLM in the same image, with the arms side by side on two GPU pairs and swapped between 2 rounds. Each cell is the mean of the two rounds' medians.
--max-num-batched-tokensAccuracy: GSM8K 5-shot chat, n = 1319, flexible-extract.
Testing
Documentation
Config data and shape lists only.
Dependencies
Breaking Changes
None.
PR Self-Review
Reviewed revision
01f2011
Behavior and intent
Prefill-sized MXFP4 MoE calls for Qwen3.8-Flash-Next at TP2 (
inter_dim=384) and TP4 (inter_dim=256), withintermediate_pad=64and M in 513..16384, now run tuned FlyDSL 2-stage kernels. Before this PR they ran the heuristic fallback, because the padded widths had no rows and no aux gate.Validation and unverified scope
python3 -m pytest -q op_tests/test_mxfp4_moe_aux_codegen.pypasses (3 tests) with both new shapes. The kernel A/B usesfmoe_pad_bench.py(below), run with and without this PR's files in the rounds described under Performance, usingTRUE_INTER=320 INTER=384for TP2 andTRUE_INTER=160 INTER=256for TP4. The serving A/B and GSM8K results are listed above.Remaining and unverified:
fmoe_pad_bench.py
PR-specific question
(gfx950, cu_num=256, padded M, 2560, inter_dim 384 or 256, 513, 11, Silu, bf16 out, fp4x2 activations and weights, per_1x32, g1u1, doweight_stage1=0). Everything else misses and keeps today's path.get_padded_Mmaps runtime M to the next power of two, so the rows serve M = 513..16384. M <= 512 has no row here, and M >= 16385 uses the heuristic as before.is_mxfp4_moe_shape_supportedtrue for these four-tuples only.test_mxfp4_moe_aux_codegen.pychecks that the gate list and the codegenSHAPESagree.get_2stage_cfgsstill validates every tuned MXMOE row and falls back on any failure. It checks the sortblock_magainst GEMM1 BM and GEMM2, the registered aux shape, the input dtype forinline_quant, stage-2 bias, and EPexpert_mask. No shipped row is inline-sort, so the padding rejection in_mxfp4_inline_sort_unsupporteddoes not apply, and the rows run with the pad vLLM passes, as the kernel A/B shows.Changed op tests
None.
Co-authored-by: Cursor [email protected]