Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calculating S and Z values in the Uniform Quantization equantion #20

Open
lovodkin93 opened this issue Sep 29, 2021 · 0 comments
Open

Comments

@lovodkin93
Copy link

Hello,
I am trying to implement your quantization method in my system (Q(r)=Int(r/S) + Z), and I keep having very weird behavior.
going through your code - I saw that for weight quantization, Z=0 and for S:

n = 2 ** (num_bits - 1) - 1
if per_channel:
    scale, _ = torch.max(torch.stack([saturation_min.abs(), saturation_max.abs()], dim=1), dim=1)
    scale = torch.clamp(scale, min=1e-8) / n
else:
    scale = max(saturation_min.abs(), saturation_max.abs())
    scale = torch.clamp(scale, min=1e-8) / n

what I didn't manage to figure out is, how do you calculate saturation_min and saturation_max.
It looks like they are the max and min of the weights, but the weights are learnt - so are they the max and min before the gradient descent or after the update of the weights?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant