From 2eba14e2851add1e25ecc114d470153516e1069c Mon Sep 17 00:00:00 2001 From: jiqing-feng Date: Fri, 22 Mar 2024 08:21:23 -0400 Subject: [PATCH 1/3] disable export=False in IPEXModel --- optimum/intel/ipex/modeling_base.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/optimum/intel/ipex/modeling_base.py b/optimum/intel/ipex/modeling_base.py index a125194250..16e8415834 100644 --- a/optimum/intel/ipex/modeling_base.py +++ b/optimum/intel/ipex/modeling_base.py @@ -203,6 +203,9 @@ def _from_pretrained( subfolder: str = "", **kwargs, ): + if not getattr(config, "torchscript", False): + raise ValueError("`torchscript` should be set to True to load TorchScript model") + # Load the model from local directory if os.path.isdir(model_id): model_cache_path = os.path.join(model_id, file_name) From 05fef0c762cf5332be36c30feccb471887a10186 Mon Sep 17 00:00:00 2001 From: jiqing-feng <107918818+jiqing-feng@users.noreply.github.com> Date: Tue, 26 Mar 2024 12:57:39 +0800 Subject: [PATCH 2/3] Update optimum/intel/ipex/modeling_base.py Co-authored-by: Ella Charlaix <80481427+echarlaix@users.noreply.github.com> --- optimum/intel/ipex/modeling_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/optimum/intel/ipex/modeling_base.py b/optimum/intel/ipex/modeling_base.py index 16e8415834..266ff39785 100644 --- a/optimum/intel/ipex/modeling_base.py +++ b/optimum/intel/ipex/modeling_base.py @@ -204,7 +204,7 @@ def _from_pretrained( **kwargs, ): if not getattr(config, "torchscript", False): - raise ValueError("`torchscript` should be set to True to load TorchScript model") + raise ValueError("`config.torchscript` should be set to `True`, if your model is not a TorchScript model and needs to be traced please set `export=True` when loading it with `.from_pretrained()`") # Load the model from local directory if os.path.isdir(model_id): From ed6b62464536efc95c73e5df6d5eb7fab324c062 Mon Sep 17 00:00:00 2001 From: jiqing-feng Date: Tue, 26 Mar 2024 09:04:31 -0400 Subject: [PATCH 3/3] fix code style --- optimum/intel/ipex/modeling_base.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/optimum/intel/ipex/modeling_base.py b/optimum/intel/ipex/modeling_base.py index 266ff39785..e77994c475 100644 --- a/optimum/intel/ipex/modeling_base.py +++ b/optimum/intel/ipex/modeling_base.py @@ -204,7 +204,9 @@ def _from_pretrained( **kwargs, ): if not getattr(config, "torchscript", False): - raise ValueError("`config.torchscript` should be set to `True`, if your model is not a TorchScript model and needs to be traced please set `export=True` when loading it with `.from_pretrained()`") + raise ValueError( + "`config.torchscript` should be set to `True`, if your model is not a TorchScript model and needs to be traced please set `export=True` when loading it with `.from_pretrained()`" + ) # Load the model from local directory if os.path.isdir(model_id):