Serialization and range reduction support for Fake Quant/Observer#26519
Serialization and range reduction support for Fake Quant/Observer#26519raghuramank100 wants to merge 12 commits intogh/raghuramank100/28/basefrom
Conversation
Differential Revision: [D17217408](https://our.internmc.facebook.com/intern/diff/D17217408/) [ghstack-poisoned]
Differential Revision: [D17217408](https://our.internmc.facebook.com/intern/diff/D17217408/) ghstack-source-id: 90463022 Pull Request resolved: #26519
…bserver" Differential Revision: [D17217408](https://our.internmc.facebook.com/intern/diff/D17217408/) [ghstack-poisoned]
…bserver" Differential Revision: [D17217408](https://our.internmc.facebook.com/intern/diff/D17217408/) [ghstack-poisoned]
…bserver" Differential Revision: [D17217408](https://our.internmc.facebook.com/intern/diff/D17217408/) [ghstack-poisoned]
| default_fake_quant = FakeQuantize | ||
| def _save_to_state_dict(self, destination, prefix, keep_vars): | ||
| super(FakeQuantize, self)._save_to_state_dict(destination, prefix, keep_vars) | ||
| destination[prefix + 'quant_min'] = self.quant_min |
There was a problem hiding this comment.
interesting, looks like we have a legit use cases for non-Tensor register_buffer (cc @gchanan). No action now, just interesting
…bserver" Differential Revision: [D17217408](https://our.internmc.facebook.com/intern/diff/D17217408/) [ghstack-poisoned]
…bserver" Differential Revision: [D17217408](https://our.internmc.facebook.com/intern/diff/D17217408/) [ghstack-poisoned]
Pull Request resolved: #26519 ghstack-source-id: 90622881 Differential Revision: [D17217408](https://our.internmc.facebook.com/intern/diff/D17217408/)
…bserver" Differential Revision: [D17217408](https://our.internmc.facebook.com/intern/diff/D17217408/) [ghstack-poisoned]
…bserver" Differential Revision: [D17217408](https://our.internmc.facebook.com/intern/diff/D17217408/) [ghstack-poisoned]
Pull Request resolved: #26519 ghstack-source-id: 90701068 Differential Revision: [D17217408](https://our.internmc.facebook.com/intern/diff/D17217408/)
…bserver" Differential Revision: [D17217408](https://our.internmc.facebook.com/intern/diff/D17217408/) [ghstack-poisoned]
Pull Request resolved: pytorch#26519 ghstack-source-id: 90622881 Differential Revision: [D17217408](https://our.internmc.facebook.com/intern/diff/D17217408/)
…bserver" Differential Revision: [D17217408](https://our.internmc.facebook.com/intern/diff/D17217408/) [ghstack-poisoned]
dzhulgakov
left a comment
There was a problem hiding this comment.
Looks good, please address nits before landing
| @@ -13,23 +12,20 @@ class FakeQuantize(Module): | |||
| `calcqparam`: A function that calculates quantization parameters | |||
There was a problem hiding this comment.
the docstring is way out of date - please update
There was a problem hiding this comment.
Good catch, will update
| self.ch_axis = ch_axis | ||
| self.min_vals = None | ||
| self.max_vals = None | ||
| self.register_buffer('min_vals', None) |
There was a problem hiding this comment.
maybe just register empty tensor? (torch.tensor([])). Then you don't need to override _load_from_state_dict?
There was a problem hiding this comment.
Will try that
There was a problem hiding this comment.
Doesnt work, so sticking with current approach
…bserver" Differential Revision: [D17217408](https://our.internmc.facebook.com/intern/diff/D17217408/) [ghstack-poisoned]
|
@pytorchbot Retest this please |
|
@pytorchbot retest this please |
1 similar comment
|
@pytorchbot retest this please |
…bserver" Differential Revision: [D17217408](https://our.internmc.facebook.com/intern/diff/D17217408/) [ghstack-poisoned]
Pull Request resolved: #26519 ghstack-source-id: 90895631 Differential Revision: [D17217408](https://our.internmc.facebook.com/intern/diff/D17217408/)
|
This pull request has been merged in b0a2f6f. |
…torch#26519) Summary: Pull Request resolved: pytorch#26519 ghstack-source-id: 90895631 Test Plan: buck test caffe2/test:quantization -- 'test_histogram_observer \(test_quantization\.ObserverTest\)' --print-passing-details and buck test caffe2/test:fake_quant -- 'test_fq_serializable \(test_fake_quant\.TestFakeQuantizePerTensorAffine\)' --print-passing-details Differential Revision: D17217408 fbshipit-source-id: 0da7efdcdae0c065dd035c5dd2b6a78231545ece
Pull Request resolved: pytorch/pytorch#26519 ghstack-source-id: 90704280 Differential Revision: [D17217408](https://our.internmc.facebook.com/intern/diff/D17217408/)
Pull Request resolved: pytorch/pytorch#26519 ghstack-source-id: 90905579 Differential Revision: [D17217408](https://our.internmc.facebook.com/intern/diff/D17217408/)
…torch#26519) Summary: Pull Request resolved: pytorch#26519 ghstack-source-id: 90895631 Test Plan: buck test caffe2/test:quantization -- 'test_histogram_observer \(test_quantization\.ObserverTest\)' --print-passing-details and buck test caffe2/test:fake_quant -- 'test_fq_serializable \(test_fake_quant\.TestFakeQuantizePerTensorAffine\)' --print-passing-details Differential Revision: D17217408 fbshipit-source-id: 0da7efdcdae0c065dd035c5dd2b6a78231545ece
Stack from ghstack:
Differential Revision: D17217408