Skip to content

Commit 0c42219

Browse files
committed
try fix test
add debug print to debug remove print, add bias to asym quant tests lint
1 parent 0337dff commit 0c42219

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

jetstream_pt/layers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ def quantize_weight_from_nn_linear(self, weight):
246246
weight, (1,), self.n_bit, self.is_symmetric_weight, self.block_size
247247
)
248248
w_dq = dequantize_tensor(w_q, scale, zp)
249-
print("check qweight cosine dist: ", _calc_cosine_dist(weight, w_dq))
250249
self._load_quantized_weights(w_q, scale, zp)
251250

252251
def forward(self, inputs):

tests/test_quantization.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,12 @@ def quantize_dequantize_weight(w, n_bit):
143143
w_q_asym, s_asym, zp_asym = quantize_tensor(
144144
w, (1,), n_bit=n_bit, symmetric=False
145145
)
146-
# print(f"w_q_asym {w_q_asym}, s_asym {s_asym}, zp_asym {zp_asym}")
147146
w_dq_asym = dequantize_tensor(w_q_asym, s_asym, zp_asym)
148-
# print(f"w_dq_asym {w_dq_asym}")
149-
# self._print_diff(w, w_dq)
150-
# self._print_diff(w, w_dq_asym)
151147
# Asymmetric is more accurate than symmetric.
152-
self.assertLess((w - w_dq_asym).norm(), (w - w_dq).norm())
148+
self.assertLess(
149+
(w - w_dq_asym).norm(),
150+
(w - w_dq).norm(),
151+
)
153152
# Blockwise quant.
154153
w_block_q, s_block, _ = quantize_tensor(
155154
w, (1,), n_bit=n_bit, symmetric=True, block_size=2
@@ -169,7 +168,9 @@ def quantize_dequantize_weight(w, n_bit):
169168
# Blockwise asymmetric is more accurate than blockwise symmetric.
170169
self.assertLess((w - w_block_asym_dq).norm(), (w - w_block_dq).norm())
171170

172-
w = torch.randn(2, 8)
171+
w = (
172+
torch.randn(2, 8) + 2
173+
) # Add a bias to normal dist to test asymmetric quant.
173174
for bit in [4, 8]:
174175
with self.subTest(bit=bit):
175176
quantize_dequantize_weight(w, bit)

0 commit comments

Comments
 (0)