-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[quant][graphmode][fix] dequantize propagation for {add/mul}_scalar #40596
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:
Previously the fusion patterns for {add/mul}_scalar is inconsistent since the op pattern
produces a non-quantized tensor and the op replacement graph produces a quantized tensor
Test Plan:
Reviewers:
Subscribers:
Tasks:
Tags:
[ghstack-poisoned]
|
|
||
| def forward(self, x): | ||
| x = self.conv(x) | ||
| # add_scalar |
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 thought this was already supported. What was missing?
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.
the fusion pattern is inconsistent
| std::string add_scalar = R"( | ||
| graph(%a_quant, %b_scalar, %alpha): | ||
| %a_dequant = aten::dequantize(%a_quant) | ||
| %r = aten::add(%a_dequant, %b_scalar, %alpha) | ||
| return (%r) )"; | ||
|
|
||
| std::string quantized_add_scalar = R"( | ||
| graph(%a_quant, %b_scalar, %alpha): | ||
| %r = quantized::add_scalar(%a_quant, %b_scalar) | ||
| return (%r) )"; |
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.
@raghuramank100 major change is this
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.
original pattern produces a float tensor and quantized pattern produces a quantized tensor
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.
So is it correct to say that the new pattern is: deq->add-> = quantize_add->deq?
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.
new pattern is:
dq - aten::add -quant --> quantized::add_scalar
💊 CI failures summary and remediationsAs of commit 52b3f05 (more details on the Dr. CI page):
ci.pytorch.org: 1 failedThis 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 12 times. |
…l}_scalar"
Summary:
Previously the fusion patterns for {add/mul}_scalar is inconsistent since the op pattern
produces a non-quantized tensor and the op replacement graph produces a quantized tensor
Test Plan:
Reviewers:
Subscribers:
Tasks:
Tags:
[ghstack-poisoned]
…l}_scalar"
Summary:
Previously the fusion patterns for {add/mul}_scalar is inconsistent since the op pattern
produces a non-quantized tensor and the op replacement graph produces a quantized tensor
Test Plan:
Reviewers:
Subscribers:
Tasks:
Tags:
Differential Revision: [D22251072](https://our.internmc.facebook.com/intern/diff/D22251072)
[ghstack-poisoned]
|
This pull request has been merged in e3a9768. |
1 similar comment
|
This pull request has been merged in e3a9768. |
…ytorch#40596) Summary: Pull Request resolved: pytorch#40596 Previously the fusion patterns for {add/mul}_scalar is inconsistent since the op pattern produces a non-quantized tensor and the op replacement graph produces a quantized tensor Test Plan: Imported from OSS Differential Revision: D22251072 fbshipit-source-id: e16eb92cf6611578cca1ed8ebde961f8d0610137
…40596) Summary: Pull Request resolved: #40596 Previously the fusion patterns for {add/mul}_scalar is inconsistent since the op pattern produces a non-quantized tensor and the op replacement graph produces a quantized tensor Test Plan: Imported from OSS Differential Revision: D22251072 fbshipit-source-id: e16eb92cf6611578cca1ed8ebde961f8d0610137
…40596) Summary: Pull Request resolved: #40596 Previously the fusion patterns for {add/mul}_scalar is inconsistent since the op pattern produces a non-quantized tensor and the op replacement graph produces a quantized tensor Test Plan: Imported from OSS Differential Revision: D22251072 fbshipit-source-id: e16eb92cf6611578cca1ed8ebde961f8d0610137
… aten::repeat (#40933) * [quant][graphmode][fix] dequantize propagation for {add/mul}_scalar (#40596) Summary: Pull Request resolved: #40596 Previously the fusion patterns for {add/mul}_scalar is inconsistent since the op pattern produces a non-quantized tensor and the op replacement graph produces a quantized tensor Test Plan: Imported from OSS Differential Revision: D22251072 fbshipit-source-id: e16eb92cf6611578cca1ed8ebde961f8d0610137 * [quant][graphmode] Support quantization for `aten::apend` (#40743) Summary: Pull Request resolved: #40743 `aten::append` modifies input inplace and the output is ignored, these ops are not supported right now, so we'll need to first make `aten::append` non-inplace by change ``` ignored = aten::append(list, x) ``` to ``` x_list = aten::ListConstruct(x) result = aten::add(list, x_list) ``` and then quantize the aten::add instead. Test Plan: TestQuantizeJitOps.test_general_shape_ops Imported from OSS Differential Revision: D22302151 fbshipit-source-id: 931000388e7501e9dd17bec2fad8a96b71a5efc5
Stack from ghstack:
Summary:
Previously the fusion patterns for {add/mul}_scalar is inconsistent since the op pattern
produces a non-quantized tensor and the op replacement graph produces a quantized tensor
Test Plan:
Reviewers:
Subscribers:
Tasks:
Tags:
Differential Revision: D22251072