Skip to content

PTQ-Level Efficiency, QAT-Level Accuracy | 训练后量化的效率,量化感知训练的精度

remove require_intel_extension_for_pytorch and fix TypeError: unhashable type: 'set' (#1425)

Xin He319da040720d
diff --git a/auto_round/compressors/base.py b/auto_round/compressors/base.py
index 974a055cd..65b4b9fc1 100644
--- a/auto_round/compressors/base.py
+++ b/auto_round/compressors/base.py
@@ -2186,7 +2186,8 @@ class BaseCompressor(object):
else:
# Change this if new device is supported
if str(self.model.device) == "cpu" and (not self.device.startswith("hpu")):
- no_split_modules = getattr(self.model, "_no_split_modules", [])
+ # type(self.model._no_split_modules) changes from list to set when transformers > 5.0
+ no_split_modules = list(getattr(self.model, "_no_split_modules", []))
devices = parse_available_devices(self.device_map)
max_memory = get_max_memory()
diff --git a/test/test_cuda/integrations/test_transformers.py b/test/test_cuda/integrations/test_transformers.py
index 9544a20a3..8be385b94 100644
--- a/test/test_cuda/integrations/test_transformers.py
+++ b/test/test_cuda/integrations/test_transformers.py
@@ -19,7 +19,6 @@ import pytest
from transformers import AutoModelForCausalLM, AutoRoundConfig, AutoTokenizer
from transformers.testing_utils import (
require_accelerate,
- require_intel_extension_for_pytorch,
require_torch_gpu,
require_torch_multi_gpu,
slow,
@@ -27,6 +26,8 @@ from transformers.testing_utils import (
)
from transformers.utils import is_torch_available
+from auto_round.testing_utils import is_ipex_available
+
from ...helpers import get_model_path
if is_torch_available():
@@ -105,7 +106,7 @@ class TestAutoRound:
output_sentence = self.tokenizer.decode(output[0], skip_special_tokens=True)
assert output_sentence in self.EXPECTED_OUTPUTS
- @require_intel_extension_for_pytorch
+ @pytest.mark.skipif(not is_ipex_available(), reason="test requires intel-extension-for-pytorch")
def test_quantized_model_on_cpu(self):
"""
Simple test that checks if the quantized model is working properly
@@ -170,7 +171,7 @@ class TestAutoRound:
inputs = tokenizer(text, return_tensors="pt").to(model.device)
tokenizer.decode(model.generate(**inputs, max_new_tokens=5)[0])
- @require_intel_extension_for_pytorch
+ @pytest.mark.skipif(not is_ipex_available(), reason="test requires intel-extension-for-pytorch")
def test_convert_from_awq_cpu(self):
"""
Simple test that checks if auto-round work properly with awq format