Repository navigation
[AMD] [GLM-5.3-Flash Day 0] Load the MXFP4 MTP draft layer - #39779
Merged
hnyls2002 merged 7 commits intoSep 22, 2026
Merged
Conversation
Serving amd/GLM-5.3-Flash-Quark-MXFP4 with MTP aborts while loading the draft model, on a shape mismatch between a uint8 parameter and a bfloat16 tensor of twice its width. That width ratio is the signature of an MXFP4-packed parameter meeting an unpacked weight: a module the checkpoint stores unquantized, or stores as block FP8, was built as MXFP4 because its config was never found. Two independent lookups miss, for different reasons. 1. Per-expert entries against a fused module. The export pins each expert individually, naming 864 entries for the NextN layer's 288 experts as block FP8, while SGLang builds one FusedMoE whose name ends in .experts. No pattern matches that name, so the MoE inherits the global MXFP4 scheme and its unpacked FP8 weights meet a half-width packed parameter. Resolving .experts from the experts' shared config fixes it; the experts of one layer have to agree for a fused module to be well defined, so disagreement raises rather than silently picking one. 2. The NextN mapper replaced the target's instead of composing with it. The quantization config is keyed on the checkpoint's own names, so the draft has to strip the same prefixes the target does before any lookup can match. Composing the two also exposes that eh_proj, enorm and hnorm are siblings of the transformer block rather than children of it, so they need their own rules alongside the catch-all that routes everything else under decoder. With both, the draft loads and MTP is accurate: GSM8K 99.0% over 200 examples on MI355X TP4, against 99.5% for the same checkpoint with MTP off. One further defect remains outside this change. The draft's fused MoE scales stay at their all-ones initial value because the scale-name normalization added by sgl-project#38546 matches ".weight_scale" with a dot, while a fused expert parameter is named experts.w13_weight_scale with an underscore. Accuracy is unaffected since verification rejects the bad drafts, but acceptance drops to 1.20 of 6 and MTP buys nothing. The one-line correction belongs on sgl-project#38546, which introduces that helper.
1am9trash
pushed a commit
that referenced
this pull request
Sep 17, 2026
Squashed from #39779, which carries the same change against main and remains open there for review. Co-Authored-By: Jacob Chang <[email protected]> Co-authored-by: Cursor <[email protected]>
Jacob0226
marked this pull request as ready for review
September 18, 2026 07:35
Jacob0226
requested review from
1am9trash,
HaiShaw,
hubertlu-tw,
kkHuang-amd and
yichiche
as code owners
September 18, 2026 07:35
Raiden-Makoto
suggested changes
Sep 18, 2026
Raiden-Makoto
left a comment
Contributor
There was a problem hiding this comment.
Requesting changes for the two reproduced configuration-mapping issues noted inline.
…sing
Two review findings on the MXFP4 NextN draft loading, both about a lookup
quietly resolving to something it was never told.
WeightsMapper._map_name rewrites a name at most once: it tries the longest rule
first and stops at the first hit. `|` merges rule dicts into that one loop, so
the draft's renames did not compose with the target's -- they competed. Against
the checkpoint's own names the longer `model.language_model.` rule won and the
result never reached `model.decoder`: `...layers.45.mlp.experts.7.up_proj` came
out as `model.layers.45.mlp.experts.7.up_proj`. `eh_proj` fared worse, because
`language_model.` itself ends in `model.`, so the `model.layers.45.eh_proj` rule
matched mid-string and produced `model.language_model.eh_proj`; `enorm` and
`hnorm` escaped that only by a rule-length tie broken by dict insertion order.
Working at all therefore depended on names arriving already stripped, which is
not a property this method can see. Spelling out both the checkpoint's
`model.language_model.layers.{n}` and the normalized `model.layers.{n}` removes
the dependency, and the prefixed rule being the longer one keeps the stripped
rule from matching inside it. Checked against amd/GLM-5.3-Flash-Quark-MXFP4's
924-entry layer_quant_config and 626-entry exclude list: from either naming all
864 expert entries resolve under model.decoder.mlp.experts, and all six
draft-layer exclusions land on the runtime module names, with no `language_model`
surviving in the output.
_find_matched_config's per-expert resolution accepted any non-empty match and
returned its first entry, so a checkpoint pinning one expert -- or one projection
of each -- would hand that scheme to the whole fused bank. It now requires the
coverage a fused module implies: contiguous expert indices and the same
projection set for every expert, before the existing config comparison. Partial
coverage raises, which can_fuse_shared_expert already reads as "cannot fuse", so
its stub-module lookup keeps working.
Unit tests cover both: the mapper against both namings for the transformer block
and for the eh_proj/enorm/hnorm siblings, and expert resolution for complete
uniform coverage, conflicting configs, a missing expert, partial projections, and
a fused parameter name that is not <index>.<projection>.
Contributor
|
LGTM |
…extn-draft Co-authored-by: Cursor <[email protected]> # Conflicts: # test/registered/unit/layers/quantization/test_quark_config.py
Raiden-Makoto
approved these changes
Sep 22, 2026
- Word the per-expert coverage errors like the neighbouring packed-module check, one line each. - Trim the NextN mapper comment: _map_name chains one substring rule with one prefix rule, so the "rules cannot be chained" premise was wrong. - Keep one regression case per bug plus the fall-through contract; fold the raise cases into one table, and move the mapper rows that fail before the fix into test_glm5_next_modelopt.py to reuse its fixture instead of adding a CPU file. Co-Authored-By: Claude Opus 5.5 <[email protected]>
hnyls2002
approved these changes
Sep 22, 2026
Collaborator
|
/rerun-test test/registered/e2e/models/test_glm53_flash_b200.py |
Contributor
|
Results for 🚀 |
This was referenced Sep 23, 2026
hdt98
added a commit
to hdt98/sglang
that referenced
this pull request
Sep 25, 2026
Adopt upstream sgl-project#39341 (k-pool DSA indexer on gfx950) and sgl-project#39779 (MXFP4 MTP draft mapper) in the conflicted files. Keep on top of them the int64 page index in the index-K prefix gather, and count aiter's 256-column row padding when splitting ragged MQA logits under the 2 GiB cap.
hdt98
added a commit
to hdt98/sglang
that referenced
this pull request
Sep 25, 2026
Reset quark.py to upstream sgl-project#39779's per-expert fused config resolution and keep only the block-FP8 activation-grouping check. Fused shared experts are CUDA-only, so the removed shared-expert precision matching loses nothing on ROCm. Drop tests whose targets are now upstream code or duplicate upstream coverage: k-pool cache layout and backend dispatch (sgl-project#39341), TileLang zero-RoPE (sgl-project#38547), transform_index widths (sgl-project#39340), mHC HIP dispatch (sgl-project#38545), the NextN name mapper, write-plan multi-pool, negative-slot scatter, and the comment-only AITER runner. Keep one focused test per production change this branch owns.
3 of 4 tasks
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
Serving
amd/GLM-5.3-Flash-Quark-MXFP4with MTP aborts while loading the draft: a uint8 parameter meets a bfloat16 tensor of twice its width. That ratio is an MXFP4-packed parameter meeting an unpacked weight — a block-FP8 module got built as MXFP4, its entry never found.Two lookups miss.
...mlp.expertsmatching none....layers.45.mlp.expertsresolves to...layers.45.eh_projrewrites tomodel.decoder.eh_proj(no such module)model.eh_projScope
_find_matched_config's per-expert resolution, and the GLM-5.3-Flash draft's name mapping. Checkpoints whose entries already match a module by name resolve exactly as before, and the FP8 build of the same model is untouched. Experts have to agree for a fused module to mean anything, so partial or conflicting coverage raises rather than handing one expert's scheme to the whole bank;can_fuse_shared_expertalready reads that as cannot-fuse. The draft's rules spell out both namings instead of changingWeightsMappersemantics, to keep the change off every other model's mapping.Test plan
Base
rocm/sgl-dev:v0.5.19-rocm720-mi35x-20260914, sglangmainplus the eight open Day-0 PRs (#39338, #39339, #39340, #39341, #38545, #38546, #38547, #39317) and #39778. This PR is the only variable. Same checkpoint, MI355X TP4, EAGLE 5 steps / 6 draft tokens, CUDA graphs on. GSM8K, 200 examples, temperature 1.0.Acceptance needs #38546's
weight_scalesuffix match, without which the draft's expert scales stay at 1.0.Name resolution is also checked against the checkpoint's 924-entry
layer_quant_configand its six draft-layerexcludeentries. Mapper only: before this PR the.expertsresolution did not exist.model.decoder.mlp.expertsCPU unit tests cover both namings and the four coverage cases.
CI States
Latest PR Test (Base): ⏳ Run #35785429641
Latest PR Test (Extra): ❌ Run #35785429424
Latest PR Test (AMD ROCm 10): ⏳ Run #35785429575