Skip to content

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

[critic bug]remove redundant round in dq simulation (#543)

Wenhua Chengc6155fdb5e5f
diff --git a/auto_round/data_type/int.py b/auto_round/data_type/int.py
index 899abf17a..396053648 100644
--- a/auto_round/data_type/int.py
+++ b/auto_round/data_type/int.py
@@ -123,11 +123,11 @@ def quant_tensor_asym_dq(tensor, bits=4, group_size=-1, v=0, min_scale=1.0, max_
scale = torch.clamp(scale, q_scale_thresh)
wmin_m = wmin_m.view(-1, 1)
- int_w = round_ste(tensor / scale + v)
- q = torch.clamp(int_w + round_ste(wmin_m / scale), 0, maxq)
+ int_w = round_ste((tensor + wmin_m) / scale + v)
+ q = torch.clamp(int_w, 0, maxq)
qdq_result = (scale * q - wmin_m).to(tensor.dtype)
qdq_result = revert_tensor_by_pad(qdq_result, orig_shape=orig_shape, pad_len=pad_len)
- zp = round_ste(wmin_m / scale) # remove this later
+ # zp = round_ste(wmin_m / scale) # remove this later
return qdq_result, {"scale": scale, "d_scale": d_scale}, {"wmin_m": wmin_m, "d_wmin_m": d_wmin_m}