-
Notifications
You must be signed in to change notification settings - Fork 24.2k
[quant] fix int16 quantization scale in conv weight #74665
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
Summary: fix int16 quantization scale in conv weight Test Plan: python3 test/test_quantization.py TestQuantizeEagerOps.test_int16_reference_module Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
🔗 Helpful links
💊 CI failures summary and remediationsAs of commit b3a341c (more details on the Dr. CI page):
🕵️ 3 new failures recognized by patternsThe following CI failures do not appear to be due to upstream breakages:
|
Job | Step | Action |
---|---|---|
Test | 🔁 rerun |
This comment was automatically generated by Dr. CI (expand for details).
Please report bugs/suggestions to the (internal) Dr. CI Users group.
@terrychenism has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
In the PR summary, could we provide some context on what specifically was broken, and how you are fixing it? |
data = torch.randn(*input_size, dtype=torch.float) | ||
|
||
original_ref_m = RefM() | ||
torch.quantization.engine = "qnnpack" |
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.
note: not all test environments will support qnnpack. You can check for this with "qnnpack" in torch.testing._internal.common_quantized.supported_qengines
, and skip the test if this is false
@@ -98,11 +98,11 @@ def _quantize_weight( | |||
return weight | |||
|
|||
if weight_qscheme == torch.per_tensor_affine: | |||
if weight_dtype in [torch.quint8, torch.qint8, torch.qint32]: | |||
if weight_dtype in [torch.quint8, torch.qint8, torch.qint32, torch.qint32]: |
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.qint32 already included before for this one
@@ -16,7 +16,7 @@ def _init_weight_qparams(self, weight_qparams, device): | |||
None, torch.per_tensor_affine, torch.per_channel_affine, | |||
torch.per_channel_affine_float_qparams], \ | |||
Exception(f"qscheme: {self.weight_qscheme} is not support in reference quantized {self._get_name()}") | |||
if self.weight_dtype in [torch.quint8, torch.qint8, torch.quint4x2]: | |||
if self.weight_dtype in [torch.quint8, torch.qint8, torch.quint4x2, torch.qint32]: |
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.
can we add a warning on L37 in the else branch to enable the user to find this easier next time?
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 think we can add an assert, the else
branch should not be executed, it is added just for torchscript
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 added 'if-else' back due to one of fx test cases needs torch.float, so it will call 'else'
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.
TestQuantizeFx.test_dynamic_with_fusion_multiple_uses
Summary: fix int16 quantization scale in conv weight before pr, ref_module.conv.get_quantized_weight() in qint32 dtype will get scale = 1.0. fixed by add qint32 support in set/get weight function for reference module Test Plan: python3 test/test_quantization.py TestQuantizeEagerOps.test_int16_reference_module Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D35106497](https://our.internmc.facebook.com/intern/diff/D35106497) [ghstack-poisoned]
@terrychenism has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
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 overall, had two inline comments, please address them before landing
Summary: fix int16 quantization scale in conv weight before pr, ref_module.conv.get_quantized_weight() in qint32 dtype will get scale = 1.0. fixed by add qint32 support in set/get weight function for reference module Test Plan: python3 test/test_quantization.py TestQuantizeEagerOps.test_int16_reference_module Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D35106497](https://our.internmc.facebook.com/intern/diff/D35106497) [ghstack-poisoned]
Summary: fix int16 quantization scale in conv weight before pr, ref_module.conv.get_quantized_weight() in qint32 dtype will get scale = 1.0. fixed by add qint32 support in set/get weight function for reference module Test Plan: python3 test/test_quantization.py TestQuantizeEagerOps.test_int16_reference_module Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D35106497](https://our.internmc.facebook.com/intern/diff/D35106497) [ghstack-poisoned]
@terrychenism has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Summary: fix int16 quantization scale in conv weight before pr, ref_module.conv.get_quantized_weight() in qint32 dtype will get scale = 1.0. fixed by add qint32 support in set/get weight function for reference module Test Plan: python3 test/test_quantization.py TestQuantizeEagerOps.test_int16_reference_module Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D35106497](https://our.internmc.facebook.com/intern/diff/D35106497) [ghstack-poisoned]
@terrychenism has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Summary: fix int16 quantization scale in conv weight before pr, ref_module.conv.get_quantized_weight() in qint32 dtype will get scale = 1.0. fixed by add qint32 support in set/get weight function for reference module Test Plan: python3 test/test_quantization.py TestQuantizeEagerOps.test_int16_reference_module Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D35106497](https://our.internmc.facebook.com/intern/diff/D35106497) [ghstack-poisoned]
@terrychenism has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Summary: fix int16 quantization scale in conv weight before pr, ref_module.conv.get_quantized_weight() in qint32 dtype will get scale = 1.0. fixed by add qint32 support in set/get weight function for reference module Test Plan: python3 test/test_quantization.py TestQuantizeEagerOps.test_int16_reference_module Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D35106497](https://our.internmc.facebook.com/intern/diff/D35106497) [ghstack-poisoned]
@terrychenism has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Summary: fix int16 quantization scale in conv weight before pr, ref_module.conv.get_quantized_weight() in qint32 dtype will get scale = 1.0. fixed by add qint32 support in set/get weight function for reference module Test Plan: python3 test/test_quantization.py TestQuantizeEagerOps.test_int16_reference_module Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D35106497](https://our.internmc.facebook.com/intern/diff/D35106497) [ghstack-poisoned]
@terrychenism has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Summary: fix int16 quantization scale in conv weight before pr, ref_module.conv.get_quantized_weight() in qint32 dtype will get scale = 1.0. fixed by add qint32 support in set/get weight function for reference module Test Plan: python3 test/test_quantization.py TestQuantizeEagerOps.test_int16_reference_module Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D35106497](https://our.internmc.facebook.com/intern/diff/D35106497) [ghstack-poisoned]
@terrychenism has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Summary: fix int16 quantization scale in conv weight before pr, ref_module.conv.get_quantized_weight() in qint32 dtype will get scale = 1.0. fixed by add qint32 support in set/get weight function for reference module Test Plan: python3 test/test_quantization.py TestQuantizeEagerOps.test_int16_reference_module Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D35106497](https://our.internmc.facebook.com/intern/diff/D35106497) [ghstack-poisoned]
@terrychenism has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Summary: fix int16 quantization scale in conv weight before pr, ref_module.conv.get_quantized_weight() in qint32 dtype will get scale = 1.0. fixed by add qint32 support in set/get weight function for reference module Test Plan: python3 test/test_quantization.py TestQuantizeEagerOps.test_int16_reference_module Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D35106497](https://our.internmc.facebook.com/intern/diff/D35106497) [ghstack-poisoned]
@terrychenism has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Summary: Pull Request resolved: #74665 fix int16 quantization scale in conv weight Test Plan: python3 test/test_quantization.py TestQuantizeEagerOps.test_int16_reference_module Imported from OSS Reviewed By: mrshenli Differential Revision: D35106497 fbshipit-source-id: 61030786d20d845ef36ea40cdacdd7dcccf12ae9
Hey @terrychenism. |
Stack from ghstack (oldest at bottom):
Summary:
fix int16 quantization scale in conv weight
before pr, ref_module.conv.get_quantized_weight() in qint32 dtype will get scale = 1.0.
fixed by add qint32 support in set/get weight function for reference module
Test Plan:
python3 test/test_quantization.py TestQuantizeEagerOps.test_int16_reference_module
Reviewers:
Subscribers:
Tasks:
Tags:
Differential Revision: D35106497