Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
May 30, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/transformers/modeling_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2734,7 +2734,9 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P
target_dtype = torch.int8

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 have a `_no_split_modules` attribute, thus it does not support `device_map='{device_map}'` yet. If you are using a model on the hub, we recommend to open a pull request to make sure they implement the `_no_split_modules` attribute."
ArthurZucker marked this conversation as resolved.
Show resolved Hide resolved
)
no_split_modules = model._no_split_modules
if device_map not in ["auto", "balanced", "balanced_low_0", "sequential"]:
raise ValueError(
Expand Down