-
Notifications
You must be signed in to change notification settings - Fork 22.2k
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
quantization: fix scale+zp serialization of quantized BatchNorm{2|3}d #70432
Conversation
Summary: Not for review yet. Scale and zero_point need to be buffers for serialization to work on them properly. For now, this PR fixes the issue without dealing with BC, just so we can run CI and see how many callsites expect the old behavior. CI results will determine next steps. Test Plan: ``` python test/test_quantization.py TestStaticQuantizedModule.test_batch_norm2d_serialization ``` Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
CI Flow Status⚛️ CI FlowRuleset - Version:
You can add a comment to the PR and tag @pytorchbot with the following commands: # ciflow rerun, "ciflow/default" will always be added automatically
@pytorchbot ciflow rerun
# ciflow rerun with additional labels "-l <ciflow/label_name>", which is equivalent to adding these labels manually and trigger the rerun
@pytorchbot ciflow rerun -l ciflow/scheduled -l ciflow/slow For more information, please take a look at the CI Flow Wiki. |
Summary: Not for review yet. Scale and zero_point need to be buffers for serialization to work on them properly. For now, this PR fixes the issue without dealing with BC, just so we can run CI and see how many callsites expect the old behavior. CI results will determine next steps. Test Plan: ``` python test/test_quantization.py TestStaticQuantizedModule.test_batch_norm2d_serialization ``` Reviewers: Subscribers: Tasks: Tags: ghstack-source-id: cdbf2362c95f4ff33547aa84cc669cb5d1dc51b1 Pull Request resolved: #70432
🔗 Helpful links
💊 CI failures summary and remediationsAs of commit 0bee19a (more details on the Dr. CI page):
🕵️ 1 new failure recognized by patternsThe following CI failures do not appear to be due to upstream breakages: linux-xenial-cuda11.3-py3.7-gcc7 / test (fx2trt, 1, 1, linux.4xlarge.nvidia.gpu) (1/1)Step: "Test" (full log | diagnosis details | 🔁 rerun)
|
@vkuzo has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
…3}d" Summary: Not for review yet. Scale and zero_point need to be buffers for serialization to work on them properly. For now, this PR fixes the issue without dealing with BC, just so we can run CI and see how many callsites expect the old behavior. CI results will determine next steps. Test Plan: ``` python test/test_quantization.py TestStaticQuantizedModule.test_batch_norm2d_serialization ``` Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D33330022](https://our.internmc.facebook.com/intern/diff/D33330022) [ghstack-poisoned]
Summary: Not for review yet. Scale and zero_point need to be buffers for serialization to work on them properly. For now, this PR fixes the issue without dealing with BC, just so we can run CI and see how many callsites expect the old behavior. CI results will determine next steps. Test Plan: ``` python test/test_quantization.py TestStaticQuantizedModule.test_batch_norm2d_serialization ``` Reviewers: Subscribers: Tasks: Tags: ghstack-source-id: 1308837dbdc16ababcca95f6a461372c2ae78060 Pull Request resolved: #70432
@vkuzo has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
…hNorm{2|3}d" Summary: Scale and zero_point need to be buffers for serialization to work on them properly. This PR moves them to buffers. This is BC breaking, but the "before" state was completely broken (scale + zp were not serialized at all) so there is no value in trying to handle it. Test Plan: ``` python test/test_quantization.py TestStaticQuantizedModule.test_batch_norm2d_serialization python test/test_quantization.py TestStaticQuantizedModule.test_batch_norm3d_serialization ``` Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D33330022](https://our.internmc.facebook.com/intern/diff/D33330022) [ghstack-poisoned]
Summary: Scale and zero_point need to be buffers for serialization to work on them properly. This PR moves them to buffers. This is BC breaking, but the "before" state was completely broken (scale + zp were not serialized at all) so there is no value in trying to handle it. Test Plan: ``` python test/test_quantization.py TestStaticQuantizedModule.test_batch_norm2d_serialization python test/test_quantization.py TestStaticQuantizedModule.test_batch_norm3d_serialization ``` Reviewers: Subscribers: Tasks: Tags: ghstack-source-id: 6a3424d0f001431ca38f8ce1c6766fdee6e48f02 Pull Request resolved: #70432
@vkuzo has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
@@ -644,6 +644,50 @@ def test_batch_norm3d(self): | |||
self.assertEqual(quant_ref.int_repr().numpy(), qy.int_repr().numpy(), | |||
msg="BatchNorm3d module API failed") | |||
|
|||
def _test_batch_norm_serialization(self, get_model, data1, data2): | |||
m1 = get_model() | |||
m1.qconfig = torch.quantization.default_qconfig |
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.
nit: torch.ao.quantization
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 good, thanks!
…hNorm{2|3}d" Summary: Scale and zero_point need to be buffers for serialization to work on them properly. This PR moves them to buffers. This is BC breaking, but the "before" state was completely broken (scale + zp were not serialized at all) so there is no value in trying to handle it. Test Plan: ``` python test/test_quantization.py TestStaticQuantizedModule.test_batch_norm2d_serialization python test/test_quantization.py TestStaticQuantizedModule.test_batch_norm3d_serialization ``` Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D33330022](https://our.internmc.facebook.com/intern/diff/D33330022) [ghstack-poisoned]
Summary: Scale and zero_point need to be buffers for serialization to work on them properly. This PR moves them to buffers. This is BC breaking, but the "before" state was completely broken (scale + zp were not serialized at all) so there is no value in trying to handle it. Test Plan: ``` python test/test_quantization.py TestStaticQuantizedModule.test_batch_norm2d_serialization python test/test_quantization.py TestStaticQuantizedModule.test_batch_norm3d_serialization ``` Reviewers: Subscribers: Tasks: Tags: ghstack-source-id: 1649ae2f68bd43b804f29e7fd30f5a132ee9773c Pull Request resolved: #70432
@vkuzo has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Stack from ghstack:
Summary:
Scale and zero_point need to be buffers for serialization to work
on them properly. This PR moves them to buffers. This is BC breaking,
but the "before" state was completely broken (scale + zp were not
serialized at all) so there is no value in trying to handle it.
Test Plan:
Reviewers:
Subscribers:
Tasks:
Tags:
Differential Revision: D33330022