-
Notifications
You must be signed in to change notification settings - Fork 25.3k
[Quant][Inductor] Enable quantization linear pattern fusion for gelu inside inductor #114854
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
…inside inductor [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/114854
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit f19e007 with merge base cb489e7 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
_gelu_fusion_1(get_qlinear(2)), | ||
dtype=original_pattern_output_dtype, | ||
), | ||
UnaryAttr("gelu", [], ""): generate_pattern_with_output_quant( |
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.
This UnaryAttr("gelu", [], "")
should have different algorithm_attr
as above, right?
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 believe we should set the algorithm_attr
for GeLU
here to distinguish 2 different algorithms.
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.
Thank you for your feedback! I've made the requested changes.
super().__init__() | ||
self.linear = torch.nn.Linear(4, 4, use_bias) | ||
self.unary_fn = torch.nn.ReLU() | ||
if postop == torch.nn.GELU: | ||
self.unary_fn = postop(approximate=post_op_algo) |
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.
Looks like you already pass in a instance of torch.nn.GELU()
, I am afraid it can't be initialized here again?
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.
You are right! Thanks for the comment and changed accordingly.
…n for gelu inside inductor" **Summary** Enable QLinear Unary pattern for gelu with int8 **Test plan** python test/inductor/test_mkldnn_pattern_matcher.py -k test_qlinear_unary cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 aakhundov ColinPeppler [ghstack-poisoned]
@@ -496,6 +517,8 @@ def qconv_binary(match: Match, *args, **kwargs): | |||
|
|||
|
|||
def _register_quantization_unary_fusion(): | |||
from .mkldnn_fusion import _gelu_fusion_1, _gelu_fusion_2 |
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.
_gelu_fusion_1
is for erf and _gelu_fusion_2
is for tanh approximation? If so, can we give more meaningful name to them instead of "1" and "2"?
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.
Thank you for your feedback! I use _gelu_fusion_erf
and _gelu_fusion_tanh
instead.
…n for gelu inside inductor" **Summary** Enable QLinear Unary pattern for gelu with int8 **Test plan** python test/inductor/test_mkldnn_pattern_matcher.py -k test_qlinear_unary cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 aakhundov ColinPeppler [ghstack-poisoned]
…n for gelu inside inductor" **Summary** Enable QLinear Unary pattern for gelu with int8 **Test plan** python test/inductor/test_mkldnn_pattern_matcher.py -k test_qlinear_unary cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 aakhundov ColinPeppler [ghstack-poisoned]
…n for gelu inside inductor" **Summary** Enable QLinear Unary pattern for gelu with int8 **Test plan** python test/inductor/test_mkldnn_pattern_matcher.py -k test_qlinear_unary cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 aakhundov ColinPeppler [ghstack-poisoned]
…n for gelu inside inductor" **Summary** Enable QLinear Unary pattern for gelu with int8 **Test plan** python test/inductor/test_mkldnn_pattern_matcher.py -k test_qlinear_unary cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 aakhundov ColinPeppler [ghstack-poisoned]
…n for gelu inside inductor" **Summary** Enable QLinear Unary pattern for gelu with int8 **Test plan** python test/inductor/test_mkldnn_pattern_matcher.py -k test_qlinear_unary cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 aakhundov ColinPeppler [ghstack-poisoned]
…n for gelu inside inductor" **Summary** Enable QLinear Unary pattern for gelu with int8 **Test plan** python test/inductor/test_mkldnn_pattern_matcher.py -k test_qlinear_unary cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 aakhundov ColinPeppler [ghstack-poisoned]
self.linear2 = torch.nn.Linear(4, 4, use_bias) | ||
self.unary_fn2 = torch.nn.ReLU() | ||
if unary_op == torch.nn.GELU(): |
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.
2 different GELU instances should not be same always.
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.
Thanks for the comment and changed accordingly.
…n for gelu inside inductor" **Summary** Enable QLinear Unary pattern for gelu with int8 **Test plan** python test/inductor/test_mkldnn_pattern_matcher.py -k test_qlinear_gelu_cpu cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 aakhundov ColinPeppler [ghstack-poisoned]
…n for gelu inside inductor" **Summary** Enable QLinear Unary pattern for gelu with int8 **Test plan** python test/inductor/test_mkldnn_pattern_matcher.py -k test_qlinear_gelu_cpu cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 aakhundov ColinPeppler [ghstack-poisoned]
… for gelu inside inductor ghstack-source-id: 458d785 Pull Request resolved: pytorch#114854
…n for gelu inside inductor" **Summary** Enable QLinear Unary pattern for gelu with int8 **Test plan** python test/inductor/test_mkldnn_pattern_matcher.py -k test_qlinear_gelu_cpu cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 aakhundov ColinPeppler [ghstack-poisoned]
… fusion for gelu inside inductor ghstack-source-id: c7ffc92 Pull Request resolved: pytorch#114854
…n for gelu inside inductor" **Summary** Enable QLinear Unary pattern for gelu with int8 **Test plan** python test/inductor/test_mkldnn_pattern_matcher.py -k test_qlinear_gelu_cpu cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 aakhundov ColinPeppler [ghstack-poisoned]
… for gelu inside inductor ghstack-source-id: 3e91151 Pull Request resolved: pytorch#114854
…n for gelu inside inductor" **Summary** Enable QLinear Unary pattern for gelu with int8 **Test plan** python test/inductor/test_mkldnn_pattern_matcher.py -k test_qlinear_gelu_cpu cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 aakhundov ColinPeppler [ghstack-poisoned]
…n for gelu inside inductor" **Summary** Enable QLinear Unary pattern for gelu with int8 **Test plan** python test/inductor/test_mkldnn_pattern_matcher.py -k test_qlinear_gelu_cpu cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 aakhundov ColinPeppler [ghstack-poisoned]
Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as |
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
…_mixed_bf16 for gelu (#116004) **Summary** Enable QLinear Unary pattern for gelu with int8_mix_bf16 **Test plan** python test/inductor/test_mkldnn_pattern_matcher.py -k test_qlinear_gelu_int8_mixed_bf16 Co-authored-by: leslie-fang-intel <leslie.fang@intel.com> Pull Request resolved: #116004 Approved by: https://github.com/jgong5, https://github.com/leslie-fang-intel ghstack dependencies: #114853, #114854
Stack from ghstack (oldest at bottom):
Summary
Enable QLinear Unary pattern for gelu with int8
Test plan
python test/inductor/test_mkldnn_pattern_matcher.py -k test_qlinear_gelu_cpu
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @peterbell10 @ipiszy @yf225 @chenyang78 @kadeng @muchulee8 @aakhundov @ColinPeppler @amjames @desertfire @chauhang