Skip to content

[Fix] model_loader: Neutral UE8M0 block scales for dummy weights - #47337

Merged
merrymercy merged 1 commit into
sgl-project:mainfrom
wwl2755:fix-dummy-ue8m0-block-scales
Oct 31, 2026
Merged

merrymercy merged 1 commit into
sgl-project:mainfrom
wwl2755:fix-dummy-ue8m0-block-scales

Conversation

@wwl2755

@wwl2755 wwl2755 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

initialize_dummy_weights only initializes floating-point tensors. MXFP8 layers allocate their UE8M0 block scales (weight_scale_inv) as torch.uint8 zeros (fp8.py, MoE and linear create_weights), so with --load-format dummy those 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_inv tensors with 127 (2^0), the UE8M0 counterpart of the existing neutral FP4 global scales (filled with 1.0).
  • Unit test test_ue8m0_dummy_block_scales_are_neutral next to test_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

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.
@metamergebot metamergebot added the run-ci CI: run the baseline test suite on this PR label Oct 30, 2026
@wwl2755
wwl2755 marked this pull request as ready for review October 30, 2026 00:59
@wwl2755
wwl2755 requested a review from b8zhong as a code owner October 30, 2026 00:59

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@merrymercy
merrymercy merged commit 800de62 into sgl-project:main Oct 31, 2026
217 of 243 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants