Add opt-in strict checkpoint loading to from_pretrained - #48962
Open
YeonwooSung wants to merge 1 commit into
Open
YeonwooSung wants to merge 1 commit into
YeonwooSung wants to merge 1 commit into
Conversation
Raise on missing or unexpected keys when from_pretrained is called with strict=True. Default remains False so For* loads of a base checkpoint are unchanged.
Contributor
|
Thank you for your contribution 🤗! CI Security Gate — automatic approval blockedThis PR was not automatically approved for CI because the security gate failed. Possible reasons:
See the workflow run for the exact violations. A maintainer can review and manually approve CI if a finding is a false positive. |
Member
|
This comes from a 2 years old feature request, so not sure we actually want it haha |
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.
Fixes #32067
Add opt-in
strict=Truetofrom_pretrained. Afterloading_infois finalized, raise if there are missing or unexpected keys. Default staysFalse.This matches
torch.nn.Module.load_state_dict(strict=True)for those two sets. Conversion scripts can turn it on without changingFor*loads of a base checkpoint.Discussed on #32067. Arthur +1 still stood; no ACK on missing vs unexpected after 8 days, so this raises on both.
Before submitting
Who can review?
@Cyrilvallez @ArthurZucker @qgallouedec