-
Notifications
You must be signed in to change notification settings - Fork 227
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
Fix wrong scale eps applied #1770
base: main
Are you sure you want to change the base?
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/1770
Note: Links to docs will display an error until the docs builds have been completed. ❌ 2 New FailuresAs of commit beab4c1 with merge base 7963f9c ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
ebc22f4
to
1acb897
Compare
Please don't merge yet, this isn't good enough... |
1acb897
to
a66f34d
Compare
Ok, I think it could be reviewed now. Basically, in Now, this is all probably an overkill: it's pretty much relevant only for float16 inputs, it could be that it fixes only one of several quantization code paths, etc. So maybe I just put this in my #1671 for now, specifically for the quantization type where I've encountered the issue while I was testing it? |
Closing as the issue is rather improbable to encounter in practice. |
a66f34d
to
ee7884c
Compare
ee7884c
to
535ac19
Compare
@@ -944,10 +944,16 @@ def _choose_qparams_affine( | |||
else: | |||
zero_point = torch.full_like(scale, int((quant_max + quant_min + 1) / 2)) | |||
scale = torch.clamp(scale, min=eps) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we modify eps
to the right value instead of trying to clamp twice? Right now eps
is set to torch.finfo(input.dtype).eps
, it seems like that just isn't the right way to set it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO we should fix eps
instead of clamping twice
By the way, thanks for fixing this! I think this PR should include a test case which fails before and passes after these changes. |
535ac19
to
51d3ca0
Compare
Added a test case - without changes in I see you point about clamping twice. I need to see if some further changes in (The |
9a43a80
to
42a2347
Compare
Pushed an update, I think this is it. Namely, in
|
42a2347
to
beab4c1
Compare
Fixes #1766.