diff --git a/awq/quantize/quantizer.py b/awq/quantize/quantizer.py index a7ae4413..5a82e5d1 100644 --- a/awq/quantize/quantizer.py +++ b/awq/quantize/quantizer.py @@ -256,7 +256,7 @@ def _search_best_scale( weight = weight.view(-1, self.group_size) # Calculates the relative magnitude of the weights within each of the quantization groups, # and rescales each group individually so that each group has weights on a 0-1 scale. - w_scale = weight.abs() / weight.abs().amax(dim=1, keepdim=True) + w_scale = weight.abs() / (weight.abs().amax(dim=1, keepdim=True) + 1e-6) # Resizes the rescaled weight matrix back up to its original dimensions w_scale = w_scale.view(org_shape) # Gets the average rescaled magnitude for each output channel