Skip to content

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

[W4A8]Fix Packing (#648)

Yi Liua5fa835e2d1b
diff --git a/auto_round/export/export_to_autoround/qlinear_triton_act.py b/auto_round/export/export_to_autoround/qlinear_triton_act.py
index 59a238c75..3fd951302 100644
--- a/auto_round/export/export_to_autoround/qlinear_triton_act.py
+++ b/auto_round/export/export_to_autoround/qlinear_triton_act.py
@@ -141,8 +141,9 @@ class QuantLinear(nn.Module):
else:
repeat_zeros = zeros
- intweight = torch.round(W.to(device) / repeat_scales[:,:W.shape[1]] + repeat_zeros[:,:W.shape[1]])
-
+ intweight = torch.round(W.to(device) / repeat_scales[:, : W.shape[1]] + repeat_zeros[:, : W.shape[1]]).to(
+ torch.int32
+ )
del repeat_scales
intweight = intweight.reshape(-1, intweight.shape[1] // 32 * self.bits, 32 // self.bits)
order_map = torch.arange(0, 32 // self.bits, device=device) * self.bits