Repository navigation
fix(modeling): reject missing decoder weights - #135
Merged
nonatofabio merged 1 commit intoNov 24, 2026
Merged
Conversation
Check loading results for the retained decoder so incompatible checkpoints cannot silently leave random weights in use. Keep discarded heads and encoders outside the check.
ikenyal
marked this pull request as ready for review
November 9, 2026 21:25
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
nonatofabio
self-requested a review
November 24, 2026 01:18
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.
Human Overview
I wanted checkpoint loading to fail clearly instead of silently leaving decoder weights randomly initialized. This change checks the loading results and rejects missing decoder weights, while preserving intentional omissions and keeping checkpoint-format support unchanged.
Description
An unmapped checkpoint can leave decoder weights randomly initialized while loading appears to succeed.
_load_torsonow requests loading information on each branch and raises aValueErrornaming the checkpoint, missing-weight count, and first missing decoder keys.Only weights belonging to the retained decoder are checked. Discarded LM heads and Gemma 4 vision/audio encoders remain optional. This does not add checkpoint layouts or change the training recipe, calibration, or correctly loaded weights. The architecture guide describes the failure behavior.
Related Issues
Closes #131. This is separate from the token-readout work in #124, as agreed in the issue.
Type of Change
Bug fix
Testing
Python 3.12: 517 passed, 19 skipped. Python 3.10 with CI's floor pins: 501 passed, 20 skipped. CPU distributed: 11 passed, 1 skipped. Twelve offline CPU regression cases cover complete/missing weights, an unmapped layout, and intentional omissions; six fail on main. CI-equivalent formatting, lint, and type checks pass. CUDA untested; see the environment note below.
pytest -qlocally (GPU tests skip automatically without CUDA)ruff check .andmypy ./srclocally and both passAdditional Details
Validation environment
HF_HUB_OFFLINE=1, without downloading base models.mypy ./src ./training --exclude training/testspassed with the dependencies declared for CI's detached lint environment. Type-checking with the latest runtime's torch stubs instead reports the same 24 existing errors on main and this branch; no new errors were introduced.Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.