Simplify DTensor Check for modeling_utils.py (#38245)
Update modeling_utils.py
This commit is contained in:
@@ -3567,7 +3567,7 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, PushToHubMixin, PeftAdapterMi
|
|||||||
for name, tensor in state_dict.items():
|
for name, tensor in state_dict.items():
|
||||||
# Sometimes in the state_dict we have non-tensor objects.
|
# Sometimes in the state_dict we have non-tensor objects.
|
||||||
# e.g. in bitsandbytes we have some `str` objects in the state_dict
|
# e.g. in bitsandbytes we have some `str` objects in the state_dict
|
||||||
if isinstance(tensor, torch.Tensor) or isinstance(tensor, DTensor):
|
if isinstance(tensor, torch.Tensor):
|
||||||
ptrs[id_tensor_storage(tensor)].append(name)
|
ptrs[id_tensor_storage(tensor)].append(name)
|
||||||
else:
|
else:
|
||||||
# In the non-tensor case, fall back to the pointer of the object itself
|
# In the non-tensor case, fall back to the pointer of the object itself
|
||||||
|
|||||||
Reference in New Issue
Block a user