Ignore CLIP position_ids in unexpected key loading report#45385
Closed
songyuc wants to merge 1 commit intohuggingface:mainfrom
Closed
Ignore CLIP position_ids in unexpected key loading report#45385songyuc wants to merge 1 commit intohuggingface:mainfrom
songyuc wants to merge 1 commit intohuggingface:mainfrom
Conversation
Contributor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: clip |
6 tasks
Author
|
Thanks! This PR appears to be superseded by #45437, which has now been merged and also covers the CLIP case. I'll close this PR to avoid duplication. |
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?
Loading
openai/clip-vit-base-patch32currently reports the following keys as unexpected:text_model.embeddings.position_idsvision_model.embeddings.position_idsIn the current CLIP implementation, these buffers are registered with
persistent=False, so they are not part of the current serialization contract and are not expected to be restored from checkpoints.Older CLIP checkpoints may still contain these keys, but they are harmless historical buffers. This PR adds them to
_keys_to_ignore_on_load_unexpectedinCLIPPreTrainedModelso they no longer appear as misleading unexpected keys during loading.This follows the same approach as #44508 for OwlViT.
Related to #44493.
I reproduced the issue locally, verified that the two keys disappear from
unexpected_keysafter the change, and added a targeted regression test.Code Agent Policy
Before submitting
Test plan
CLIPModel.from_pretrained("openai/clip-vit-base-patch32", output_loading_info=True)RUN_SLOW=1 python -m pytest tests/models/clip/test_modeling_clip.py -k position_ids -sv -rsWho can review?
@Cyrilvallez