From dd0cbc195bcbd28ce6270b0e348632c5504e62e9 Mon Sep 17 00:00:00 2001 From: "arthur.zucker@gmail.com" Date: Tue, 30 May 2023 13:29:09 +0000 Subject: [PATCH 1/3] Better warning --- src/transformers/modeling_utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/transformers/modeling_utils.py b/src/transformers/modeling_utils.py index 38be4e736a7a..6c24785c2768 100644 --- a/src/transformers/modeling_utils.py +++ b/src/transformers/modeling_utils.py @@ -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." + ) no_split_modules = model._no_split_modules if device_map not in ["auto", "balanced", "balanced_low_0", "sequential"]: raise ValueError( From 85759b796b31da8f992cdd956a2458cf47e62ed3 Mon Sep 17 00:00:00 2001 From: Arthur <48595927+ArthurZucker@users.noreply.github.com> Date: Tue, 30 May 2023 16:33:36 +0200 Subject: [PATCH 2/3] Update src/transformers/modeling_utils.py Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> --- src/transformers/modeling_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transformers/modeling_utils.py b/src/transformers/modeling_utils.py index 6c24785c2768..638e446f1421 100644 --- a/src/transformers/modeling_utils.py +++ b/src/transformers/modeling_utils.py @@ -2735,7 +2735,7 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P if model._no_split_modules is None: 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." + 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 if device_map not in ["auto", "balanced", "balanced_low_0", "sequential"]: From c3de005d908ae9fa2974cf24f095b67bf3531801 Mon Sep 17 00:00:00 2001 From: "arthur.zucker@gmail.com" Date: Tue, 30 May 2023 14:35:00 +0000 Subject: [PATCH 3/3] format line --- src/transformers/modeling_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/transformers/modeling_utils.py b/src/transformers/modeling_utils.py index 638e446f1421..2dbe5d43829b 100644 --- a/src/transformers/modeling_utils.py +++ b/src/transformers/modeling_utils.py @@ -2735,7 +2735,8 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P if model._no_split_modules is None: 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." + 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 if device_map not in ["auto", "balanced", "balanced_low_0", "sequential"]: