Repository navigation
[Fix] model_loader: Neutral UE8M0 block scales for dummy weights - #47337
Merged
merrymercy merged 1 commit intoOct 31, 2026
Merged
Conversation
initialize_dummy_weights only touches floating-point tensors, but MXFP8 layers allocate their UE8M0 block scales (weight_scale_inv) as uint8 zeros. With --load-format dummy those scales stay 0, i.e. 2**-127, so every MXFP8 weight dequantizes to ~0. Fill them with 127 (2**0), the UE8M0 counterpart of the existing neutral FP4 global scales.
Yuxingwang-intel
pushed a commit
to Yuxingwang-intel/sglang
that referenced
this pull request
Nov 6, 2026
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
initialize_dummy_weightsonly initializes floating-point tensors. MXFP8 layers allocate their UE8M0 block scales (weight_scale_inv) astorch.uint8zeros (fp8.py, MoE and linearcreate_weights), so with--load-format dummythose scales stay 0. In UE8M0, 0 means 2^-127, so every MXFP8 weight dequantizes to roughly zero. The MXFP8 layers then produce near-zero outputs, which can propagate to NaN downstream.Modifications
initialize_dummy_weights: fill uint8*weight_scale_invtensors with 127 (2^0), the UE8M0 counterpart of the existing neutral FP4 global scales (filled with 1.0).test_ue8m0_dummy_block_scales_are_neutralnext totest_nvfp4_dummy_scales_are_neutral.Accuracy Tests
Affects only
--load-format dummy; real checkpoints load their own scales.Speed Tests and Profiling
N/A.
Checklist
CI States
Latest PR Test (Base): ❌ Run #40965646221
Latest PR Test (Extra): ❌ Run #40965646003
Latest PR Test (AMD ROCm 10): ❌ Run #40965646016