Repository navigation
fix: preserve final RMS predictions during weight processing - #1903
Merged
jlarson4 merged 2 commits intoOct 16, 2026
Merged
Conversation
jlarson4
reviewed
Oct 15, 2026
jlarson4
approved these changes
Oct 15, 2026
jlarson4
left a comment
Collaborator
There was a problem hiding this comment.
Looks good to me! I will merge if/when CI is passing
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.
Description
Preserve predictions during compatibility-mode weight processing for supported mixed normalization models: LayerNorm blocks with a final RMSNorm (
normalization_type="LN", final_rms=True).Two centering operations incorrectly treated this topology as uniformly LayerNorm:
d_model. This is equivalent after zero-mean LayerNorm output, but not after RMSNorm.center_writing_weights=True, even though the main writing-weight-centering path already excludes models withfinal_rms=True.Both paths now respect
final_rms. Final RMS scale is still folded into unembedding weights, and value biases are still folded into attention output biases; only the unsafe centering is skipped. Block LayerNorm folding, vocabulary-axis unembedding centering, and ordinary LayerNorm/RMSNorm behavior remain unchanged. No dependencies or public APIs change.The cached-statistics analysis paths also respect the selected final norm: ordinary residual-stack normalization and the fused projected-neuron path share a target-aware centering check. Intermediate block LayerNorm centering is preserved. This keeps DLA and full residual decomposition consistent with the correctly preserved model logits. Writing-weight centering and post-value-fold output-bias cleanup likewise share one eligibility condition.
Reproduction and regression coverage
All reproductions use tiny, real Native models with random CPU weights and no checkpoint downloads. Extending the existing prediction-parity matrix to include mixed LN/final-RMS with nonidentity block norm parameters failed before the fix: maximum log-softmax difference was approximately 0.5501. Fixing only unembedding centering left approximately 0.0186 error, exposing the post-value-fold bias centering path.
Regression coverage now includes:
Validation
git diff --checkpassed.Type of change
Checklist
No documentation change is needed because this restores the existing prediction-preservation contract. The full-unit-suite checkbox remains unchecked because only the affected test surface was run.