[NNX] Checkpoint restore: error on weights missing from the checkpoint#4341
Open
ecnal-cienet wants to merge 1 commit into
Open
[NNX] Checkpoint restore: error on weights missing from the checkpoint#4341ecnal-cienet wants to merge 1 commit into
ecnal-cienet wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
ee725b5 to
d416dc1
Compare
Collaborator
|
|
d416dc1 to
e206ad7
Compare
On the pure_nnx resume path a weight present in the model but absent from the checkpoint was silently zero-filled, or left as an unmaterialized ShapeDtypeStruct that failed cryptically in the first train_step. Fold a descriptive guard into _populate_pure_dict_from_partial: NNX-only rngs/dropout are still defaulted, but a genuinely missing weight now raises naming the parameter path and shape by default, governed by a new checkpoint_missing_param_policy (error/warn) config.
e206ad7 to
cff628c
Compare
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
On the pure_nnx resume path, a weight present in the model but absent from the checkpoint is handled unsafely. Now that proactive
scan_layersvalidation has landed (#4304) and the reactive mismatch guards were removed (#4340),_populate_pure_dict_from_partialfills every absent leaf with a default:partial_restoreas an unmaterializedjax.ShapeDtypeStruct→ propagated as-is, then failing with a cryptic, low-level compile/allocation error deep in the firsttrain_step.The
scan_layerscheck only validates thescan_layersflag, so neither case is caught for an arbitrary missing weight (a changedemb_dim/mlp_dim, a different number of layers, a dropped or renamed module, etc.).This folds a descriptive guard into
_populate_pure_dict_from_partial, tracking the tree path and whether the leaf sits under an NNX-onlyrngs/dropoutsubtree:checkpoint_missing_param_policy:"error"(default): raise naming the parameter path and expected shape."warn": log a WARNING listing the zero-filled path and continue."error"is the default because a zero-filled or unmaterialized weight is a silentcorrectness failure. A survivingShape DtypeStructis treated the same as an absent leaf, so the previously cryptic first-train_stepcompile error becomes an explicit, path-named error at restore time.Tests
tests/unit/checkpointing_nnx_load_test.py::TestMissingParamPolicy— present weights pass through; rng/dropout absence defaults even undererror; a missing weight raises naming the path; a survivingShapeDtypeStructis treated as missing;warnzero-fills and logs; default policy iserror.tests/unit/checkpointing_nnx_missing_param_test.py— end-to-end through the realcreate_orbax_checkpoint_manager → maybe_save_checkpoint → load_state_if_possiblestack: a weight missing from the checkpoint raises naming its path,warnzero-fills and continues, and a matching-arch restore returns concrete arrays.Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.