-
Notifications
You must be signed in to change notification settings - Fork 23.3k
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
Add better performing versions for groupwise and depthwise convolutions #22869
Conversation
2c873f7
to
330c32f
Compare
330c32f
to
eb51d56
Compare
Did you benchmark 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.
Please add a benchmark test for the kernels and add the benchmarking results before and after the change as part of documentation for this PR. Thanks!
torch/nn/quantized/modules/conv.py
Outdated
@@ -64,7 +64,7 @@ def weight(self): | |||
|
|||
@weight.setter | |||
def weight(self, w): | |||
self._packed_weight = torch.ops.quantized.fbgemm_conv_prepack(w, self.groups) | |||
self._packed_weight = torch.ops.quantized.fbgemm_conv_prepack(w, self.stride, self.padding, self.dilation, self.groups) |
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.
an unrelated question: do we have unpack for conv?
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.
@jerryzh168
We made sure to add unpack for conv. Details in pytorch/FBGEMM#103, pytorch/FBGEMM#105, pytorch/FBGEMM#106, pytorch/FBGEMM@815139b, pytorch/FBGEMM@64a2c73
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.
is this ready or still ongoing?
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 I saw qconv_unpack, Thanks
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 is ready. I might have to change your qat modules if they have landed.
eb51d56
to
90a9501
Compare
90a9501
to
27a82ef
Compare
27a82ef
to
2536c1a
Compare
Sure. I'll add benchmarking results in the summary. I have a followup PR that adds benchmarking. #22895 |
2536c1a
to
2bb6f94
Compare
2bb6f94
to
8f80e17
Compare
@raghuramank100 Please see summary for before and after results. |
8f80e17
to
0e90e00
Compare
0e90e00
to
56bfd08
Compare
@@ -99,11 +99,10 @@ class QConv2dInt8 final : public c10::OperatorKernel { | |||
PackedConvWeight& pack_ptr = | |||
cpp_custom_type_hack::cast<PackedConvWeight>(packed_weight); | |||
auto packB = pack_ptr.w.get(); | |||
// packB->printPackedMatrix("PackedB inside QConv2dInt8:"); |
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.
Still keep this for debugging purpose? Do we have printPackedMatrix function in the general Conv interface?
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.
We don't. Let me remove this.
56bfd08
to
0929b35
Compare
0929b35
to
c44fc34
Compare
c44fc34
to
3436652
Compare
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.
@dskhudia is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
3436652
to
9cb81dc
Compare
…ns (pytorch#22869) Summary: Groupwise and depthwise convolutions become faster with this diff Pull Request resolved: pytorch#22869 Test Plan: buck test mode/dev caffe2/test:quantized -- 'test_qconv' --print-passing-details ``` Running 2 tests Started new test run: https://our.intern.facebook.com/intern/testinfra/testrun/562950091484224 ✓ caffe2/test:quantized - test_qconv (test_quantized.TestQuantizedConv) 2.731 1/2 (passed) Test output: > test_qconv (test_quantized.TestQuantizedConv) ... ok > > ---------------------------------------------------------------------- > Ran 1 test in 2.732s > > OK ✓ caffe2/test:quantized - test_qconv_unpack (test_quantized.TestQuantizedConv) 5.187 2/2 (passed) Test output: > test_qconv_unpack (test_quantized.TestQuantizedConv) ... ok > > ---------------------------------------------------------------------- > Ran 1 test in 5.188s > > OK Finished test run: https://our.intern.facebook.com/intern/testinfra/testrun/562950091484224 Summary (total time 15.66s): PASS: 2 FAIL: 0 SKIP: 0 FATAL: 0 TIMEOUT: 0 OMIT: 0 ``` buck test mode/dev caffe2/test:quantized -- 'test_conv_api' ``` Running 2 tests Started new test run: https://our.intern.facebook.com/intern/testinfra/testrun/3940649676010406 ✓ caffe2/test:quantized - test_conv_api (test_nn_quantized.ModuleAPITest) 0.040 1/2 (passed) ✓ caffe2/test:quantized - test_conv_api (test_quantized_conv.FunctionalAPITest) 5.402 2/2 (passed) Finished test run: https://our.intern.facebook.com/intern/testinfra/testrun/3940649676010406 Summary (total time 11.83s): PASS: 2 FAIL: 0 SKIP: 0 FATAL: 0 TIMEOUT: 0 OMIT: 0 ``` Differential Revision: D16264144 Pulled By: dskhudia fbshipit-source-id: 959417212f99d3789c2b48361dd36cb864db3594
9cb81dc
to
2484c80
Compare
…ns (#22869) Summary: Groupwise and depthwise convolutions become faster with this diff Pull Request resolved: pytorch/pytorch#22869 Test Plan: buck test mode/dev caffe2/test:quantized -- 'test_qconv' --print-passing-details ``` Running 2 tests Started new test run: https://our.intern.facebook.com/intern/testinfra/testrun/562950091484224 ✓ caffe2/test:quantized - test_qconv (test_quantized.TestQuantizedConv) 2.731 1/2 (passed) Test output: > test_qconv (test_quantized.TestQuantizedConv) ... ok > > ---------------------------------------------------------------------- > Ran 1 test in 2.732s > > OK ✓ caffe2/test:quantized - test_qconv_unpack (test_quantized.TestQuantizedConv) 5.187 2/2 (passed) Test output: > test_qconv_unpack (test_quantized.TestQuantizedConv) ... ok > > ---------------------------------------------------------------------- > Ran 1 test in 5.188s > > OK Finished test run: https://our.intern.facebook.com/intern/testinfra/testrun/562950091484224 Summary (total time 15.66s): PASS: 2 FAIL: 0 SKIP: 0 FATAL: 0 TIMEOUT: 0 OMIT: 0 ``` buck test mode/dev caffe2/test:quantized -- 'test_conv_api' ``` Running 2 tests Started new test run: https://our.intern.facebook.com/intern/testinfra/testrun/3940649676010406 ✓ caffe2/test:quantized - test_conv_api (test_nn_quantized.ModuleAPITest) 0.040 1/2 (passed) ✓ caffe2/test:quantized - test_conv_api (test_quantized_conv.FunctionalAPITest) 5.402 2/2 (passed) Finished test run: https://our.intern.facebook.com/intern/testinfra/testrun/3940649676010406 Summary (total time 11.83s): PASS: 2 FAIL: 0 SKIP: 0 FATAL: 0 TIMEOUT: 0 OMIT: 0 ``` Differential Revision: D16264144 Pulled By: dskhudia fbshipit-source-id: 32fa43e5c3d97c8aaa6e0858327a2ac0aef8df5c
Summary: Groupwise and depthwise convolutions become faster with this diff
Differential Revision: D16264144