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
[Inductor] [Quant] Enable lowering of quant per tensor and refactor quant pattern #124041
[Inductor] [Quant] Enable lowering of quant per tensor and refactor quant pattern #124041
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/124041
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 5f81bea with merge base fdff992 (): This comment was automatically generated by Dr. CI and updates every 15 minutes. |
ghstack-source-id: b947d4e653552e2decf30d30888d9ac911b6f40c Pull Request resolved: #124041
…tern" cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 aakhundov ColinPeppler amjames desertfire chauhang [ghstack-poisoned]
ghstack-source-id: e79df3747a4f820efb45917048b06665ebeb9323 Pull Request resolved: #124041
…tern" cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 aakhundov ColinPeppler amjames desertfire chauhang [ghstack-poisoned]
ghstack-source-id: 77b385d916550ec2cc83d340c4a04d8162ddd0bf Pull Request resolved: #124041
…tern" cc jgong5 mingfeima XiaobingSuper sanchitintel ashokei jingxu10 voznesenskym penguinwu EikanWang Guobing-Chen zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 aakhundov ColinPeppler amjames desertfire chauhang [ghstack-poisoned]
ghstack-source-id: 8d18ac99ac988f0ef3aa8054dfc38ebbb5ca1d2e Pull Request resolved: #124041
…tern" cc jgong5 mingfeima XiaobingSuper sanchitintel ashokei jingxu10 voznesenskym penguinwu EikanWang Guobing-Chen zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 aakhundov ColinPeppler amjames desertfire chauhang [ghstack-poisoned]
ghstack-source-id: b5cea99eca1aa3635e4070b08f27a983507f28e8 Pull Request resolved: #124041
…tern" cc jgong5 mingfeima XiaobingSuper sanchitintel ashokei jingxu10 voznesenskym penguinwu EikanWang Guobing-Chen zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 aakhundov ColinPeppler amjames desertfire chauhang [ghstack-poisoned]
ghstack-source-id: c27e0a6860cf6ce6891dd613a842ef3c59599119 Pull Request resolved: #124041
…tern" cc jgong5 mingfeima XiaobingSuper sanchitintel ashokei jingxu10 voznesenskym penguinwu EikanWang Guobing-Chen zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 aakhundov ColinPeppler amjames desertfire chauhang [ghstack-poisoned]
ghstack-source-id: c90f2a0235edc5b2fe98b1f5295b57effc513aab Pull Request resolved: #124041
…tern" cc jgong5 mingfeima XiaobingSuper sanchitintel ashokei jingxu10 voznesenskym penguinwu EikanWang Guobing-Chen zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 aakhundov ColinPeppler amjames desertfire chauhang [ghstack-poisoned]
ghstack-source-id: 5fea49bfba3f0e1d454c336ff8a2d4f20f7ee6b9 Pull Request resolved: #124041
…tern" cc jgong5 mingfeima XiaobingSuper sanchitintel ashokei jingxu10 voznesenskym penguinwu EikanWang Guobing-Chen zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 aakhundov ColinPeppler amjames desertfire chauhang [ghstack-poisoned]
ghstack-source-id: 17bd7bb1e7a1d35194d4be4467a1c4f2b41fb009 Pull Request resolved: #124041
…tern" cc jgong5 mingfeima XiaobingSuper sanchitintel ashokei jingxu10 voznesenskym penguinwu EikanWang Guobing-Chen zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 aakhundov ColinPeppler amjames desertfire chauhang [ghstack-poisoned]
ghstack-source-id: 06d74132126f6e5e02900540461cf907cb841868 Pull Request resolved: #124041
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 |
**Summary** Change the name of QConv output scale from `inv_output_scale` to `output_scale` after we move the optimization of quant/dequant from decomposition to lowering phase. Pull Request resolved: #124246 Approved by: https://github.com/jgong5, https://github.com/peterbell10 ghstack dependencies: #124041
**Summary** Fix 2 regression issues caused by previous refactor: - Fix the issue in dequant promotion pass with dynamic quant when the dequant node is with `tensor` overload. - Fix numerical issue in dynamic quant, since input will convert to scales' dtype (which is `double`) to do quant operatoration with previous implementation. **TestPlan** ``` clear && python -u -m pytest -s -v test/inductor/test_mkldnn_pattern_matcher.py -k test_dynamic_qlinear_input_dim_exceeds_2 clear && python -u -m pytest -s -v test/inductor/test_mkldnn_pattern_matcher.py -k test_qlinear_dequant_promotion_dynamic_cpu ``` Pull Request resolved: #125207 Approved by: https://github.com/peterbell10, https://github.com/jgong5 ghstack dependencies: #124041, #124246
@pytorchbot revert -m 'Sorry for reverting your change but I think there is a land race with the change https://hud.pytorch.org/pytorch/pytorch/commit/33e6791645b5950b0f39301f55b8a4a79c0ca847' -c landrace |
@pytorchbot successfully started a revert job. Check the current status here. |
This reverts commit 3da949b. Reverted #125207 on behalf of https://github.com/huydhn due to Sorry for reverting your change but I think there is a land race with the change https://hud.pytorch.org/pytorch/pytorch/commit/33e6791645b5950b0f39301f55b8a4a79c0ca847 ([comment](#124041 (comment)))
This reverts commit 9ba9f7f. Reverted #124246 on behalf of https://github.com/huydhn due to Sorry for reverting your change but I think there is a land race with the change https://hud.pytorch.org/pytorch/pytorch/commit/33e6791645b5950b0f39301f55b8a4a79c0ca847 ([comment](#124041 (comment)))
…factor quant pattern (#124041)" This reverts commit 33e6791. Reverted #124041 on behalf of https://github.com/huydhn due to Sorry for reverting your change but I think there is a land race with the change https://hud.pytorch.org/pytorch/pytorch/commit/33e6791645b5950b0f39301f55b8a4a79c0ca847 ([comment](#124041 (comment)))
@leslie-fang-intel your PR has been successfully reverted. |
Hi @huydhn, has this change https://hud.pytorch.org/pytorch/pytorch/commit/33e6791645b5950b0f39301f55b8a4a79c0ca847' landed? Should I rebase this ghstack and try land again? |
Yes, please do a rebase to main and try to land this again |
The stack is probably having a landrace with this change #122832 that was landed few hours ago |
… refactor quant pattern" **Summary** Per the discussion in #123444, the `decomposed quant/dequant` patterns changed after #123445, we can move the optimization of `decomposed quant/dequant` from inductor decomposition into lowering phase to avoid the changes. In this way, we can: - Avoid the pattern matcher failure introduced in #123445 - Make the quantization pattern clearer in the pattern matcher phase, since the `quant/dequant` nodes have not been decomposed. **Changes in this PR** - Move optimization of `decomposed quant/dequant` from inductor decomposition into lowering phase. - Corresponding changes in the quantization pattern matcher to ensure no bc-breaking. **TestPlan** ``` python -u -m pytest -s -v test/inductor/test_mkldnn_pattern_matcher.py -k test_q ``` cc jgong5 mingfeima XiaobingSuper sanchitintel ashokei jingxu10 voznesenskym penguinwu EikanWang Guobing-Chen zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 aakhundov ColinPeppler amjames desertfire chauhang [ghstack-poisoned]
Rebase to main and check the preCI again. |
@pytorchbot merge |
Hi @huydhn, after rebase, the preCI are all green. I am going to re-land. |
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 |
**Summary** Change the name of QConv output scale from `inv_output_scale` to `output_scale` after we move the optimization of quant/dequant from decomposition to lowering phase. Pull Request resolved: #124246 Approved by: https://github.com/jgong5, https://github.com/peterbell10 ghstack dependencies: #124041
**Summary** Fix 2 regression issues caused by previous refactor: - Fix the issue in dequant promotion pass with dynamic quant when the dequant node is with `tensor` overload. - Fix numerical issue in dynamic quant, since input will convert to scales' dtype (which is `double`) to do quant operatoration with previous implementation. **TestPlan** ``` clear && python -u -m pytest -s -v test/inductor/test_mkldnn_pattern_matcher.py -k test_dynamic_qlinear_input_dim_exceeds_2 clear && python -u -m pytest -s -v test/inductor/test_mkldnn_pattern_matcher.py -k test_qlinear_dequant_promotion_dynamic_cpu ``` Pull Request resolved: #125207 Approved by: https://github.com/peterbell10, https://github.com/jgong5 ghstack dependencies: #124041, #124246
Stack from ghstack (oldest at bottom):
Summary
Per the discussion in #123444, the
decomposed quant/dequant
patterns changed after #123445, we can move the optimization ofdecomposed quant/dequant
from inductor decomposition into lowering phase to avoid the changes. In this way, we can:quant/dequant
nodes have not been decomposed.Changes in this PR
decomposed quant/dequant
from inductor decomposition into lowering phase.TestPlan
cc @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10 @voznesenskym @penguinwu @EikanWang @Guobing-Chen @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @peterbell10 @ipiszy @yf225 @chenyang78 @kadeng @muchulee8 @aakhundov @ColinPeppler @amjames @desertfire @chauhang