Skip to content

Commit

Permalink
Fix _load_state_dict_into_meta_model with device_map=None (huggingfac…
Browse files Browse the repository at this point in the history
…e#36488)

* Fix _load_state_dict_into_meta_model with device_map=None

* Update src/transformers/modeling_utils.py
  • Loading branch information
hlky authored and garrett361 committed Mar 4, 2025
1 parent 3a036a7 commit 4d57c2c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/transformers/modeling_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,8 +785,8 @@ def _load_state_dict_into_meta_model(
tensor_device = None
if device_map is not None and device_map.get("", None) is not None:
tensor_device = device_map[""].index if isinstance(device_map[""], torch.device) else device_map[""]

device_map_regex = "|".join(sorted(device_map.keys(), reverse=True))
if device_map is not None:
device_map_regex = "|".join(sorted(device_map.keys(), reverse=True))

# we need this later to initialize tensor parallelism
if device_mesh is not None:
Expand Down

0 comments on commit 4d57c2c

Please sign in to comment.