Unverified Commit af2aac51 authored by Arthur's avatar Arthur Committed by GitHub
Browse files

[from_pretrained] imporve the error message when `_no_split_modules` is not defined (#23861)



* Better warning

* Update src/transformers/modeling_utils.py
Co-authored-by: default avatarSylvain Gugger <35901082+sgugger@users.noreply.github.com>

* format line

---------
Co-authored-by: default avatarSylvain Gugger <35901082+sgugger@users.noreply.github.com>
parent 58022e41
...@@ -2734,7 +2734,10 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix ...@@ -2734,7 +2734,10 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
target_dtype = torch.int8 target_dtype = torch.int8
if model._no_split_modules is None: if model._no_split_modules is None:
raise ValueError(f"{model.__class__.__name__} does not support `device_map='{device_map}'` yet.") raise ValueError(
f"{model.__class__.__name__} does not support `device_map='{device_map}'`. To implement support, the model"
"class needs to implement the `_no_split_modules` attribute."
)
no_split_modules = model._no_split_modules no_split_modules = model._no_split_modules
if device_map not in ["auto", "balanced", "balanced_low_0", "sequential"]: if device_map not in ["auto", "balanced", "balanced_low_0", "sequential"]:
raise ValueError( raise ValueError(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment