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

upgrade ipex model to transformers 4.42.3 #812

Merged
merged 2 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .github/workflows/test_ipex.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
fail-fast: false
matrix:
python-version: [3.8, 3.9]
transformers-version: [4.39.0, 4.41.2]
transformers-version: [4.39.0, 4.42.3]
os: [ubuntu-latest]

runs-on: ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion optimum/exporters/ipex/model_patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

# Please also update in the setup.py and .github/workflows/test_ipex.yml if you change the transformers version
_TRANSFORMERS_MIN_VERSION = "4.39.0"
_TRANSFORMERS_MAX_VERSION = "4.41.2"
_TRANSFORMERS_MAX_VERSION = "4.42.3"

_IPEX_EXPORTED_GENERATION_TASKS = ("text-generation",)

Expand Down
9 changes: 5 additions & 4 deletions optimum/intel/ipex/modeling_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ class IPEXModel(OptimizedModel):
base_model_prefix = "ipex_model"
main_input_name = "input_ids"
output_name = "last_hidden_state"
_supports_cache_class = False

def __init__(
self,
Expand Down Expand Up @@ -428,6 +427,8 @@ def forward(
class IPEXModelForCausalLM(IPEXModel, GenerationMixin):
auto_model_class = AutoModelForCausalLM
export_feature = "text-generation"
_supports_cache_class = False
_is_stateful = False

def __init__(
self,
Expand Down Expand Up @@ -476,8 +477,8 @@ def __init__(
else:
self._reorder_cache = self.model_cls._reorder_cache.__get__(self)

if is_transformers_version(">=", "4.38.0") and model_type in {"llama", "phi", "persimmon"}:
self.prepare_inputs_for_generation = _prepare_inputs_for_generation_for_llama
if is_transformers_version(">=", "4.38.0") and model_type in {"llama", "phi", "persimmon", "mistral"}:
self.prepare_inputs_for_generation = _ipex_prepare_inputs_for_generation
else:
self.prepare_inputs_for_generation = self.model_cls.prepare_inputs_for_generation.__get__(self)

Expand Down Expand Up @@ -613,7 +614,7 @@ def generate(self, *args, **kwargs):
return super().generate(*args, **kwargs)


def _prepare_inputs_for_generation_for_llama(
def _ipex_prepare_inputs_for_generation(
input_ids, past_key_values=None, attention_mask=None, inputs_embeds=None, **kwargs
):
from transformers.cache_utils import Cache
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"neural-compressor": ["neural-compressor>=2.2.0", "onnxruntime<1.15.0", "accelerate"],
"openvino": ["openvino>=2023.3", "nncf>=2.11.0", "openvino-tokenizers[transformers]"],
"nncf": ["nncf>=2.11.0"],
"ipex": ["intel-extension-for-pytorch", "transformers>=4.39.0,<=4.41.2"],
"ipex": ["intel-extension-for-pytorch", "transformers>=4.39.0,<=4.42.3"],
"diffusers": ["diffusers"],
"quality": QUALITY_REQUIRE,
"tests": TESTS_REQUIRE,
Expand Down
Loading