-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[quant] Make PerChannel Observer work with float qparams #42690
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
Conversation
Summary: Add implementation for new qscheme per_channel_affine_float_qparams in observer Test Plan: python test/test_quantization.py TestObserver.test_per_channel_observers Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
💊 CI failures summary and remediationsAs of commit 3086331 (more details on the Dr. CI page): 💚 💚 Looks good so far! There are no failures yet. 💚 💚 This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions on the GitHub issue tracker or post in the (internal) Dr. CI Users group. This comment has been revised 45 times. |
torch/quantization/observer.py
Outdated
| min_val = torch.min(min_val, torch.zeros_like(min_val)) | ||
| max_val = torch.max(max_val, torch.zeros_like(max_val)) |
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.
this code was a bit confusing (before this PR). Maybe we can rename these something like min_val_neg and max_val_pos in the rest of the function?
torch/quantization/observer.py
Outdated
| else: | ||
| zero_point = zero_point.new_full(zero_point.size(), 128) | ||
| elif self.qscheme == torch.per_channel_affine_float_qparams: | ||
| scale = (orig_max - orig_min) / float(qmax - qmin) |
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.
ideally this should be max_val - min_val, since that's what is actually happening. The other qschemes are not using observed min and max directly.
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.
Right. Maybe I can rename the other usages so I can use max_val - min_val directly here
Summary: Add implementation for new qscheme per_channel_affine_float_qparams in observer Test Plan: python test/test_quantization.py TestObserver.test_per_channel_observers Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
Summary: Add implementation for new qscheme per_channel_affine_float_qparams in observer Test Plan: python test/test_quantization.py TestObserver.test_per_channel_observers Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
Summary: Add implementation for new qscheme per_channel_affine_float_qparams in observer Test Plan: python test/test_quantization.py TestObserver.test_per_channel_observers Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
Summary: Add implementation for new qscheme per_channel_affine_float_qparams in observer Test Plan: python test/test_quantization.py TestObserver.test_per_channel_observers Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
Summary: Add implementation for new qscheme per_channel_affine_float_qparams in observer Test Plan: python test/test_quantization.py TestObserver.test_per_channel_observers Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D23070633](https://our.internmc.facebook.com/intern/diff/D23070633) [ghstack-poisoned]
Summary: Add implementation for new qscheme per_channel_affine_float_qparams in observer Test Plan: python test/test_quantization.py TestObserver.test_per_channel_observers Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D23070633](https://our.internmc.facebook.com/intern/diff/D23070633) [ghstack-poisoned]
Summary: Add implementation for new qscheme per_channel_affine_float_qparams in observer Test Plan: python test/test_quantization.py TestObserver.test_per_channel_observers Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D23070633](https://our.internmc.facebook.com/intern/diff/D23070633) [ghstack-poisoned]
|
This pull request has been merged in 816d37b. |
Summary: Add implementation for new qscheme per_channel_affine_float_qparams in observer Test Plan: python test/test_quantization.py TestObserver.test_per_channel_observers Reviewers: Subscribers: Tasks: Tags: ghstack-source-id: 3788f49 Pull Request resolved: pytorch/pytorch#42690
Stack from ghstack:
Summary:
Add implementation for new qscheme per_channel_affine_float_qparams in observer
Test Plan:
python test/test_quantization.py TestObserver.test_per_channel_observers
Reviewers:
Subscribers:
Tasks:
Tags:
Differential Revision: D23070633