Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Commit 45e8c28

Browse files
authored
fix symmetric zero points for unit8 quantization (#604) (#605)
1 parent 33d764a commit 45e8c28

File tree

1 file changed

+5
-0
lines changed
  • src/sparseml/pytorch/sparsification/quantization

1 file changed

+5
-0
lines changed

src/sparseml/pytorch/sparsification/quantization/helpers.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,11 @@ def fix_observer_quant_range(module: Module):
521521
fake_quantize.quant_min is None
522522
or fake_quantize.quant_max is None
523523
or (observer.quant_min is not None or observer.quant_max is not None)
524+
or ( # do not propagate default uint8 symmetric range
525+
observer.qscheme == torch.per_tensor_symmetric
526+
and fake_quantize.quant_min == 0
527+
and fake_quantize.quant_max == 255
528+
)
524529
):
525530
continue
526531
observer.quant_min = fake_quantize.quant_min

0 commit comments

Comments
 (0)