Repository navigation
fix(model): store Muse Glimmer final norm uncentered for exact bf16 round trip - #6256
Draft
kamran-nvidia wants to merge 3 commits into
Draft
kamran-nvidia wants to merge 3 commits into
kamran-nvidia wants to merge 3 commits into
Conversation
…ound trip HF Muse applies its final RMSNorm gain directly (w), unlike the decoder-layer norms (1 + w). The bridge mapped decoder.final_norm.weight through RMSNorm2ZeroCenteredRMSNormMapping, which stores w - 1 in bf16. For Muse's final-norm gains (about -5 to -3) that subtraction rounds, so 1,120 of 6,656 elements of model.language_model.norm.weight changed by one bf16 step after an HF -> Megatron -> HF round trip. Build the Megatron final norm with zero_centered_gamma=False and map it with ReplicatedMapping so the released weights are stored as-is. Add a regression test that round-trips bf16 gains in [-5, -3) through the mapping bit-exactly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kamran Jafari <kjafarisadeg@nvidia.com>
Contributor
Author
|
/ok to test ffcf2d6 |
The released final-norm gains span about -4.9 to 4.4, not [-5, -3). Most elements that drifted under the old zero-centered mapping (1,061 of 1,120) lie in [-4, -3), where bf16 w - 1 rounds to a coarser step. The test input range is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kamran Jafari <kjafarisadeg@nvidia.com>
Contributor
Author
|
/ok to test c9b763d |
Contributor
Author
|
/ok to test a2a3025 |
This branch was successfully deployed
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.
What does this PR do ?
Makes the Muse Glimmer HF ↔ Megatron round trip bit-exact again. Before this change, the final RMSNorm gain was rounded on import.
Changelog
modeling_muse_glimmer.py:MuseGlimmerModelrebuildsdecoder.final_normas aTENormwithlayernorm_zero_centered_gamma=False. HF Muse applies the final-norm gain directly (w); only the decoder-layer norms use1 + w. Those layer norms stay zero-centered.muse_glimmer_bridge.py:decoder.final_norm.weightnow usesReplicatedMappinginstead ofRMSNorm2ZeroCenteredRMSNormMapping, so the released weights are stored unchanged.test_muse_glimmer.py: updated the final-norm assertions and addedtest_final_norm_mapping_round_trips_bf16_exactly, which round-trips bf16 gains in [-5, -3) through the mapping and checks them withtorch.equal.Root cause
RMSNorm2ZeroCenteredRMSNormMappingdoesw -= 1on import andw += 1on export in the tensor's own dtype (bf16). Whenw - 1falls in a coarser bf16 range thanw, the stored value is rounded and adding 1 can't recover it.The released final-norm gains (
model.language_model.norm.weight, 6,656 elements) range from -4.94 to 4.38, split almost evenly between negative and positive values. After a round trip, 1,120 elements change and the other 1,435 tensors are exact:w - 1falls in [-5, -4), where the bf16 step is 0.03125 instead of 0.015625 (max error 0.015625).w - 1also lands in a coarser range (errors up to 0.0078125).The final norm was switched to the zero-centered mapping by
refactor(muse-glimmer): use native normalization modulesinside #5479, after the verification card's last exact audit. This PR restores the setup that audit covered: an uncentered final norm whose weights are stored as-is.RMSNorm2ZeroCenteredRMSNormMappingitself is unchanged, so the Qwen3.5 and Qwen3-Next bridges are not affected.Reviewer notes
w - 1. With this change they would load asw - 1and be used asw. Re-import those checkpoints from HF.wand1 + (w - 1)are equal in exact arithmetic, but with bf16 storage the old model applied1 + round(w - 1). That differed from HF'swon the same 1,120 channels (max 0.015625). The final norm now applies the HF gain exactly.Validation
Environment: NeMo 26.10.rc0 container (Transformer Engine 2.18, Transformers 5.15.0) with MCore at this PR's pinned
07147d69.python -m pytest tests/unit_tests/models/muse_glimmer/test_muse_glimmer.pypasses 22/22. As a control, running this PR's test file against the pre-fix base (c4067f5) fails the three updated tests.f84ecc3a, bf16): ranscripts/conversion/run_conversion.pywith the card'simport/exportarguments. Each run was followed by an audit comparing every exported tensor with the source (keys, dtypes, shapes, bytes) and a strict Transformers reload.ffcf2d6)ffcf2d6)c4067f5)model.language_model.norm.weightdiffers in 1,120 / 6,656 elements, max 0.015625Remaining before this leaves draft:
python -m pytest tests/unit_tests/models/muse_glimmer/test_muse_glimmer.pybridge_commit/last_verifiedfor the conversion items inexamples/model_verification_cards/muse-glimmer-30b/card.yamlGitHub Actions CI
See the CI section in the Contributing doc for how to trigger the CI. A Nvidia developer will need to approve and trigger the CI for external contributors.
Before your PR is "Ready for review"
Pre checks:
Additional Information
🤖 Generated with Claude Code