You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Many models started showing UNEXPECTED Key with position id #44493
PyTorch version (accelerator?): 2.10.0+cu128 (CUDA)
Using distributed or parallel set-up in script?:
Using GPU in script?:
GPU type: NVIDIA A100-SXM4-40GB
Who can help?
Many models, including google/owlvit-base-patch32 and a few LLMs started showing unexpecting keys. For example, I got this
import torch
from transformers import AutoModelForZeroShotObjectDetection, AutoProcessor
from transformers.image_utils import load_image
# Prepare processor and model
# model_id = "google/owlv2-large-patch14-ensemble"
model_id = "google/owlvit-base-patch32"
device = "cuda" if torch.cuda.is_available() else "cpu"
processor = AutoProcessor.from_pretrained(model_id)
model = AutoModelForZeroShotObjectDetection.from_pretrained(model_id).to(device)
OwlViTForObjectDetection LOAD REPORT from: google/owlvit-base-patch32
Key | Status | |
--------------------------------------------+------------+--+-
owlvit.text_model.embeddings.position_ids | UNEXPECTED | |
owlvit.vision_model.embeddings.position_ids | UNEXPECTED | |
Notes:
- UNEXPECTED :can be ignored when loading from different task/architecture; not ok if you expect identical arch.
Information
The official example scripts
My own modified scripts
Tasks
An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
My own task or dataset (give details below)
Reproduction
Loading some models that could trigger this, example code as below
import torch
from transformers import AutoModelForZeroShotObjectDetection, AutoProcessor
from transformers.image_utils import load_image
# Prepare processor and model
# model_id = "google/owlv2-large-patch14-ensemble"
model_id = "google/owlvit-base-patch32"
device = "cuda" if torch.cuda.is_available() else "cpu"
processor = AutoProcessor.from_pretrained(model_id)
model = AutoModelForZeroShotObjectDetection.from_pretrained(model_id).to(device)
Expected behavior
It should load correctly with no unexpected keys as they are the same unmodified model
This is annoying, but it thankfully shouldn't affect model performance! I believe what's happening here is that owlvit used to save self.position_ids as a buffer, but this was not the position embeddings, it was just an integer range tensor from 0 to the max sequence length. Obviously, there's not much point in saving this in the checkpoints, since it can easily be recomputed on the fly.
At some point the model was likely updated to recompute the key, but then we were left with these extra keys in the checkpoints and the loader is complaining about them. The right solution is to add those keys to keys_to_ignore_on_load_unexpected for owlvit to suppress those warnings - would you like to make a PR?
Hi @Rocketknight1 , I’ve opened a PR to address this by adding the corresponding patterns to _keys_to_ignore_on_load_unexpected in OwlViTPreTrainedModel.
Activity
Rocketknight1 commentedon Mar 6, 2026
This is annoying, but it thankfully shouldn't affect model performance! I believe what's happening here is that owlvit used to save
self.position_idsas a buffer, but this was not the position embeddings, it was just an integer range tensor from 0 to the max sequence length. Obviously, there's not much point in saving this in the checkpoints, since it can easily be recomputed on the fly.At some point the model was likely updated to recompute the key, but then we were left with these extra keys in the checkpoints and the loader is complaining about them. The right solution is to add those keys to
keys_to_ignore_on_load_unexpectedforowlvitto suppress those warnings - would you like to make a PR?KartikPawade commentedon Mar 6, 2026
Hi @Rocketknight1 , I’ve opened a PR to address this by adding the corresponding patterns to
_keys_to_ignore_on_load_unexpectedinOwlViTPreTrainedModel.PR: #44508
Please let me know if any adjustments are needed. Thanks!