Skip to content

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

Set the quant_method to auto-round by default (#2138)

Zhenzhong Xuabacdadf73eb
diff --git a/auto_round/export/formats/backends/fp8.py b/auto_round/export/formats/backends/fp8.py
index 1ceea2089..b4987b252 100644
--- a/auto_round/export/formats/backends/fp8.py
+++ b/auto_round/export/formats/backends/fp8.py
@@ -87,6 +87,6 @@ class FP8Format(OutputFormat):
inplace=inplace,
device=device,
serialization_dict=serialization_dict,
- quant_method=backend,
+ backend=backend,
**kwargs,
)
diff --git a/test/unit/test_cuda/export/test_auto_round_format.py b/test/unit/test_cuda/export/test_auto_round_format.py
index 0f8427e32..cbb185801 100644
--- a/test/unit/test_cuda/export/test_auto_round_format.py
+++ b/test/unit/test_cuda/export/test_auto_round_format.py
@@ -172,7 +172,7 @@ class TestAutoRound:
assert hasattr(tmp_layer, "weight_scale_inv")
assert tmp_layer.weight.dtype is torch.float8_e4m3fn
assert list(tmp_layer.weight_scale_inv.shape) == [16, 8]
- assert compressed_model.config.quantization_config["quant_method"] == "fp8"
+ assert compressed_model.config.quantization_config["quant_method"] == "auto-round"
assert compressed_model.config.quantization_config["weight_block_size"] == (128, 128)
if is_cuda_support_fp8():
eval_generated_prompt(quantized_model_path, device="cuda:0")
@@ -199,7 +199,7 @@ class TestAutoRound:
assert list(tmp_layer.weight_scale_inv.shape) == [16, 8]
in_memory_qconfig = compressed_model.config.quantization_config
- assert in_memory_qconfig["quant_method"] == "auto_round:fp8"
+ assert in_memory_qconfig["quant_method"] == "auto-round"
assert in_memory_qconfig["weight_block_size"] == (128, 128)
assert in_memory_qconfig["activation_scheme"] == "dynamic"
assert in_memory_qconfig["fmt"] == "e4m3"
@@ -207,7 +207,7 @@ class TestAutoRound:
with open(os.path.join(quantized_model_path, "quantization_config.json"), "r", encoding="utf-8") as f:
quantization_config = json.load(f)
- assert quantization_config["quant_method"] == "auto_round:fp8"
+ assert quantization_config["quant_method"] == "auto-round"
assert quantization_config["weight_block_size"] == [128, 128]
assert quantization_config["activation_scheme"] == "dynamic"
assert quantization_config["fmt"] == "e4m3"
diff --git a/test/unit/test_cuda/export/test_fp8_format.py b/test/unit/test_cuda/export/test_fp8_format.py
index 7b7618885..e054b3102 100644
--- a/test/unit/test_cuda/export/test_fp8_format.py
+++ b/test/unit/test_cuda/export/test_fp8_format.py
@@ -41,7 +41,7 @@ class TestAutoRoundBlockFP:
assert hasattr(tmp_layer, "weight_scale_inv")
assert tmp_layer.weight.dtype is torch.float8_e4m3fn
assert list(tmp_layer.weight_scale_inv.shape) == [16, 8]
- assert compressed_model.config.quantization_config["quant_method"] == "fp8"
+ assert compressed_model.config.quantization_config["quant_method"] == "auto-round"
assert compressed_model.config.quantization_config["weight_block_size"] == (128, 128)
# TODO: open below test after this issue is fixed.
# https://github.com/huggingface/transformers/issues/46209