Skip to content

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

fix XPU CI hang issue (#1261)

Xin He57af5b7f9bae
diff --git a/test/test_xpu/test_autoround.py b/test/test_xpu/test_autoround.py
index d857e3bdc..6c9d65c83 100644
--- a/test/test_xpu/test_autoround.py
+++ b/test/test_xpu/test_autoround.py
@@ -14,6 +14,7 @@ from ..helpers import get_model_path
class TestAutoRoundXPU:
@classmethod
def setup_class(self):
+ self.device = "xpu"
pass
@classmethod
@@ -58,7 +59,7 @@ class TestAutoRoundXPU:
def test_awq_format(self, dataloader):
model_name = get_model_path("facebook/opt-125m")
model = AutoModelForCausalLM.from_pretrained(
- model_name, torch_dtype="auto", trust_remote_code=True, device_map="xpu"
+ model_name, torch_dtype="auto", trust_remote_code=True, device_map=self.device
)
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
bits, group_size, sym = 4, 128, True
@@ -75,11 +76,10 @@ class TestAutoRoundXPU:
quantized_model_path = "./saved"
autoround.quantize_and_save(output_dir=quantized_model_path, format="auto_round:auto_awq")
- quantized_model_path = "./saved"
quantization_config = AutoRoundConfig(backend="auto")
-
+ # device_map="auto" doesn't work, must use "xpu"
model = AutoModelForCausalLM.from_pretrained(
- quantized_model_path, device_map="auto", quantization_config=quantization_config
+ quantized_model_path, device_map=self.device, quantization_config=quantization_config
)
tokenizer = AutoTokenizer.from_pretrained(quantized_model_path)
text = "There is a girl who likes adventure,"