We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 43492c8 commit 382af0dCopy full SHA for 382af0d
torchao/quantization/quant_primitives.py
@@ -730,6 +730,10 @@ def _choose_qparams_affine(
730
max_val_pos = max_val
731
732
if mapping_type == MappingType.SYMMETRIC.name:
733
+ # calculate smin and smax individually and choose the larger one. For example, if quant_min = -8 and quant_max = 7.
734
+ # If smin is bigger: There would be coverage on negative values down to -8, and less rounding error than the existing SYMMETRIC case.
735
+ # If smax is bigger: it covers the positive values up to 7. The round error may be bigger than the existing SYMMETRIC case.
736
+ # Either way, there's no out-of-range fp values after quantization.
737
smin = min_val_neg / float(quant_min)
738
smax = max_val_pos / float(quant_max)
739
mask = smin > smax
0 commit comments