Skip to content

Commit

Permalink
set torch minimum version for compiling
Browse files Browse the repository at this point in the history
Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
  • Loading branch information
jiqing-feng committed Nov 27, 2024
1 parent 5b71206 commit 7717572
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions optimum/intel/ipex/modeling_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@

_IPEX_SUPPORT_MODEL_TYPES = ("llama", "bert", "vit", "falcon", "gpt2")
_IPEX_EXPORTED_GENERATION_METHODS = ("sample", "greedy_search", "beam_sample", "beam_search", "assisted_generation")
# TODO: Fix these models compile issue in torch 2.6
_IPEX_MINIMUM_VERSION_FOR_COMPILE = "2.5.0"
# TODO: Already fixed in torch 2.6, will enable when torch upgrading to 2.6
_COMPILE_NOT_READY_MODEL_TYPES = ("electra", "roformer", "beit")


Expand Down Expand Up @@ -109,6 +110,7 @@ def __init__(
model.device.type == "cpu"
and self.export_feature not in _IPEX_EXPORTED_GENERATION_TASKS
and config.model_type not in _COMPILE_NOT_READY_MODEL_TYPES
and is_ipex_version(">=", _IPEX_MINIMUM_VERSION_FOR_COMPILE)
):
from torch._inductor import config

Expand Down Expand Up @@ -145,7 +147,9 @@ def _from_pretrained(
- The path to a directory containing the model weights.
"""
if getattr(config, "torchscript", False):
logger.warning("IPEXModel will not support torch script model in the future.")
logger.warning(
"IPEXModel will not support torch script model in the future, fallback to TSModelForCausalLM"
)
return TSModelForCausalLM.from_pretrained(model_id, **kwargs)

model = cls.auto_model_class.from_pretrained(model_id, **kwargs)
Expand Down

0 comments on commit 7717572

Please sign in to comment.