Skip to content

Commit 55c10db

Browse files
committed
fix: added zero_point in [0,nlvl] assert in asymmetric_linear_quanitzation_params
Signed-off-by: Brandon Groth <[email protected]>
1 parent 5d5cbe2 commit 55c10db

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

fms_mo/quant_refactor/linear_utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,11 @@ def asymmetric_linear_quantization_params(
296296
zero_point = zero_point.round()
297297
if signed:
298298
zero_point += 2 ** (num_bits - 1)
299+
300+
# Ensure zp in [0, n_levels]
301+
zp_bounds = torch.all((zero_point > 0) & (zero_point < n_levels))
302+
assert zp_bounds, "Asymmetric zero points should be in [0, 2**bits-1]"
303+
299304
return n_levels, scale, zero_point
300305

301306

0 commit comments

Comments
 (0)