diff --git a/optimum/intel/ipex/modeling_base.py b/optimum/intel/ipex/modeling_base.py index a125194250..e77994c475 100644 --- a/optimum/intel/ipex/modeling_base.py +++ b/optimum/intel/ipex/modeling_base.py @@ -203,6 +203,11 @@ def _from_pretrained( subfolder: str = "", **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()`" + ) + # Load the model from local directory if os.path.isdir(model_id): model_cache_path = os.path.join(model_id, file_name)