Checklist
Describe the bug
What is happening?
InternVL 3.5 crashes with:
((RuntimeError: Tensor.item() cannot be called on meta tensors))
Happens when loading or calling model.chat
Reproducible on CPU and GPU
Where it happens???
-Inside modeling_intern_vit.py
-During vision backbone initialization
-Specifically when .item() is called on tensors created during init
Why it happens (your key insight)?????
-Transformers ≥5.x may initialize models on the meta device
-InternVL performs scalar extraction (.item()) before weights are materialized
-This creates a compatibility issue
One important comparison::::
Was working with me 1 Weeks ago
Reproduction
Install torch + transformers ≥5.x
Load OpenGVLab/InternVL3_5-1B using AutoModel.from_pretrained
Call model.chat (or even just model init)
Observe crash
Environment
OS: Google Colab (Ubuntu)
Python: 3.12
torch: 2.5.1+cu124
transformers: 5.1.0
InternVL: InternVL3_5-1B
CUDA: True
Error traceback
File "modeling_intern_vit.py", line XXX
dpr = [x.item() for x in torch.linspace(...)]
RuntimeError: Tensor.item() cannot be called on meta tensors