Fix device_map bug by raise an error when using device_map=xpu (#10340)

* Fix device_map bug by raise an error when using device_map=xpu

* Fix sync error

* Fix python style

* Use invalidInputError instead of invalidOperationError
This commit is contained in:
Keyan (Kyrie) Zhang 2024-03-08 13:38:52 +08:00 committed by GitHub
parent db00e79cdf
commit 7a621a4db0

View file

@ -145,6 +145,10 @@ class _BaseAutoModelClass:
invalidInputError(model_hub in ["huggingface", "modelscope"],
"The parameter `model_hub` is supposed to be `huggingface` or "
f"`modelscope`, but got {model_hub}.")
invalidInputError(not ('device_map' in kwargs and 'xpu' in kwargs['device_map']),
"Please do not use `device_map` "
"with `xpu` value as an argument. "
"Use model.to('xpu') instead.")
if model_hub == "huggingface":
config_dict, _ = PretrainedConfig.get_config_dict(pretrained_model_name_or_path)
elif model_hub == "modelscope":