Skip to content

Commit 30027ff

Browse files
committed
fix tests
Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
1 parent 7dc08da commit 30027ff

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

.github/workflows/test_ipex.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ jobs:
4444
python -c "import intel_extension_for_pytorch; print(intel_extension_for_pytorch.__version__); assert intel_extension_for_pytorch.__version__.startswith('${{ matrix.torch-version }}'.replace('.*', ''))"
4545
python -c "import transformers; print(transformers.__version__); assert transformers.__version__.startswith('${{ matrix.transformers-version }}'.replace('.*', ''))"
4646
47-
- name: Test with Pytest
48-
run: |
49-
pytest tests/ipex
50-
5147
- if: ${{ matrix.torch-version != '2.4.0' }}
5248
name: Install bitsandbytes
5349
run: |
5450
pip install https://github.com/bitsandbytes-foundation/bitsandbytes/releases/download/continuous-release_multi-backend-refactor/bitsandbytes-0.45.0.dev0-py3-none-manylinux_2_24_x86_64.whl
51+
52+
- name: Test with Pytest
53+
run: |
54+
pytest tests/ipex

tests/ipex/test_modeling.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
PretrainedConfig,
3535
pipeline,
3636
set_seed,
37+
is_bitsandbytes_available,
3738
)
38-
from transformers.testing_utils import is_bitsandbytes_available, require_bitsandbytes
3939
from optimum.intel import (
4040
IPEXModel,
4141
IPEXModelForAudioClassification,
@@ -130,8 +130,8 @@ def test_pipeline(self, model_arch):
130130
_ = pipe(text)
131131
self.assertEqual(pipe.device, model.device)
132132

133-
@require_bitsandbytes
134133
@parameterized.expand(SUPPORTED_ARCHITECTURES)
134+
@unittest.skipIf(not is_bitsandbytes_available(), reason="Test requires bitsandbytes")
135135
def test_bnb(self, model_arch):
136136
model_id = MODEL_NAMES[model_arch]
137137
quantization_config = BitsAndBytesConfig(load_in_8bit=True)
@@ -248,8 +248,8 @@ def test_patched_model(self):
248248
self.assertTrue(torch.allclose(outputs.start_logits, transformers_outputs.start_logits, atol=1e-4))
249249
self.assertTrue(torch.allclose(outputs.end_logits, transformers_outputs.end_logits, atol=1e-4))
250250

251-
@require_bitsandbytes
252251
@parameterized.expand(SUPPORTED_ARCHITECTURES)
252+
@unittest.skipIf(not is_bitsandbytes_available(), reason="Test requires bitsandbytes")
253253
def test_bnb(self, model_arch):
254254
model_id = MODEL_NAMES[model_arch]
255255
set_seed(SEED)
@@ -475,8 +475,8 @@ def test_patched_model(self, model_arch):
475475
)
476476
self.assertTrue(torch.allclose(ipex_outputs.logits[0], exported_outputs.logits[0], atol=1e-7))
477477

478-
@require_bitsandbytes
479478
@parameterized.expand(SUPPORTED_ARCHITECTURES)
479+
@unittest.skipIf(not is_bitsandbytes_available(), reason="Test requires bitsandbytes")
480480
def test_bnb(self, model_arch):
481481
model_id = MODEL_NAMES[model_arch]
482482
set_seed(SEED)
@@ -765,8 +765,8 @@ def test_ipex_beam_search(self, test_name, model_arch, use_cache):
765765
self.assertIsInstance(outputs, torch.Tensor)
766766
self.assertTrue(torch.equal(outputs, transformers_outputs))
767767

768-
@require_bitsandbytes
769768
@parameterized.expand(SUPPORTED_ARCHITECTURES)
769+
@unittest.skipIf(not is_bitsandbytes_available(), reason="Test requires bitsandbytes")
770770
def test_bnb(self, model_arch):
771771
model_id = MODEL_NAMES[model_arch]
772772
set_seed(SEED)

0 commit comments

Comments
 (0)