[WIP DO NOT MERGE] [AMD] fix(mxfp4): route AITER MXFP4+swiglu through FlyDSL gate_mode=INTERLEAVE - #25580
Closed
bingxche wants to merge 3 commits into
Closed
[WIP DO NOT MERGE] [AMD] fix(mxfp4): route AITER MXFP4+swiglu through FlyDSL gate_mode=INTERLEAVE#25580bingxche wants to merge 3 commits into
bingxche wants to merge 3 commits into
Conversation
|
Cursor Agent can help with this pull request. Just |
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
gate_mode=INTERLEAVEgate_mode=INTERLEAVE
gate_mode=INTERLEAVE
bingxche
marked this pull request as ready for review
May 18, 2026 08:38
bingxche
requested review from
AniZpZ,
BBuf,
Edwardf0t1,
FlamingoPg,
Fridge003,
HaiShaw,
Ying1123,
ch-wan,
ispobock and
merrymercy
as code owners
May 18, 2026 08:38
This was referenced May 18, 2026
Collaborator
Author
|
@amd-bot ci-status |
CI Status for PR #25580PR: [AMD] fix(mxfp4): route AITER MXFP4+swiglu through FlyDSL gate_mode=INTERLEAVE AMD: 3 test-job failures (0 likely related) | Others: 16 base-b job failures (0 related — all fast-failed on lint) AMD CI Failures
Other CI Failures
DetailsPR semantics (why none of the failures are PR-caused):
Blocker / next step: the cascade of NV/base-b failures and the lint failure are caused by a pre-existing
|
AITER's CK 2-stage MoE codegen (gen_instances.py) only accepts silu/gelu as activation; passing swiglu makes the JIT build fail with 'invalid choice: swiglu' -> 'gemm_moe_ck2stages_lookup.h not found' -> ModuleNotFoundError when no tuned config row matches the workload (e.g. gpt-oss-20b/120b MXFP4 on mi35x gfx950 8-GPU). aiter.fused_moe exposes gate_mode as a caller-controlled parameter (default GateMode.SEPARATED). The MXFP4 path was not setting it, so swiglu fell back to the CK default and tried to JIT a non-existent ck2stages swiglu kernel. Thread gate_mode through AiterMoeQuantInfo and AiterRunnerCore.run, and select GateMode.INTERLEAVE in Mxfp4MoEMethod.apply when activation is swiglu. The FlyDSL interleaved-gate stage1 kernels natively support swiglu and are what the MXFP4 tuned CSV rows target. Note: AITER >= the commit that adds the gate_mode kwarg to aiter.fused_moe and ships aiter.ops.flydsl.moe_common is required. Co-authored-by: Bingxu Chen <Bingxu.Chen@amd.com>
cursor
Bot
force-pushed
the
bingxche/mxfp4-aiter-swiglu-gate-mode-5279
branch
from
May 20, 2026 11:24
6dd60d9 to
24b408c
Compare
This was referenced May 23, 2026
This was referenced May 31, 2026
Resolve conflict in AiterMoeQuantInfo (keep both swiglu_limit and gate_mode fields) and reconcile AiterRunnerCore.run() into a single gate_mode source. main #26208 set extra["gate_mode"]=INTERLEAVE when swiglu_limit>0, while this branch passes gate_mode=quant_info.gate_mode directly to fused_moe. A naive merge would pass gate_mode twice (TypeError) on the FP8/DSv4 path where swiglu_limit>0. Now gate_mode is resolved once: it comes from quant_info.gate_mode (MXFP4/GPT-OSS sets it from activation), and swiglu_limit>0 forces INTERLEAVE to preserve the original DSv4 behavior. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 2, 2026
Rohan138
added a commit
to Rohan138/vllm
that referenced
this pull request
Jun 8, 2026
The MXFP4 W4A16 weight-load path in oracle/mxfp4.py uses shuffle_weight_a16w4 (is_guinterleave=True), which interleaves gate/up columns within each weight tile. The CK/FlyDSL MoE kernels in aiter must be told this via gate_mode=GateMode.INTERLEAVE so they decode the gate/up packing correctly. Without the explicit gate_mode, aiter defaults to SEPARATED and (since ROCm/aiter#3123) dispatches the (SEPARATED + Swiglu + per_1x32 + fp4x2) case to a path that returns garbage for shuffled weights or crashes during CK2stages JIT for the unshuffled Quark variant (amd/gpt-oss-20b-w-mxfp4-a-bf16). This was the root cause of ROCM-25517 (gpt-oss-120b W4A16 gsm8k acc = 0) and ROCM-25478 (gpt-oss-20b Quark JIT crash). Other paths are unaffected: - FP8 W8A8 (DeepSeek-V4-Pro, DeepSeek-V3.2): shuffled with quark_ocp_mx.py:shuffle_weight(layout=(16,16)) — non-interleaved. use_mxfp4_w4a16 is False, default SEPARATED preserved. - MXFP4 W4A4 (amd/DeepSeek-R1-0528-MXFP4): shuffled via rocm_aiter_ops.shuffle_weights — non-interleaved. use_mxfp4_w4a16 is False, default SEPARATED preserved. The gate_mode kwarg was added to aiter.fused_moe in ROCm/aiter#3123 (aiter>=0.1.14). To stay compatible with older aiter shipping with vllm (e.g. aiter 0.1.13.post1 in the vllm-rocm:nightly image), we probe the aiter signature and drop the kwarg when unsupported — pre-vllm-project#3123 aiter tolerated the implicit SEPARATED default for interleave-shuffled weights, so dropping the kwarg is safe there. GateMode itself only exists on aiter>=0.1.14 and is imported under try/except for the same reason. Validation on MI355X (gfx950): vllm@main + aiter@main (6aeba41) openai/gpt-oss-120b W4A16 gsm8k: TP=1: 0.000 -> 0.905 TP=8: 0.000 -> 0.905 vllm@main + aiter@main amd/gpt-oss-20b-w-mxfp4-a-bf16 TP=2 enforce-eager: CK2stages JIT crash -> serves cleanly vllm-rocm:nightly + aiter 0.1.13.post1 openai/gpt-oss-120b W4A16 gsm8k: TP=1: 0.910 (backward-compat — gate_mode kwarg silently dropped) vllm-rocm:v0.22.0 + aiter@main openai/gpt-oss-120b W4A16 gsm8k: TP=1: 0.895 amd/gpt-oss120b-w-mxfp4-a-fp8 W4A8 (this PR composes with vllm-project#44804): TP=8 mc=1=326, mc=8=2087, mc=32=6523, mc=64=11610 tok/s Reference: sgl-project/sglang#25580 (sglang's equivalent fix). Recommended by aiter maintainer (XiaobingZhang) on ROCm/aiter#3586. Signed-off-by: Rohan Potdar <rohan.potdar@amd.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Resolve issue ROCm/aiter#3227 surfaced after AITER commit
ff9bf15cc5c5afcd527d5695cf5462ba0bc1cc2f(ROCm/aiter#3123)Credit to @XiaobingSuper
Fix the
nightly-accuracy-8-gpu-mi35x/nightly-accuracy-8-gpu-mi35x-rocm720failure ontest_gpt_oss_eval_mi35x.py(runs 76071145339 / 76071145701).The crash chain (logs):
Root cause:
Mxfp4MoEMethodhard-codesactivation="swiglu"for the AITER backend (python/sglang/srt/layers/quantization/mxfp4.py:1019).aiter.fused_moe(...)exposesgate_modeas a caller-controlled parameter (defaults toGateMode.SEPARATED). SGLang was not setting it, so AITER took the SEPARATED path.swiglu(module_moe_ck2stages_..._swiglu_per_1x32_...).ck_gemm_moe_2stages_codegen/gen_instances.py) only acceptssiluorgelufor-act. Codegen aborts,gemm_moe_ck2stages_lookup.his never produced, the subsequent.cucompile fails, and the scheduler dies withModuleNotFoundError.The correct path for MXFP4 + swiglu on AITER is the FlyDSL interleaved-gate stage1 kernels (
flydsl_moe1_afp4_wfp4_bf16_*), which natively implement swiglu via fusedsilu_and_mul_fq. Those kernels are selected when the caller passesgate_mode=GateMode.INTERLEAVE.Modifications
python/sglang/srt/layers/moe/moe_runner/aiter.pygate_mode: str = "separated"toAiterMoeQuantInfo(default preserves existing AITER MoE semantics — AITER's own default is alsoSEPARATED).AiterRunnerCore.run, resolve a singlegate_modeand forward it into theaiter.fused_moe(...)call. This is the post-[MoE] Unify DeepEPMoE+MoriEPMoE through AITER MoeRunner pre/post-permute #23760 equivalent of the original patch'sfused_experts_none_to_aiteredit, and now covers the unified standard / DeepEP normal / DeepEP LL dispatch paths through the AITER runner.python/sglang/srt/layers/quantization/mxfp4.pyMxfp4MoEMethod.applyAITER branch, setgate_mode=GateMode.INTERLEAVE.valuewhenself.runner.config.activation == "swiglu", otherwise keepGateMode.SEPARATED.value. ImportGateModefromaiter.ops.flydsl.moe_commonlocally inside the branch (kept lazy because aiter is ROCm-only).Reconcile with
main#26208 (added during themainmerge)After branching,
mainlanded #26208 which, insideAiterRunnerCore.run, setsextra["gate_mode"] = GateMode.INTERLEAVE.valueandextra["swiglu_limit"]wheneverquant_info.swiglu_limit > 0(the DSv4 FP8 path). A naive merge would then passgate_modetwice toaiter.fused_moe(...)(once via this PR's explicit kwarg, once via**extra), raisingTypeError: fused_moe() got multiple values for keyword argument 'gate_mode'on anyswiglu_limit > 0call.The merge therefore reconciles both into a single source of truth for
gate_modeinrun:This is byte-for-byte equivalent to #26208 on the DSv4 FP8 path (
swiglu_limit > 0⇒gate_mode="interleave"+swiglu_limitforwarded), so DSv4 behavior is unchanged, while the MXFP4/GPT-OSS path getsINTERLEAVEfromquant_info.gate_modeas intended.Required AITER version. This patch depends on two AITER changes:
aiter.fused_moe(...)exposinggate_modeas a caller-controlled kwarg.aiter.ops.flydsl.moe_commonmodule that definesGateMode.Both are present from ROCm/aiter PR #3123 (commit
ff9bf15c). Older AITER pins (e.g.a6bb499...shipped in somerocm/sgl-devimages) will fail at runtime with eitherTypeError: fused_moe() got an unexpected keyword argument 'gate_mode'orModuleNotFoundError: No module named 'aiter.ops.flydsl.moe_common'. CI images / Dockerfile pins must be bumped to at leastff9bf15c, or workflows must be dispatched withaiter_refset to a sufficiently new commit, before this PR can land cleanly across all AITER MoE tests (LLaDA2, Qwen3 MoE, DeepEP, etc., not only MXFP4).For AITER versions that meet the above bound, this change is a no-op on every non-MXFP4 / non-swiglu AITER path:
quant_info.gate_modestays at the"separated"default and matches AITER's own default behavior.Tests (commit
134d74a)Re-dispatched
nightly-accuracy-8-gpu-mi35xon this PR branch after merging latestmain(which required reconciling thegate_modechange with the newswiglu_limithandling from #26208). Both passed ✅:nightly-accuracy-8-gpu-mi35x(run)nightly-accuracy-8-gpu-mi35x-rocm720(run)Speed Tests and Profiling
The INTERLEAVE FlyDSL stage1 kernels are the ones the MXFP4 tuned CSVs target on
gfx950, so this also takes the MXFP4 path off the un-tuned CK default and onto the intended high-performance path. No standalone microbench in this PR.Checklist
CI States
Latest PR Test (Base): ❌ Run #26733545189
Latest PR Test (Extra): ❌ Run #26733545103