Skip to content

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

fix autogptq exporting issue

wenhuach21d413128f5e01
diff --git a/auto_round/export/export_to_autogptq.py b/auto_round/export/export_to_autogptq.py
index 571048c1c..39e926ecf 100644
--- a/auto_round/export/export_to_autogptq.py
+++ b/auto_round/export/export_to_autogptq.py
@@ -102,7 +102,6 @@ def save_quantized_to_autogptq(model, save_dir: str, bits=4, group_size=128, sym
model_save_name = model_base_name + ".bin"
torch.save(model.state_dict(), join(save_dir, model_save_name))
- model.config.save_pretrained(save_dir)
from auto_gptq.modeling._base import BaseQuantizeConfig
quantization_config = BaseQuantizeConfig(bits=bits, group_size=group_size, desc_act=False, sym=sym,
@@ -122,6 +121,10 @@ def save_quantized_to_autogptq(model, save_dir: str, bits=4, group_size=128, sym
with open(join(save_dir, "quantize_config.json"), "w", encoding="utf-8") as f:
json.dump(config_dict, f, indent=2)
+ config_dict["quant_method"] = "gptq" ##hf transformers could only recognize this value
+ model.config.quantization_config = config_dict
+ model.config.save_pretrained(save_dir)
+