Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
chenfucn committed Oct 30, 2023
1 parent c628dbd commit 80eab05
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ def quantize_blockwise_4bits_ref(matrix_float: npt.ArrayLike, block_size: int, i
block_idx = k_id // block_size
scales[n, block_idx] = scale
zp_pair = zero_point[n, block_idx // 2]
zero_point[n, block_idx // 2] = ((zp_pair & 0x0F) | (zp << 4)) if (block_idx & 1) else ((zp_pair & 0xF0) | zp)
zero_point[n, block_idx // 2] = ((zp_pair & 0x0F) | (zp << 4)) \
if (block_idx & 1) else ((zp_pair & 0xF0) | zp)

blk_int0 = np.clip(
np.round(np.float32(matrix_float_padded[n, k_id : k_id + block_size : 2] * reciprocal_scale + zp)),
Expand Down Expand Up @@ -120,15 +121,15 @@ def test_quantize_blockwise_4bits(self):
dequantize_blockwise_4bits(
quant_value_ref[c, k],
scales_ref[c, k],
(zero_point_ref[c, k//2] >> 4)
(zero_point_ref[c, k // 2] >> 4)
if (k & 1)
else (zero_point_ref[c, k//2] & 0x0F),
else (zero_point_ref[c, k // 2] & 0x0F),
min(block_size, rows - k * block_size),
),
dequantize_blockwise_4bits(
quant_value[c, k],
scales[c, k],
(zero_point[c, k//2] >> 4) if (k & 1) else (zero_point[c, k//2] & 0x0F),
(zero_point[c, k // 2] >> 4) if (k & 1) else (zero_point[c, k // 2] & 0x0F),
min(block_size, rows - k * block_size),
),
atol=1.2 * abs(scales[c, k]),
Expand Down

0 comments on commit 80eab05

Please sign in to comment.