Skip to content

Commit a55e503

Browse files
Isotr0pyLysandreJik
authored andcommitted
Fix config dtype parsing for Emu3 edge case (#40766)
* fix emu3 config Signed-off-by: Isotr0py <mozf@mail2.sysu.edu.cn> * address comment Signed-off-by: Isotr0py <mozf@mail2.sysu.edu.cn> * add comments Signed-off-by: Isotr0py <mozf@mail2.sysu.edu.cn> --------- Signed-off-by: Isotr0py <mozf@mail2.sysu.edu.cn>
1 parent 91393fe commit a55e503

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/transformers/configuration_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,9 @@ def dict_dtype_to_str(self, d: dict[str, Any]) -> None:
10581058
if d.get("dtype") is not None:
10591059
if isinstance(d["dtype"], dict):
10601060
d["dtype"] = {k: str(v).split(".")[-1] for k, v in d["dtype"].items()}
1061-
elif not isinstance(d["dtype"], str):
1061+
# models like Emu3 can have "dtype" as token in config's vocabulary map,
1062+
# so we also exclude int type here to avoid error in this special case.
1063+
elif not isinstance(d["dtype"], (str, int)):
10621064
d["dtype"] = str(d["dtype"]).split(".")[1]
10631065
for value in d.values():
10641066
if isinstance(value, dict):

0 commit comments

Comments
 (0)