Skip to content

Fix Muse Glimmer final norm initialization - #4489

Merged
tianyu-l merged 2 commits into
pytorch:mainfrom
yikw1022:fix/muse-glimmer-final-norm-init
Sep 5, 2026
Merged

tianyu-l merged 2 commits into
pytorch:mainfrom
yikw1022:fix/muse-glimmer-final-norm-init

Conversation

@yikw1022

@yikw1022 yikw1022 commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

The final output norm uses gain_center=0.0 and inherited zero weight
initialization from _gain_norm, resulting in zero effective scale at
initialization. This zeros the final hidden states and logits, and produces
zero gradients for the decoder and lm_head on the first backward pass.

Initialize only the final norm weight to one while retaining
gain_center=0.0, so its initial effective scale is one. This keeps the
checkpoint parameterization unchanged and leaves the other gain-centered
norm initializations unchanged.

Validation:

  • git diff --check passed.
  • A standalone RMSNorm forward/backward check produced zero outputs and
    gradients before the change, and nonzero outputs and gradients after it.

@meta-cla

meta-cla Bot commented Sep 5, 2026

Copy link
Copy Markdown

Hi @yikw1022!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 5, 2026
@meta-cla

meta-cla Bot commented Sep 5, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@tianyu-l

tianyu-l commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@claude review this PR

@claude

claude Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @tianyu-l's task in 4m 46s —— View job


Review: Fix Muse Glimmer final norm initialization

  • Read changed files and surrounding context
  • Verify the root cause and correctness of the fix
  • Check for issues / side effects
  • Post review

Summary

The fix is correct and the root cause is real. I was able to independently confirm the bug from the checked-in golden numerics, which is nice corroboration.

Root-cause confirmation. The final norm is a RMSGainCenterNorm with effective scale weight + gain_center. It was built via _gain_norm(..., gain_center=0.0), which pins param_init=_GAIN_NORM_INIT = {"weight": nn.init.zeros_} (__init__.py:76, :108-114). So at init the effective scale was 0 + 0 = 0, zeroing the final hidden states. With h=0 into lm_head (no bias), logits are exactly zero -> uniform distribution -> step-1 loss = ln(vocab).

The debug vocab is 2048, and ln(2048) = 7.624619. The committed golden asset's step-1 loss is exactly 7.624619007... (tests/assets/losses/{fake_pg,real_pg}/muse_glimmer_a10g.txt). That is the fingerprint of all-zero logits — the bug is real and this fix addresses it correctly.

Fix correctness. Overriding param_init={"weight": nn.init.ones_} while keeping gain_center=0.0 gives effective scale 1 + 0 = 1 at init. This is the right approach because it preserves the checkpoint parameterization: the state-dict adapter maps HF norm.weight -> norm.weight with no +/-1 offset (the final norm uses the plain-weight convention; see state_dict_adapter.py:35, :139), and init is overwritten by loaded weights anyway. Choosing gain_center=1.0 instead would have required an offset in the adapter and broken checkpoint compat — so keeping gain_center=0.0 is the correct choice. Using dataclasses.replace also avoids mutating the shared _GAIN_NORM_INIT dict. The docstring update in model.py:59-61 is accurate.

Blocking issue: golden loss assets must be regenerated

Per .claude/CLAUDE.md ("Validating Numerics" / "Show numerical proof"), this is a computation change that alters from-scratch training numerics, not a no-op refactor. The two golden assets consumed by the muse_glimmer_text_fsdp integration test still encode the pre-fix (buggy, all-zero-logit) trajectory:

  • tests/assets/losses/fake_pg/muse_glimmer_a10g.txt
  • tests/assets/losses/real_pg/muse_glimmer_a10g.txt

After this fix, step-1 logits are no longer zero, so the loss will no longer be ln(2048) and the entire loss/grad_norm trajectory changes. The integration test compares against golden_numerics_path (tests/integration_tests/models.py:193-195), so CI will fail unless these assets are regenerated on GPU with the fix applied. This is the main thing missing from the PR. Regenerate the golden losses →

Minor / non-blocking

  1. PR validation was insufficient for the guidelines. The description validates with a "standalone RMSNorm forward/backward check," but a computation change should include a full-model loss comparison (the regenerated assets above effectively serve as this proof). Worth attaching in the PR description.
  2. Optional readability. Rather than dataclasses.replace(_gain_norm(...), param_init=...) at the callsite, consider a small weight_init parameter on _gain_norm (defaulting to _GAIN_NORM_INIT). Purely stylistic — the current form is correct and localized.
  3. Scope audit. RMSGainCenterNorm and the gain_center=0.0 final-norm pattern are Muse-Glimmer-specific, so no sibling models (llama3/qwen3/deepseek_v3/gpt_oss/flux) need the same change. Good.

Verdict

Correct, well-reasoned fix that preserves checkpoint compatibility. Please regenerate the two muse_glimmer_a10g.txt golden assets so the integration test reflects post-fix numerics — without that, CI will fail and the recorded "golden" values would continue to encode the bug.
· branch fix/muse-glimmer-final-norm-init

@tianyu-l tianyu-l left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

might need to update golden loss files, please see what tests say

# Final output norm is gain-centered on 0.0.
norm=_gain_norm(dim, _NORM_EPS, gain_center=0.0),
# Keep the checkpoint's zero gain center, but initialize to unit scale.
norm=dataclasses.replace(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

see if you like this style or the style claude suggests

@tianyu-l
tianyu-l merged commit e7d702b into pytorch:main Sep 5, 2026
14 checks passed
wwwjn added a commit that referenced this pull request Sep 7, 2026
## Summary

- automatically apply `ciflow/8gpu` when a PR changes files under
`tests/assets/losses/`
- refresh the stale Real-PG A10G goldens for DeepSeek V3, GPT-OSS, Muse
Glimmer, and Qwen3
- normalize the generated parallelism header in the DeepSeek V3 CP+PP
golden

## Why

A Fake-PG golden update signals an expected numerics change, but the
corresponding Real-PG numerics currently run only after merge unless the
author manually adds `ciflow/8gpu`. Labeling any golden update
automatically makes the author validate the full 8-GPU Real-PG suite
before landing.

The current Real-PG values became stale after #4484 changed MoE router
numerics and #4489 changed Muse Glimmer initialization.

## Test plan

- `pre-commit run --files .github/labeler.yml
tests/assets/losses/real_pg/*.txt`
- [8-GPU Real-PG golden export on current
main](https://github.com/pytorch/torchtitan/actions/runs/34075482250):
feature and model suites passed
- compared all exported goldens byte-for-byte with the checked-in files
- confirmed all 10 loss and grad-norm steps for the four changed
numerical goldens against an independent scheduled Real-PG run ([run
34070052002](https://github.com/pytorch/torchtitan/actions/runs/34070052002))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants