-
Notifications
You must be signed in to change notification settings - Fork 29k
AutoModel.from_pretrained(...)
(with explicit device_map
unset) fails under with torch.device("meta")
with PyTorch 2.6.0 and 2.7.0
#38066
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
AutoModel.from_pretrained(...)
fails under with torch.device("meta")
with PyTorch 2.7.0AutoModel.from_pretrained(...)
fails under with torch.device("meta")
with PyTorch 2.6.0 and 2.7.0
Probably in the code transformers/src/transformers/modeling_utils.py Lines 833 to 834 in 716819b
there In all of modeling_utils.py there are 3-4 places where this needs to be fixed to not fail under I think the code I found in the wild does this as a smoke test, e.g. to force downloading the model weights, check that the model code works etc? |
AutoModel.from_pretrained(...)
fails under with torch.device("meta")
with PyTorch 2.6.0 and 2.7.0AutoModel.from_pretrained(...)
(with explicit device_map
unset) fails under with torch.device("meta")
with PyTorch 2.6.0 and 2.7.0
Hi, I'm not sure |
It actually worked after my fixes to ~three lines. The only problems came from usage of default I think it's a valid way for smoke tests / getting HF to download everything and check that sizes in the checkpoint are matching the meta tensors in the model etc. And supporting colloquial PyTorch's |
Sure - if you're willing to open a PR for the fix we can take a look! |
I found this code in the wild in https://github.com/Open-Reasoner-Zero/Open-Reasoner-Zero/blob/f6d1ec77ce2ce18f3d925a1014c9e4d6b4ad3072/orz/ppo/actors.py#L745-L746 (linked issue Open-Reasoner-Zero/Open-Reasoner-Zero#71)
fails with:
Also, unless uncommenting the first line, it also fails on 2.6.0 with
RuntimeError: Tensor.item() cannot be called on meta tensors
:The text was updated successfully, but these errors were encountered: