-
Notifications
You must be signed in to change notification settings - Fork 25.3k
[quant][pt2] Add Conv + BN fusion for prepare QAT #98568
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
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Summary: This commit adds the prepare_qat_pt2e API and the fusion logic for Conv + BN. We use the subgraph rewriter to match and replace the pattern with the existing logic in `nniqat.ConvBn2d`. Note this is not the end-to-end flow yet. In particular, the following things are still missing and will be added in future PRs: 1) Weight fake quantize after scaled weight 2) Convert flow needs to swap the new subgraph with another one that merges the batchnorm stats back into conv Test Plan: python test/test_quantization.py TestQuantizePT2E.test_qat_conv_bn_fusion [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/98568
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ✅ No FailuresAs of commit bc04d11: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
andrewor14
added a commit
that referenced
this pull request
Apr 7, 2023
Summary: This commit adds the prepare_qat_pt2e API and the fusion logic for Conv + BN. We use the subgraph rewriter to match and replace the pattern with the existing logic in `nniqat.ConvBn2d`. Note this is not the end-to-end flow yet. In particular, the following things are still missing and will be added in future PRs: 1) Weight fake quantize after scaled weight 2) Convert flow needs to swap the new subgraph with another one that merges the batchnorm stats back into conv Test Plan: python test/test_quantization.py TestQuantizePT2E.test_qat_conv_bn_fusion ghstack-source-id: 3f39bce Pull Request resolved: #98568
Summary: This commit adds the prepare_qat_pt2e API and the fusion logic for Conv + BN. We use the subgraph rewriter to match and replace the pattern with the existing logic in `nniqat.ConvBn2d`. Note this is not the end-to-end flow yet. In particular, the following things are still missing and will be added in future PRs: 1) Weight fake quantize after scaled weight 2) Convert flow needs to swap the new subgraph with another one that merges the batchnorm stats back into conv Test Plan: python test/test_quantization.py TestQuantizePT2E.test_qat_conv_bn_fusion [ghstack-poisoned]
andrewor14
added a commit
that referenced
this pull request
Apr 7, 2023
Summary: This commit adds the prepare_qat_pt2e API and the fusion logic for Conv + BN. We use the subgraph rewriter to match and replace the pattern with the existing logic in `nniqat.ConvBn2d`. Note this is not the end-to-end flow yet. In particular, the following things are still missing and will be added in future PRs: 1) Weight fake quantize after scaled weight 2) Convert flow needs to swap the new subgraph with another one that merges the batchnorm stats back into conv Test Plan: python test/test_quantization.py TestQuantizePT2E.test_qat_conv_bn_fusion ghstack-source-id: 349db4d Pull Request resolved: #98568
Summary: This commit adds the prepare_qat_pt2e API and the fusion logic for Conv + BN. We use the subgraph rewriter to match and replace the pattern with the existing logic in `nniqat.ConvBn2d`. Note this is not the end-to-end flow yet. In particular, the following things are still missing and will be added in future PRs: 1) Weight fake quantize after scaled weight 2) Convert flow needs to swap the new subgraph with another one that merges the batchnorm stats back into conv Test Plan: python test/test_quantization.py TestQuantizePT2E.test_qat_conv_bn_fusion cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx desertfire [ghstack-poisoned]
andrewor14
added a commit
that referenced
this pull request
Apr 7, 2023
Summary: This commit adds the prepare_qat_pt2e API and the fusion logic for Conv + BN. We use the subgraph rewriter to match and replace the pattern with the existing logic in `nniqat.ConvBn2d`. Note this is not the end-to-end flow yet. In particular, the following things are still missing and will be added in future PRs: 1) Weight fake quantize after scaled weight 2) Convert flow needs to swap the new subgraph with another one that merges the batchnorm stats back into conv Test Plan: python test/test_quantization.py TestQuantizePT2E.test_qat_conv_bn_fusion ghstack-source-id: d2374ac Pull Request resolved: #98568
yanboliang
reviewed
Apr 8, 2023
Summary: This commit adds the prepare_qat_pt2e API and the fusion logic for Conv + BN. We use the subgraph rewriter to match and replace the pattern with the existing logic in `nniqat.ConvBn2d`. Note this is not the end-to-end flow yet. In particular, the following things are still missing and will be added in future PRs: 1) Weight fake quantize after scaled weight 2) Convert flow needs to swap the new subgraph with another one that merges the batchnorm stats back into conv Test Plan: python test/test_quantization.py TestQuantizePT2E.test_qat_conv_bn_fusion cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx desertfire [ghstack-poisoned]
Summary: This commit adds the prepare_qat_pt2e API and the fusion logic for Conv + BN. We use the subgraph rewriter to match and replace the pattern with the existing logic in `nniqat.ConvBn2d`. Note this is not the end-to-end flow yet. In particular, the following things are still missing and will be added in future PRs: 1) Weight fake quantize after scaled weight 2) Convert flow needs to swap the new subgraph with another one that merges the batchnorm stats back into conv Test Plan: python test/test_quantization.py TestQuantizePT2E.test_qat_conv_bn_fusion cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx desertfire [ghstack-poisoned]
Summary: This commit adds the prepare_qat_pt2e API and the fusion logic for Conv + BN. We use the subgraph rewriter to match and replace the pattern with the existing logic in `nniqat.ConvBn2d`. Note this is not the end-to-end flow yet. In particular, the following things are still missing and will be added in future PRs: 1) Weight fake quantize after scaled weight 2) Convert flow needs to swap the new subgraph with another one that merges the batchnorm stats back into conv Test Plan: python test/test_quantization.py TestQuantizePT2E.test_qat_conv_bn_fusion cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx desertfire [ghstack-poisoned]
andrewor14
added a commit
that referenced
this pull request
Apr 12, 2023
Summary: This commit adds the prepare_qat_pt2e API and the fusion logic for Conv + BN. We use the subgraph rewriter to match and replace the pattern with the existing logic in `nniqat.ConvBn2d`. Note this is not the end-to-end flow yet. In particular, the following things are still missing and will be added in future PRs: 1) Weight fake quantize after scaled weight 2) Convert flow needs to swap the new subgraph with another one that merges the batchnorm stats back into conv Test Plan: python test/test_quantization.py TestQuantizePT2E.test_qat_conv_bn_fusion ghstack-source-id: b2e3e49 Pull Request resolved: #98568
Summary: This commit adds the prepare_qat_pt2e API and the fusion logic for Conv + BN. We use the subgraph rewriter to match and replace the pattern with the existing logic in `nniqat.ConvBn2d`. Note this is not the end-to-end flow yet. In particular, the following things are still missing and will be added in future PRs: 1) Weight fake quantize after scaled weight 2) Convert flow needs to swap the new subgraph with another one that merges the batchnorm stats back into conv Test Plan: python test/test_quantization.py TestQuantizePT2E.test_qat_conv_bn_fusion cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx desertfire [ghstack-poisoned]
Summary: This commit adds the prepare_qat_pt2e API and the fusion logic for Conv + BN. We use the subgraph rewriter to match and replace the pattern with the existing logic in `nniqat.ConvBn2d`. Note this is not the end-to-end flow yet. In particular, the following things are still missing and will be added in future PRs: 1) Weight fake quantize after scaled weight 2) Convert flow needs to swap the new subgraph with another one that merges the batchnorm stats back into conv Test Plan: python test/test_quantization.py TestQuantizePT2E.test_qat_conv_bn_fusion cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx desertfire [ghstack-poisoned]
andrewor14
added a commit
that referenced
this pull request
Apr 13, 2023
Summary: This commit adds the prepare_qat_pt2e API and the fusion logic for Conv + BN. We use the subgraph rewriter to match and replace the pattern with the existing logic in `nniqat.ConvBn2d`. Note this is not the end-to-end flow yet. In particular, the following things are still missing and will be added in future PRs: 1) Weight fake quantize after scaled weight 2) Convert flow needs to swap the new subgraph with another one that merges the batchnorm stats back into conv Test Plan: python test/test_quantization.py TestQuantizePT2E.test_qat_conv_bn_fusion ghstack-source-id: fd1d3dc Pull Request resolved: #98568
Summary: This commit adds the prepare_qat_pt2e API and the fusion logic for Conv + BN. We use the subgraph rewriter to match and replace the pattern with the existing logic in `nniqat.ConvBn2d`. Note this is not the end-to-end flow yet. In particular, the following things are still missing and will be added in future PRs: 1) Weight fake quantize after scaled weight 2) Convert flow needs to swap the new subgraph with another one that merges the batchnorm stats back into conv Test Plan: python test/test_quantization.py TestQuantizePT2E.test_qat_conv_bn_fusion cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx desertfire [ghstack-poisoned]
andrewor14
added a commit
that referenced
this pull request
Apr 13, 2023
Summary: This commit adds the prepare_qat_pt2e API and the fusion logic for Conv + BN. We use the subgraph rewriter to match and replace the pattern with the existing logic in `nniqat.ConvBn2d`. Note this is not the end-to-end flow yet. In particular, the following things are still missing and will be added in future PRs: 1) Weight fake quantize after scaled weight 2) Convert flow needs to swap the new subgraph with another one that merges the batchnorm stats back into conv Test Plan: python test/test_quantization.py TestQuantizePT2E.test_qat_conv_bn_fusion ghstack-source-id: 7deee75 Pull Request resolved: #98568
Summary: This commit adds the prepare_qat_pt2e API and the fusion logic for Conv + BN. We use the subgraph rewriter to match and replace the pattern with the existing logic in `nniqat.ConvBn2d`. Note this is not the end-to-end flow yet. In particular, the following things are still missing and will be added in future PRs: 1) Weight fake quantize after scaled weight 2) Convert flow needs to swap the new subgraph with another one that merges the batchnorm stats back into conv Test Plan: python test/test_quantization.py TestQuantizePT2E.test_qat_conv_bn_fusion cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx desertfire [ghstack-poisoned]
andrewor14
added a commit
that referenced
this pull request
Apr 13, 2023
Summary: This commit adds the prepare_qat_pt2e API and the fusion logic for Conv + BN. We use the subgraph rewriter to match and replace the pattern with the existing logic in `nniqat.ConvBn2d`. Note this is not the end-to-end flow yet. In particular, the following things are still missing and will be added in future PRs: 1) Weight fake quantize after scaled weight 2) Convert flow needs to swap the new subgraph with another one that merges the batchnorm stats back into conv Test Plan: python test/test_quantization.py TestQuantizePT2E.test_qat_conv_bn_fusion ghstack-source-id: fccf1a0 Pull Request resolved: #98568
Summary: This commit adds the prepare_qat_pt2e API and the fusion logic for Conv + BN. We use the subgraph rewriter to match and replace the pattern with the existing logic in `nniqat.ConvBn2d`. Note this is not the end-to-end flow yet. In particular, the following things are still missing and will be added in future PRs: 1) Weight fake quantize after scaled weight 2) Convert flow needs to swap the new subgraph with another one that merges the batchnorm stats back into conv Test Plan: python test/test_quantization.py TestQuantizePT2E.test_qat_conv_bn_fusion cc soumith voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx desertfire [ghstack-poisoned]
andrewor14
added a commit
that referenced
this pull request
Apr 28, 2023
…or prepare QAT" Summary: This follows #98568, which lays all the groundwork for Conv + BN fusion in prepare QAT. Conv + BN + ReLU fusion can reuse the same match and replace patterns and is handled similarly. Test Plan: python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_fusion python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_numerics Reviewers: kimishpatel, jerryzh168 Differential Revision: [D45360792](https://our.internmc.facebook.com/intern/diff/D45360792) [ghstack-poisoned]
andrewor14
added a commit
that referenced
this pull request
Apr 28, 2023
Summary: This follows #98568, which lays all the groundwork for Conv + BN fusion in prepare QAT. Conv + BN + ReLU fusion can reuse the same match and replace patterns and is handled similarly. Test Plan: python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_fusion python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_numerics Reviewers: kimishpatel, jerryzh168 Differential Revision: [D45360792](https://our.internmc.facebook.com/intern/diff/D45360792) [ghstack-poisoned]
andrewor14
added a commit
that referenced
this pull request
Apr 28, 2023
Summary: This follows #98568, which lays all the groundwork for Conv + BN fusion in prepare QAT. Conv + BN + ReLU fusion can reuse the same match and replace patterns and is handled similarly. Test Plan: python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_fusion python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_numerics Reviewers: kimishpatel, jerryzh168 ghstack-source-id: d4ef3ac Pull Request resolved: #99695
andrewor14
added a commit
that referenced
this pull request
Apr 28, 2023
Summary: This follows #98568, which lays all the groundwork for Conv + BN fusion in prepare QAT. Conv + BN + ReLU fusion can reuse the same match and replace patterns and is handled similarly. Test Plan: python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_fusion python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_numerics Reviewers: kimishpatel, jerryzh168 [ghstack-poisoned]
andrewor14
added a commit
that referenced
this pull request
Apr 28, 2023
…or prepare QAT" Summary: This follows #98568, which lays all the groundwork for Conv + BN fusion in prepare QAT. Conv + BN + ReLU fusion can reuse the same match and replace patterns and is handled similarly. Test Plan: python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_fusion python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_numerics Reviewers: kimishpatel, jerryzh168 [ghstack-poisoned]
andrewor14
added a commit
that referenced
this pull request
Apr 28, 2023
Summary: This follows #98568, which lays all the groundwork for Conv + BN fusion in prepare QAT. Conv + BN + ReLU fusion can reuse the same match and replace patterns and is handled similarly. Test Plan: python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_fusion python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_numerics Reviewers: kimishpatel, jerryzh168 [ghstack-poisoned]
andrewor14
added a commit
that referenced
this pull request
Apr 28, 2023
Summary: This follows #98568, which lays all the groundwork for Conv + BN fusion in prepare QAT. Conv + BN + ReLU fusion can reuse the same match and replace patterns and is handled similarly. Test Plan: python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_fusion python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_numerics Reviewers: kimishpatel, jerryzh168 ghstack-source-id: 77f6094 Pull Request resolved: #100283
andrewor14
added a commit
that referenced
this pull request
May 3, 2023
Summary: This follows #98568, which lays all the groundwork for Conv + BN fusion in prepare QAT. Conv + BN + ReLU fusion can reuse the same match and replace patterns and is handled similarly. Test Plan: python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_fusion python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_numerics Reviewers: kimishpatel, jerryzh168 ghstack-source-id: 77f6094 Pull Request resolved: #100283
andrewor14
added a commit
that referenced
this pull request
May 3, 2023
…or prepare QAT" Summary: This follows #98568, which lays all the groundwork for Conv + BN fusion in prepare QAT. Conv + BN + ReLU fusion can reuse the same match and replace patterns and is handled similarly. Test Plan: python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_fusion python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_numerics Reviewers: kimishpatel, jerryzh168 [ghstack-poisoned]
andrewor14
added a commit
that referenced
this pull request
May 3, 2023
Summary: This follows #98568, which lays all the groundwork for Conv + BN fusion in prepare QAT. Conv + BN + ReLU fusion can reuse the same match and replace patterns and is handled similarly. Test Plan: python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_fusion python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_numerics Reviewers: kimishpatel, jerryzh168 [ghstack-poisoned]
andrewor14
added a commit
that referenced
this pull request
May 3, 2023
…or prepare QAT" Summary: This follows #98568, which lays all the groundwork for Conv + BN fusion in prepare QAT. Conv + BN + ReLU fusion can reuse the same match and replace patterns and is handled similarly. Test Plan: python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_fusion python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_numerics Reviewers: kimishpatel, jerryzh168 [ghstack-poisoned]
andrewor14
added a commit
that referenced
this pull request
May 3, 2023
Summary: This follows #98568, which lays all the groundwork for Conv + BN fusion in prepare QAT. Conv + BN + ReLU fusion can reuse the same match and replace patterns and is handled similarly. Test Plan: python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_fusion python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_numerics Reviewers: kimishpatel, jerryzh168 [ghstack-poisoned]
andrewor14
added a commit
that referenced
this pull request
May 3, 2023
…or prepare QAT" Summary: This follows #98568, which lays all the groundwork for Conv + BN fusion in prepare QAT. Conv + BN + ReLU fusion can reuse the same match and replace patterns and is handled similarly. Test Plan: python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_fusion python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_numerics Reviewers: kimishpatel, jerryzh168 Differential Revision: [](https://our.internmc.facebook.com/intern/diff/) Differential Revision: [D45515494](https://our.internmc.facebook.com/intern/diff/D45515494) [ghstack-poisoned]
andrewor14
added a commit
that referenced
this pull request
May 3, 2023
Summary: This follows #98568, which lays all the groundwork for Conv + BN fusion in prepare QAT. Conv + BN + ReLU fusion can reuse the same match and replace patterns and is handled similarly. Test Plan: python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_fusion python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_numerics Reviewers: kimishpatel, jerryzh168 Differential Revision: [](https://our.internmc.facebook.com/intern/diff/) Differential Revision: [D45515494](https://our.internmc.facebook.com/intern/diff/D45515494) [ghstack-poisoned]
andrewor14
added a commit
that referenced
this pull request
May 3, 2023
…or prepare QAT" Summary: This follows #98568, which lays all the groundwork for Conv + BN fusion in prepare QAT. Conv + BN + ReLU fusion can reuse the same match and replace patterns and is handled similarly. Test Plan: python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_fusion python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_numerics Reviewers: kimishpatel, jerryzh168 Differential Revision: [](https://our.internmc.facebook.com/intern/diff/) Differential Revision: [D45515494](https://our.internmc.facebook.com/intern/diff/D45515494) [ghstack-poisoned]
andrewor14
added a commit
that referenced
this pull request
May 3, 2023
Summary: This follows #98568, which lays all the groundwork for Conv + BN fusion in prepare QAT. Conv + BN + ReLU fusion can reuse the same match and replace patterns and is handled similarly. Test Plan: python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_fusion python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_numerics Reviewers: kimishpatel, jerryzh168 Differential Revision: [](https://our.internmc.facebook.com/intern/diff/) Differential Revision: [D45515494](https://our.internmc.facebook.com/intern/diff/D45515494) [ghstack-poisoned]
andrewor14
added a commit
that referenced
this pull request
May 4, 2023
…or prepare QAT" Summary: This follows #98568, which lays all the groundwork for Conv + BN fusion in prepare QAT. Conv + BN + ReLU fusion can reuse the same match and replace patterns and is handled similarly. Test Plan: python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_fusion python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_numerics Reviewers: kimishpatel, jerryzh168 Differential Revision: [](https://our.internmc.facebook.com/intern/diff/) Differential Revision: [D45515494](https://our.internmc.facebook.com/intern/diff/D45515494) [ghstack-poisoned]
andrewor14
added a commit
that referenced
this pull request
May 4, 2023
Summary: This follows #98568, which lays all the groundwork for Conv + BN fusion in prepare QAT. Conv + BN + ReLU fusion can reuse the same match and replace patterns and is handled similarly. Test Plan: python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_fusion python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_numerics Reviewers: kimishpatel, jerryzh168 Differential Revision: [](https://our.internmc.facebook.com/intern/diff/) Differential Revision: [D45515494](https://our.internmc.facebook.com/intern/diff/D45515494) [ghstack-poisoned]
andrewor14
added a commit
that referenced
this pull request
May 4, 2023
Summary: This follows #98568, which lays all the groundwork for Conv + BN fusion in prepare QAT. Conv + BN + ReLU fusion can reuse the same match and replace patterns and is handled similarly. Test Plan: python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_fusion python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_numerics Reviewers: kimishpatel, jerryzh168 ghstack-source-id: 7c8f018 Pull Request resolved: #100283
andrewor14
added a commit
that referenced
this pull request
May 4, 2023
…or prepare QAT" Summary: This follows #98568, which lays all the groundwork for Conv + BN fusion in prepare QAT. Conv + BN + ReLU fusion can reuse the same match and replace patterns and is handled similarly. Test Plan: python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_fusion python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_numerics Reviewers: kimishpatel, jerryzh168 Differential Revision: [](https://our.internmc.facebook.com/intern/diff/) Differential Revision: [D45515494](https://our.internmc.facebook.com/intern/diff/D45515494) [ghstack-poisoned]
andrewor14
added a commit
that referenced
this pull request
May 4, 2023
Summary: This follows #98568, which lays all the groundwork for Conv + BN fusion in prepare QAT. Conv + BN + ReLU fusion can reuse the same match and replace patterns and is handled similarly. Test Plan: python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_fusion python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_numerics Reviewers: kimishpatel, jerryzh168 Differential Revision: [](https://our.internmc.facebook.com/intern/diff/) Differential Revision: [D45515494](https://our.internmc.facebook.com/intern/diff/D45515494) [ghstack-poisoned]
andrewor14
added a commit
that referenced
this pull request
May 5, 2023
…or prepare QAT" Summary: This follows #98568, which lays all the groundwork for Conv + BN fusion in prepare QAT. Conv + BN + ReLU fusion can reuse the same match and replace patterns and is handled similarly. Test Plan: python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_fusion python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_numerics Reviewers: kimishpatel, jerryzh168 Differential Revision: [](https://our.internmc.facebook.com/intern/diff/) Differential Revision: [D45515494](https://our.internmc.facebook.com/intern/diff/D45515494) [ghstack-poisoned]
andrewor14
added a commit
that referenced
this pull request
May 5, 2023
Summary: This follows #98568, which lays all the groundwork for Conv + BN fusion in prepare QAT. Conv + BN + ReLU fusion can reuse the same match and replace patterns and is handled similarly. Test Plan: python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_fusion python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_numerics Reviewers: kimishpatel, jerryzh168 Differential Revision: [](https://our.internmc.facebook.com/intern/diff/) Differential Revision: [D45515494](https://our.internmc.facebook.com/intern/diff/D45515494) [ghstack-poisoned]
andrewor14
added a commit
that referenced
this pull request
May 7, 2023
…or prepare QAT" Summary: This follows #98568, which lays all the groundwork for Conv + BN fusion in prepare QAT. Conv + BN + ReLU fusion can reuse the same match and replace patterns and is handled similarly. Test Plan: python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_fusion python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_numerics Reviewers: kimishpatel, jerryzh168 Differential Revision: [](https://our.internmc.facebook.com/intern/diff/) Differential Revision: [D45515494](https://our.internmc.facebook.com/intern/diff/D45515494) [ghstack-poisoned]
andrewor14
added a commit
that referenced
this pull request
May 7, 2023
Summary: This follows #98568, which lays all the groundwork for Conv + BN fusion in prepare QAT. Conv + BN + ReLU fusion can reuse the same match and replace patterns and is handled similarly. Test Plan: python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_fusion python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_numerics Reviewers: kimishpatel, jerryzh168 Differential Revision: [](https://our.internmc.facebook.com/intern/diff/) Differential Revision: [D45515494](https://our.internmc.facebook.com/intern/diff/D45515494) [ghstack-poisoned]
pytorchmergebot
pushed a commit
that referenced
this pull request
May 7, 2023
Summary: This follows #98568, which lays all the groundwork for Conv + BN fusion in prepare QAT. Conv + BN + ReLU fusion can reuse the same match and replace patterns and is handled similarly. Test Plan: python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_fusion python test/test_quantization.py TestQuantizePT2E.test_prepare_qat_conv_bn_relu_numerics Reviewers: kimishpatel, jerryzh168 Differential Revision: [](https://our.internmc.facebook.com/intern/diff/) Differential Revision: [D45515494](https://our.internmc.facebook.com/intern/diff/D45515494) Pull Request resolved: #100283 Approved by: https://github.com/jerryzh168
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
ciflow/inductor
ciflow/trunk
Trigger trunk jobs on your pull request
Merged
merging
module: dynamo
release notes: quantization
release notes category
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Stack from ghstack (oldest at bottom):
Summary: This commit adds the
prepare_qat_pt2e
API and thefusion logic for Conv + BN. We use the subgraph rewriter to
match and replace the pattern with the existing logic in
nniqat.ConvBn2d
. Note this is not the end-to-end flow yet.In particular, the convert flow needs to swap the new subgraph
with another one that merges the batchnorm stats back into conv.
The Conv + BN fusion is implemented in the following steps:
Annotate all nodes in the pattern
[conv - bn - getitem]
Match and replace this pattern with the fused QAT pattern
(note that this is a larger subgraph than the original one)
Copy over metadata from the original nodes to the
corresponding nodes in the new subgraph, to ensure the
stack traces and dtype annotations are preserved
Prepare will insert fake quantizes in the right places
based on the annotations
Test Plan:
python test/test_quantization.py TestQuantizePT2E.test_qat_conv_bn_fusion
Reviewers: jerryzh168, kimishpatel, yanboliang
cc @soumith @voznesenskym @penguinwu @anijain2305 @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @Xia-Weiwen @wenzhe-nrv @jiayisunx @desertfire