Skip to content

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

fix amp (#1768)

Wenhua Cheng8288c48f5819
diff --git a/auto_round/compressors/base.py b/auto_round/compressors/base.py
index 99134c6f9..0818b0613 100644
--- a/auto_round/compressors/base.py
+++ b/auto_round/compressors/base.py
@@ -3136,7 +3136,7 @@ class BaseCompressor(object):
device: Union[str, torch.device] = "cpu",
):
autocast_ctx = (
- nullcontext() if self.amp else autocast(device_type=str(device).split(":")[0], dtype=self.amp_dtype)
+ nullcontext() if not self.amp else autocast(device_type=str(device).split(":")[0], dtype=self.amp_dtype)
)
if self.attention_mask:
tmp_attention_mask = [self.attention_mask[i] for i in indices]