Repository navigation
[AMD] GLM-5.3-Flash: fuse shared expert and KDA projections on Quark MXFP4 - #41870
Merged
HaiShaw merged 4 commits intoOct 3, 2026
Merged
Conversation
Jacob0226
force-pushed
the
jacob/glm53-quark-mxfp4-fusion
branch
2 times, most recently
from
October 1, 2026 08:21
02a2c97 to
2f42a18
Compare
PR sgl-project#41161 runs the shared expert inside the AITER MoE as expert 288, but only for block-FP8 checkpoints. On the Quark MXFP4 checkpoint the gate logs "requires serialized dynamic 128x128 block-FP8 experts" and every MoE layer still runs the shared expert as its own MLP: two FP4 GEMMs, a split-K reduce, SiLU, two activation quants and the add that merges it back, 7 launches per layer on decode. The gate now also accepts a Quark checkpoint when, for every sparse layer, neither the routed nor the shared experts are excluded from quantization, the routed experts are MXFP4, and both resolve to the same Quark layer config. Anything else keeps the separate shared-expert path, and --disable-shared-experts-fusion still turns it off. Co-authored-by: Cursor <[email protected]>
_can_fuse_proj only admits fp8, mxfp8 and the modelopt configs, so a Quark checkpoint runs the KDA input projections as seven GEMMs per layer on decode instead of three (fused_qkvbfg_a_proj, fused_fg_b_proj and o_proj). The Quark GLM-5.3-Flash checkpoint keeps these projections in BF16, so the fused GEMM reads the same BF16 weights; only the kernel that multiplies them changes. _can_fuse_proj decided by probing get_quant_method for an UnquantizedLinearMethod, but Quark's get_quant_method registers every non-excluded prefix as an online-quantized layer, so the probe would create quantized layers as a side effect. Add QuantizationConfig.is_linear_unquantized, a query that must not register the layer: the base implementation is the same probe, and QuarkConfig answers from its exclude list (an excluded layer that a mixed-precision export keeps in FP8 is still quantized). _can_fuse_proj now asks that and admits quark; no other model calls it. Co-authored-by: Cursor <[email protected]>
Builds QuarkConfig from an export shaped like amd/GLM-5.3-Flash-Quark-MXFP4 (MXFP4 by default, the MTP layer's experts pinned to block-FP8 one by one) and maps its names the way the loader does, so the gates see what they see at load time. Shared expert: admitted, and rejected when a target layer's routed or shared experts are excluded, block-FP8, or quantized differently from each other; the MTP layer's FP8 experts do not veto it. KDA: fused only when every source projection is excluded from quantization, and a rejected probe registers no online-quantized layer.
Jacob0226
force-pushed
the
jacob/glm53-quark-mxfp4-fusion
branch
from
October 1, 2026 09:14
2f42a18 to
074497b
Compare
Jacob0226
marked this pull request as ready for review
October 1, 2026 09:35
Jacob0226
requested review from
1am9trash,
Alisehen,
AniZpZ,
BBuf,
Edwardf0t1,
FlamingoPg,
HaiShaw,
OrangeRedeng,
b8zhong,
ch-wan,
hubertlu-tw,
kkHuang-amd,
mmangkad and
yichiche
as code owners
October 1, 2026 09:35
Contributor
Author
|
/rerun-failed-ci |
Contributor
Author
HaiShaw
approved these changes
Oct 3, 2026
Raiden-Makoto
added a commit
to Raiden-Makoto/squidward
that referenced
this pull request
Oct 14, 2026
Enable sgl-project#38764 PTPC (qkv/f_a/g_a/o), leave DSA sub-backends to the HIP default so sgl-project#41615 selects Triton, and let sgl-project#41870 shared-expert fusion auto-enable. Run the checkout the script lives in and pin TP4 INT4 QuickReduce over the image's inherited INT8.
5 tasks done
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.
Summary
On the Quark MXFP4 GLM-5.3-Flash checkpoint, two decode fusions that other checkpoints have stay off:
This PR lets Quark use both.
Scope
GLM-5.3-Flash on ROCm. CUDA does not change in practice. The shared-expert check is HIP-only and needs gfx950 with AITER. The KDA check has no GPU limit, but it changes only Quark checkpoints, which SGLang runs and tests on ROCm. So KDA fusion applies on any ROCm GPU, not just gfx950. FP8 and ModelOpt checkpoints do not change. Each fusion turns on only when the checkpoint allows it. Otherwise the layer is unchanged.
--disable-shared-experts-fusionTo check the KDA rule without side effects, this PR adds
QuantizationConfig.is_linear_unquantized. Onlyglm5_nextcalls it. Quark answers from its exclude list. Other configs keep the old check.Test plan
Baseline
rocm/sgl-dev:v0.5.20-rocm10-mi35x-20260928(sglang0318a8d0af), no other PRs. Both builds add a router GEMM config (ROCm/aiter#5933). This PR also applies cleanly to main.amd/GLM-5.3-Flash-Quark-MXFP4, MI355X TP4.in8192 / out1024, at this PR's head:
in70000 / out300, measured with the opt-in env since removed (same code path):
Each decode step saves about 1.1–1.5 ms, so the relative gain shrinks as batches grow. Summary traces: HIP-graph decode, baseline TP0, this PR TP1.
test_shared_experts_fusion_gates.pytest_glm5_next_bfg_fusion.pyQuarkConfig.is_linear_unquantizedanswers from the exclude list, counts excluded layers kept in FP8 as quantized, and registers no quantized layerAccuracy: GSM8K 0.965 → 0.967, single scoring pass each — within what one pass resolves.
CI States
Latest PR Test (Base): ✅ Run #36847184493
Latest PR Test (Extra): ❌ Run #36847184428
Latest PR Test (AMD ROCm 10): ❌ Run #36847184568