Default observer and fake-quant for backends#26627
Default observer and fake-quant for backends#26627raghuramank100 wants to merge 11 commits intogh/raghuramank100/38/basefrom
Conversation
Differential Revision: [D17518194](https://our.internmc.facebook.com/intern/diff/D17518194/) [ghstack-poisoned]
Differential Revision: [D17518194](https://our.internmc.facebook.com/intern/diff/D17518194/) ghstack-source-id: 90556162 Pull Request resolved: #26627
Differential Revision: [D17518194](https://our.internmc.facebook.com/intern/diff/D17518194/) [ghstack-poisoned]
Pull Request resolved: #26627 ghstack-source-id: 90556162 Differential Revision: [D17518194](https://our.internmc.facebook.com/intern/diff/D17518194/)
Differential Revision: [D17518194](https://our.internmc.facebook.com/intern/diff/D17518194/) [ghstack-poisoned]
Differential Revision: [D17518194](https://our.internmc.facebook.com/intern/diff/D17518194/) [ghstack-poisoned]
Pull Request resolved: #26627 ghstack-source-id: 90623342 Differential Revision: [D17518194](https://our.internmc.facebook.com/intern/diff/D17518194/)
Differential Revision: [D17518194](https://our.internmc.facebook.com/intern/diff/D17518194/) [ghstack-poisoned]
Pull Request resolved: #26627 ghstack-source-id: 90623342 Differential Revision: [D17518194](https://our.internmc.facebook.com/intern/diff/D17518194/)
| default_qat_qconfig = QConfig(activation=default_fake_quant, | ||
| weight=default_weight_fake_quant) | ||
|
|
||
| def get_default_qconfig(backend='fbgemm'): |
There was a problem hiding this comment.
technically - it's not even fbgemm, but rather fbgemm on per-CooperLake x86 :-\ . But I don't know how to make it nicer.
There was a problem hiding this comment.
I agree, perhaps just call it server and have a comment stating that you need to know about the hardware platform to ensure you are picking a good default?
There was a problem hiding this comment.
Actually with mkl-dnn not sure how to improve on this, so leaving this as is for now
| def get_default_qconfig(backend='fbgemm'): | ||
| if backend == 'fbgemm': | ||
| qconfig = QConfig(activation=HistogramObserver.with_args(reduce_range=True), | ||
| weight=default_per_channel_weight_observer) |
There was a problem hiding this comment.
so we do per-channel only for fbgemm, not for mobile?
There was a problem hiding this comment.
Mobile does not support per-channel kernels currently. If and when QNNPACK supports it, we can change that.
torch/quantization/QConfig.py
Outdated
|
|
||
| def get_default_qat_qconfig(backend='fbgemm'): | ||
| if backend == 'fbgemm': | ||
| qconfig = QConfig(activation=FakeQuantize.with_args(observer=default_l2_observer(reduce_range = True), |
There was a problem hiding this comment.
I think this will create the same instance of observer for each FakeQuant - you probably need double with_args, but it gets ugly...
Differential Revision: [D17518194](https://our.internmc.facebook.com/intern/diff/D17518194/) [ghstack-poisoned]
Pull Request resolved: #26627 ghstack-source-id: 90704697 Differential Revision: [D17518194](https://our.internmc.facebook.com/intern/diff/D17518194/)
Differential Revision: [D17518194](https://our.internmc.facebook.com/intern/diff/D17518194/) [ghstack-poisoned]
Differential Revision: [D17518194](https://our.internmc.facebook.com/intern/diff/D17518194/) [ghstack-poisoned]
Pull Request resolved: #26627 ghstack-source-id: 90979560 Differential Revision: [D17518194](https://our.internmc.facebook.com/intern/diff/D17518194/)
dzhulgakov
left a comment
There was a problem hiding this comment.
Feel free to land this PR before the others (reorder the stack) as it's useful
Differential Revision: [D17518194](https://our.internmc.facebook.com/intern/diff/D17518194/) [ghstack-poisoned]
Pull Request resolved: #26627 ghstack-source-id: 90997604 Differential Revision: [D17518194](https://our.internmc.facebook.com/intern/diff/D17518194/)
Differential Revision: [D17518194](https://our.internmc.facebook.com/intern/diff/D17518194/) [ghstack-poisoned]
Differential Revision: [D17518194](https://our.internmc.facebook.com/intern/diff/D17518194/) [ghstack-poisoned]
Pull Request resolved: #26627 ghstack-source-id: 91008337 Differential Revision: [D17518194](https://our.internmc.facebook.com/intern/diff/D17518194/)
|
This pull request has been merged in d5298b6. |
Summary: Pull Request resolved: #26627 ghstack-source-id: 91008337 Test Plan: buck test caffe2/test:quantization -- --print-passing-details Differential Revision: D17518194 fbshipit-source-id: 1eb8a7a85dc811c4ee5228d68563abb157613ceb
Summary: Pull Request resolved: #26627 ghstack-source-id: 91008337 Test Plan: buck test caffe2/test:quantization -- --print-passing-details Differential Revision: D17518194 fbshipit-source-id: 1eb8a7a85dc811c4ee5228d68563abb157613ceb
Summary: Pull Request resolved: #26627 ghstack-source-id: 91008337 Test Plan: buck test caffe2/test:quantization -- --print-passing-details Differential Revision: D17518194 fbshipit-source-id: 1eb8a7a85dc811c4ee5228d68563abb157613ceb
Summary: Pull Request resolved: #26627 ghstack-source-id: 91008337 Test Plan: buck test caffe2/test:quantization -- --print-passing-details Differential Revision: D17518194 fbshipit-source-id: 1eb8a7a85dc811c4ee5228d68563abb157613ceb
Summary: Pull Request resolved: #26627 ghstack-source-id: 91008337 Test Plan: buck test caffe2/test:quantization -- --print-passing-details Differential Revision: D17518194 fbshipit-source-id: 1eb8a7a85dc811c4ee5228d68563abb157613ceb
Summary: Pull Request resolved: pytorch#26627 ghstack-source-id: 91008337 Test Plan: buck test caffe2/test:quantization -- --print-passing-details Differential Revision: D17518194 fbshipit-source-id: 1eb8a7a85dc811c4ee5228d68563abb157613ceb
Stack from ghstack:
Differential Revision: D17518194