Skip to content

Commit 4799952

Browse files
authored
[loading] Fix device detection (#42323)
fix
1 parent f2738ee commit 4799952

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/transformers/core_model_loading.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ def convert_and_load_state_dict_in_model(
610610
tp_plan = tp_plan or {}
611611
device_map = device_map or {"": "cpu"}
612612
device_map_regex = re.compile(
613-
"|".join(rf"({k})" for k in sorted(device_map.keys(), key=lambda x: x.count("."), reverse=True))
613+
"|".join(rf"({k})" for k in sorted(device_map.keys(), key=lambda x: (x.count("."), len(x)), reverse=True))
614614
)
615615
dtype_plan = dtype_plan or {}
616616
weight_mapping = weight_mapping or []

0 commit comments

Comments
 (0)