-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[quant][graphmode] insert_quant_dequant work with qconfig_dict #25127
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: Extend insert_quant_dequant pass to go through forward function graphs Test Plan: ``` python test/test_jit.py 'TestJit.test_insert_quant_dequant' python test/test_quantizer.py ``` Reviewers: pt1quant Subscribers: Tasks: Tags:
…dict" Summary: Extend insert_quant_dequant pass to go through forward function graphs Test Plan: ``` python test/test_jit.py 'TestJit.test_insert_quant_dequant' python test/test_quantizer.py ``` Reviewers: pt1quant Subscribers: Tasks: Tags:
…dict" Summary: Extend insert_quant_dequant pass to go through forward function graphs Test Plan: ``` python test/test_jit.py 'TestJit.test_insert_quant_dequant' python test/test_quantizer.py ``` Reviewers: pt1quant Subscribers: Tasks: Tags:
…dict" Summary: Extend insert_quant_dequant pass to go through forward function graphs Test Plan: ``` python test/test_jit.py 'TestJit.test_insert_quant_dequant' python test/test_quantizer.py ``` Reviewers: pt1quant Subscribers: Tasks: Tags:
…dict" Summary: Extend insert_quant_dequant pass to go through forward function graphs Test Plan: ``` python test/test_jit.py 'TestJit.test_insert_quant_dequant' python test/test_quantizer.py ``` Reviewers: pt1quant Subscribers: Tasks: Tags:
…dict" Summary: Extend insert_quant_dequant pass to go through forward function graphs Test Plan: ``` python test/test_jit.py 'TestJit.test_insert_quant_dequant' python test/test_quantizer.py ``` Reviewers: pt1quant Subscribers: Tasks: Tags:
…dict" Summary: Extend insert_quant_dequant pass to go through forward function graphs Test Plan: ``` python test/test_jit.py 'TestJit.test_insert_quant_dequant' python test/test_quantizer.py ``` Reviewers: pt1quant Subscribers: Tasks: Tags: Differential Revision: [D17001137](https://our.internmc.facebook.com/intern/diff/D17001137)
…dict" Summary: Extend insert_quant_dequant pass to go through forward function graphs Test Plan: ``` python test/test_jit.py 'TestJit.test_insert_quant_dequant' python test/test_quantizer.py ``` Reviewers: pt1quant Subscribers: Tasks: Tags: Differential Revision: [D17001137](https://our.internmc.facebook.com/intern/diff/D17001137)
…dict" Summary: Extend insert_quant_dequant pass to go through forward function graphs Test Plan: ``` python test/test_jit.py 'TestJit.test_insert_quant_dequant' python test/test_quantizer.py ``` Reviewers: pt1quant Subscribers: Tasks: Tags: Differential Revision: [D17001137](https://our.internmc.facebook.com/intern/diff/D17001137)
…dict" Summary: Extend insert_quant_dequant pass to go through forward function graphs Test Plan: ``` python test/test_jit.py 'TestJit.test_insert_quant_dequant' python test/test_quantizer.py ``` Reviewers: pt1quant Subscribers: Tasks: Tags: Differential Revision: [D17001137](https://our.internmc.facebook.com/intern/diff/D17001137)
…dict" Summary: Extend insert_quant_dequant pass to go through forward function graphs Test Plan: ``` python test/test_jit.py 'TestJit.test_insert_quant_dequant' python test/test_quantizer.py ``` Reviewers: pt1quant Subscribers: Tasks: Tags: Differential Revision: [D17001137](https://our.internmc.facebook.com/intern/diff/D17001137)
…dict" Summary: Extend insert_quant_dequant pass to go through forward function graphs Test Plan: ``` python test/test_jit.py 'TestJit.test_insert_quant_dequant' python test/test_quantizer.py ``` Reviewers: pt1quant Subscribers: Tasks: Tags: Differential Revision: [D17001137](https://our.internmc.facebook.com/intern/diff/D17001137)
…dict" Summary: Extend insert_quant_dequant pass to go through forward function graphs Test Plan: ``` python test/test_jit.py 'TestJit.test_insert_quant_dequant' python test/test_quantizer.py ``` Reviewers: pt1quant Subscribers: Tasks: Tags: Differential Revision: [D17001137](https://our.internmc.facebook.com/intern/diff/D17001137)
…dict" Summary: Extend insert_quant_dequant pass to go through forward function graphs Test Plan: ``` python test/test_jit.py 'TestJit.test_insert_quant_dequant' python test/test_quantizer.py ``` Reviewers: pt1quant Subscribers: Tasks: Tags: Differential Revision: [D17001137](https://our.internmc.facebook.com/intern/diff/D17001137)
…dict" Summary: Extend insert_quant_dequant pass to go through forward function graphs Test Plan: ``` python test/test_jit.py 'TestJit.test_insert_quant_dequant' python test/test_quantizer.py ``` Reviewers: pt1quant Subscribers: Tasks: Tags: Differential Revision: [D17001137](https://our.internmc.facebook.com/intern/diff/D17001137)
ZolotukhinM
left a comment
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.
I think we should not duplicate the logic from insertObservers for figuring out what values we need to quantize. Instead we should just look for the corresponding CallMethod nodes and replace them with Q-DQ nodes. This logic was introduced earlier, but earlier it was slightly better "justified" than now.
|
|
||
| } // namespace | ||
|
|
||
| TORCH_API void InsertObservers( |
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.
Please avoid unnecessary code movements to make the diffs smaller. I'd suggest undoing this part of this PR.
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.
oh the reason is I'm separating out a InsertObserversImpl function and put that into a anonymous namespace
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.
Ah, ok. Please try to split such changes in future as they are not related to what the commit message says.
|
|
||
| for (Value* v : values_to_quantize) { | ||
| if (v->type()->isSubtypeOf(TensorType::get())) { | ||
| if (v->node()->kind() == prim::CallMethod && v->node()->s(attr::name) == "forward") { |
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.
Do we need to replicate the logic of insertObservers in the loop above? We had to do it previously, but now we can just rely on having prim::CallMethod nodes and replace them with Q-DQ?
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.
or should I remove these in a separate PR? that change seems unrelated actually
…dict" Summary: Extend insert_quant_dequant pass to go through forward function graphs Test Plan: ``` python test/test_jit.py 'TestJit.test_insert_quant_dequant' python test/test_quantizer.py ``` Reviewers: pt1quant Subscribers: Tasks: Tags: Differential Revision: [D17001137](https://our.internmc.facebook.com/intern/diff/D17001137)
…dict" Summary: Extend insert_quant_dequant pass to go through forward function graphs Test Plan: ``` python test/test_jit.py 'TestJit.test_insert_quant_dequant' python test/test_quantizer.py ``` Reviewers: pt1quant Subscribers: Tasks: Tags: Differential Revision: [D17001137](https://our.internmc.facebook.com/intern/diff/D17001137)
…dict" Summary: Extend insert_quant_dequant pass to go through forward function graphs Test Plan: ``` python test/test_jit.py 'TestJit.test_insert_quant_dequant' python test/test_quantizer.py ``` Reviewers: pt1quant Subscribers: Tasks: Tags: Differential Revision: [D17001137](https://our.internmc.facebook.com/intern/diff/D17001137)
ZolotukhinM
left a comment
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.
Yeah, it's fine if you do it in a separate PR.
|
|
||
| } // namespace | ||
|
|
||
| TORCH_API void InsertObservers( |
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.
Ah, ok. Please try to split such changes in future as they are not related to what the commit message says.
…dict" Summary: Extend insert_quant_dequant pass to go through forward function graphs Test Plan: ``` python test/test_jit.py 'TestJit.test_insert_quant_dequant' python test/test_quantizer.py ``` Reviewers: pt1quant Subscribers: Tasks: Tags: Differential Revision: [D17001137](https://our.internmc.facebook.com/intern/diff/D17001137)
…dict" Summary: Extend insert_quant_dequant pass to go through forward function graphs Test Plan: ``` python test/test_jit.py 'TestJit.test_insert_quant_dequant' python test/test_quantizer.py ``` Reviewers: pt1quant Subscribers: Tasks: Tags: Differential Revision: [D17001137](https://our.internmc.facebook.com/intern/diff/D17001137)
| script::Module InsertQuantDeQuant( | ||
| script::Module& input_module, | ||
| c10::optional<script::Module> QuantizeHelper::findChildModuleToQuantize(Value* v) { | ||
| if (v->node()->kind() == prim::CallMethod && v->node()->s(attr::name) == "forward") { |
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.
Nit: you could use early exits to avoid staircase indentation.
|
This pull request has been merged in 96db3ad. |
Stack from ghstack:
Summary:
Extend insert_quant_dequant pass to go through forward function graphs
Test Plan:
Reviewers:
pt1quant
Subscribers:
Tasks:
Tags:
Differential Revision: D17001137