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

Add warning for transformers>=4.38 and OpenVINO 2024.0 #599

Merged
merged 5 commits into from
Mar 12, 2024
Merged
Changes from 1 commit
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
14 changes: 12 additions & 2 deletions optimum/exporters/openvino/model_patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import logging as log

from optimum.intel.utils.import_utils import (
_openvino_version,
_torch_version,
_transformers_version,
is_torch_version,
Expand All @@ -23,13 +24,14 @@


def patch_model_with_bettertransformer(model):
COLOR_RED = "\033[1;31m"
COLOR_RESET = "\033[0m"

# check that the model has not yet been pathced
if hasattr(model, "use_bettertransformer") and model.use_bettertransformer is True:
return model

if is_transformers_version("<", "4.36") or is_torch_version("<", "2.1.1"):
COLOR_RED = "\033[1;31m"
COLOR_RESET = "\033[0m"
log.warn(
COLOR_RED
+ "[WARNING] For good performance with stateful models, transformers>=4.36.2 and PyTorch>=2.1.1 are required. "
Expand All @@ -39,6 +41,14 @@ def patch_model_with_bettertransformer(model):
+ COLOR_RESET
)

if is_transformers_version(">=", "4.38") and _openvino_version < "2024.1.0-14612":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not :

Suggested change
if is_transformers_version(">=", "4.38") and _openvino_version < "2024.1.0-14612":
if is_transformers_version(">=", "4.38") and is_optimum_version("<", "2024.1.0-14612"):

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also this concerns only a subset of architectures, so would make sense to only have a warning for those wdyt ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed both. Do models based on llama keep model_type llama?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you can find the model's type list

log.warn(
COLOR_RED + f"[WARNING] Stateful models are not supported with Transformers {_transformers_version} and "
"this OpenVINO version. For good performance, consider using a nightly OpenVINO build: "
"https://docs.openvino.ai/2024/get-started/install-openvino.html. For models that do not need transformers "
"4.38+, it is also an option to downgrade transformers: `pip install transformers==4.37.2`" + COLOR_RESET
)

# model already has required SDPA implementation
if getattr(model, "_supports_sdpa", False) and getattr(model.config, "_attn_implementation", "eager") == "sdpa":
return model
Expand Down
Loading