Skip to content

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

Add a warning for improper export formats. (#265)

wenhuach21be32686be105
diff --git a/README.md b/README.md
index c9637df2e..8173e6eb8 100644
--- a/README.md
+++ b/README.md
@@ -187,7 +187,7 @@ models.
Additionally, symmetric quantization tends to perform poorly at 2-bit precision.
**AutoAWQ format**: This format is well-suited for asymmetric 4-bit quantization on CUDA devices and is widely adopted
-within the community, only 4-bits asymmetric quantization is supported. Asymmetric quantization typically improves
+within the community, only 4-bits quantization is supported. Asymmetric quantization typically improves
accuracy but may reduce inference speed. It features
specialized layer fusion tailored for Llama models.
@@ -216,7 +216,7 @@ print(tokenizer.decode(model.generate(**inputs, max_new_tokens=50)[0]))
**HPU**: docker image with Gaudi Software Stack is recommended. More details can be found
in [Gaudi Guide](https://docs.habana.ai/en/latest/).
-**CUDA**: git clone https://github.com/intel/auto-round.git && cd auto-round && pip install -vvv --no-build-isolation
+**CUDA**: git clone https://github.com/intel/auto-round.git && cd auto-round && pip install --no-build-isolation
-e .
#### CPU/HPU/CUDA on 0.3.0+
diff --git a/auto_round/autoround.py b/auto_round/autoround.py
index e03278bfd..d87e46b11 100644
--- a/auto_round/autoround.py
+++ b/auto_round/autoround.py
@@ -603,11 +603,11 @@ class AutoRound(object):
torch.cuda.empty_cache()
except:
logger.info("switch to cpu to cache inputs")
- if "lm_head" in self.layer_config and self.layer_config["lm_head"]["bits"]<8:
+ if "lm_head" in self.layer_config and self.layer_config["lm_head"]["bits"] < 8:
logger.warning(f"we strongly recommend using additional CUDA/HPU devices,e.g. "
- f"'CUDA_VISIBLE_DEVICES=0,1 python xxx',"
- f" for optimal performance during calibration when enabling lm-head quantization. "
- f"Otherwise, the process may be significantly slower.")
+ f"'CUDA_VISIBLE_DEVICES=0,1 python xxx',"
+ f" for optimal performance during calibration when enabling lm-head quantization. "
+ f"Otherwise, the process may be significantly slower.")
self.model = mv_module_from_gpu(self.model, self.low_cpu_mem_usage)
torch.cuda.empty_cache()
all_inputs = self.cache_inter_data(
@@ -1168,6 +1168,16 @@ class AutoRound(object):
logger.error(f"export format only supports {EXPORT_FORMAT.keys()}")
exit()
save_quantized_as_format = EXPORT_FORMAT.get(format)
+ if "gptq" in format and not self.sym:
+ logger.warning(
+ "The asymmetrical kernel of the GPTQ format may result in a noticeable accuracy drop,"
+ " particularly for 2-bit quantization and smaller models."
+ " We recommend exporting to either the AutoAWQ format (4 bits) or "
+ "the AutoRound format (2 bits) to enhance performance."
+ )
+ if "awq" in format and not self.bits == 4:
+ raise ValueError("The AWQ format only supports W4 asym quantization ")
+
serialization_keys = [
"bits",
"group_size",