Skip to content

Commit aefabf0

Browse files
authored
Enable ITREX v1.4.2 for torch 2.3.0+cpu (#733)
* Enable ITREX v1.4.2 for specific torch version * fix * fix style * update itrex version * fix * fix warning
1 parent bfd0767 commit aefabf0

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

.github/workflows/test_inc.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ jobs:
3232
python -m pip install --upgrade pip
3333
pip install cmake
3434
pip install py-cpuinfo
35-
pip install torch==2.2.2 torchvision==0.17.2 torchaudio==2.2.2 --index-url https://download.pytorch.org/whl/cpu
35+
pip install torch==2.3.0 torchaudio==2.3.0 torchvision==0.18 --index-url https://download.pytorch.org/whl/cpu
3636
pip install .[neural-compressor,diffusers,tests]
37-
pip install intel-extension-for-transformers==1.4.1
37+
pip install intel-extension-for-transformers
3838
pip install peft
3939
4040
- name: Test with Pytest
@@ -43,7 +43,6 @@ jobs:
4343
- name: Test IPEX
4444
run: |
4545
pip uninstall -y intel-extension-for-transformers
46-
pip install torch==2.3.0 torchaudio==2.3.0 torchvision==0.18 --extra-index-url https://download.pytorch.org/whl/cpu
4746
pip install intel-extension-for-pytorch==2.3.0
4847
pytest tests/neural_compressor/test_ipex.py
4948

optimum/intel/neural_compressor/quantization.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from neural_compressor.model.onnx_model import ONNXModel
3030
from neural_compressor.model.torch_model import IPEXModel, PyTorchModel
3131
from neural_compressor.quantization import fit
32+
from packaging.version import parse
3233
from torch.utils.data import DataLoader, RandomSampler
3334
from transformers import (
3435
DataCollator,
@@ -79,8 +80,6 @@
7980
)
8081

8182

82-
_ITREX_EXCLUDED_VERSION = "1.4.2"
83-
8483
if is_itrex_available():
8584
if is_itrex_version("<", ITREX_MINIMUM_VERSION):
8685
raise ImportError(
@@ -229,10 +228,12 @@ def quantize(
229228

230229
# ITREX Weight Only Quantization
231230
if not isinstance(quantization_config, PostTrainingQuantConfig):
232-
if is_itrex_version("==", _ITREX_EXCLUDED_VERSION):
231+
if is_itrex_version("==", "1.4.2") and (
232+
is_torch_version("!=", "2.3.0") or parse(_torch_version).local != "cpu"
233+
):
233234
raise ImportError(
234-
f"Found an incompatible version of `intel-extension-for-transformers`. Found version {_itrex_version}, "
235-
f"but {_ITREX_EXCLUDED_VERSION} is not compatible."
235+
f"Found an incompatible version of `intel-extension-for-transformers` and `torch`. Found version itrex {_itrex_version} and torch {_torch_version}, "
236+
f"but only torch 2.3.0+cpu is compatible with ITREX v1.4.2."
236237
)
237238

238239
# check neural-compressor version

0 commit comments

Comments
 (0)