Skip to content

Commit 125ff36

Browse files
only round if casting to int type
Signed-off-by: Brian Dellabetta <[email protected]>
1 parent 6faab89 commit 125ff36

File tree

1 file changed

+4
-1
lines changed
  • src/compressed_tensors/quantization/utils

1 file changed

+4
-1
lines changed

src/compressed_tensors/quantization/utils/helpers.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,12 @@ def calculate_qparams(
8484
scales = (max_vals - min_vals) / float(bit_range)
8585
scales = torch.clamp(scales, min=torch.finfo(torch.float32).eps)
8686
zero_points = bit_min - (min_vals / scales)
87-
zero_points = torch.clamp(torch.round(zero_points), bit_min, bit_max)
87+
zero_points = torch.clamp(zero_points, bit_min, bit_max)
8888

8989
# match zero-points to quantized type
90+
# if casting to int, use round instead of truncate
91+
if quantization_args.type == QuantizationType.INT:
92+
zero_points = torch.round(zero_points)
9093
zero_points = zero_points.to(zp_dtype)
9194

9295
if scales.ndim == 0:

0 commit comments

Comments
 (0)