[quant][graphmode][fx] Add support for one value being quantized with different qconfigs#53586
[quant][graphmode][fx] Add support for one value being quantized with different qconfigs#53586jerryzh168 wants to merge 24 commits intogh/jerryzh168/570/basefrom
Conversation
… different qconfigs Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
… different qconfigs Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: ghstack-source-id: 3340917 Pull Request resolved: #53586
💊 CI failures summary and remediationsAs of commit ff09ea5 (more details on the Dr. CI page):
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 to the (internal) Dr. CI Users group. |
…ntized with different qconfigs" Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
… different qconfigs Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: ghstack-source-id: 8d09c22 Pull Request resolved: #53586
…ntized with different qconfigs" Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D26912676](https://our.internmc.facebook.com/intern/diff/D26912676) [ghstack-poisoned]
… different qconfigs Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: ghstack-source-id: 25f2e03 Pull Request resolved: #53586
…ntized with different qconfigs" Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D26912676](https://our.internmc.facebook.com/intern/diff/D26912676) [ghstack-poisoned]
… different qconfigs Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: ghstack-source-id: 63e0623 Pull Request resolved: #53586
…ntized with different qconfigs" Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D26912676](https://our.internmc.facebook.com/intern/diff/D26912676) [ghstack-poisoned]
… different qconfigs Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: ghstack-source-id: f1c4408 Pull Request resolved: #53586
…ntized with different qconfigs" Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D26912676](https://our.internmc.facebook.com/intern/diff/D26912676) [ghstack-poisoned]
… different qconfigs Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: ghstack-source-id: 05c05b6 Pull Request resolved: #53586
…ntized with different qconfigs" Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D26912676](https://our.internmc.facebook.com/intern/diff/D26912676) [ghstack-poisoned]
… different qconfigs Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: ghstack-source-id: a738021 Pull Request resolved: #53586
…ntized with different qconfigs" Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D26912676](https://our.internmc.facebook.com/intern/diff/D26912676) [ghstack-poisoned]
… different qconfigs Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: ghstack-source-id: 6e99e50 Pull Request resolved: #53586
…ntized with different qconfigs" Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D26912676](https://our.internmc.facebook.com/intern/diff/D26912676) [ghstack-poisoned]
…ntized with different qconfigs" Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D26912676](https://our.internmc.facebook.com/intern/diff/D26912676) [ghstack-poisoned]
vkuzo
left a comment
There was a problem hiding this comment.
makes sense, accepting to unblock, would be great to undo the additional state in the future. One idea I had when reading this PR...thoughts about this?
# map from (node.name, qconfig) to observer
self.activation_post_process_map: Dict[Tuple(str, QConfig), ObserverBase]
If the only use case for multiple observers for a node is multiple qconfigs, perhaps that can be used to deduplicate, and we wouldn't need to add an additional indices variable? I haven't thought through it deeply, more asking for your early opinion.
| if not model.training and isinstance(observer, torch.quantization.FixedQParamsFakeQuantize): | ||
| return |
There was a problem hiding this comment.
just curious, what's the context on this one? Maybe we can add a comment?
There was a problem hiding this comment.
Sure I can add a comment. reason is fixedqparams fake quant only needs to be there for training, we can either do this check here or in _find_quant.
…ntized with different qconfigs" Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D26912676](https://our.internmc.facebook.com/intern/diff/D26912676) [ghstack-poisoned]
…ntized with different qconfigs" Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D26912676](https://our.internmc.facebook.com/intern/diff/D26912676) [ghstack-poisoned]
…ntized with different qconfigs" Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D26912676](https://our.internmc.facebook.com/intern/diff/D26912676) [ghstack-poisoned]
…ntized with different qconfigs" Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D26912676](https://our.internmc.facebook.com/intern/diff/D26912676) [ghstack-poisoned]
…ntized with different qconfigs" Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D26912676](https://our.internmc.facebook.com/intern/diff/D26912676) [ghstack-poisoned]
…ntized with different qconfigs" Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D26912676](https://our.internmc.facebook.com/intern/diff/D26912676) [ghstack-poisoned]
…ntized with different qconfigs" Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D26912676](https://our.internmc.facebook.com/intern/diff/D26912676) [ghstack-poisoned]
…ntized with different qconfigs" Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D26912676](https://our.internmc.facebook.com/intern/diff/D26912676) [ghstack-poisoned]
…ntized with different qconfigs" Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D26912676](https://our.internmc.facebook.com/intern/diff/D26912676) [ghstack-poisoned]
…ntized with different qconfigs" Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D26912676](https://our.internmc.facebook.com/intern/diff/D26912676) [ghstack-poisoned]
…ntized with different qconfigs" Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D26912676](https://our.internmc.facebook.com/intern/diff/D26912676) [ghstack-poisoned]
…ntized with different qconfigs" Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D26912676](https://our.internmc.facebook.com/intern/diff/D26912676) [ghstack-poisoned]
…ntized with different qconfigs" Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D26912676](https://our.internmc.facebook.com/intern/diff/D26912676) [ghstack-poisoned]
…ntized with different qconfigs" Summary: Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D26912676](https://our.internmc.facebook.com/intern/diff/D26912676) [ghstack-poisoned]
|
This pull request has been merged in 55544cb. |
… different qconfigs (pytorch#53586) Summary: Pull Request resolved: pytorch#53586 Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16 might do some followup PRs to clean up the hacks and refactor the code. Test Plan: python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value Imported from OSS Reviewed By: vkuzo Differential Revision: D26912676 fbshipit-source-id: ae3653fd67f05870a3a9e808f491871826c555d5
Stack from ghstack:
Summary:
Previously one value can only be quantized to one dtype, this PR adds the support for quantizing one value
in the fx graph with multiple dtypes, e.g. first quantize to int8 and then float16
might do some followup PRs to clean up the hacks and refactor the code.
Test Plan:
python test/test_quantization.py TestQuantizeFx.test_multiple_qconfigs_single_value
Reviewers:
Subscribers:
Tasks:
Tags:
Differential Revision: D26912676