-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[Quant] Refactor reference module mapping #72755
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: Add is_refernece flag in convert function Test Plan: python3 test/test_quantization.py TestQuantizeEagerOps.test_conv_transpose_2d Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
CI Flow Status⚛️ CI FlowRuleset - Version:
|
🔗 Helpful links
💊 CI failures summary and remediationsAs of commit d2d938e (more details on the Dr. CI page): 💚 💚 Looks good so far! There are no failures yet. 💚 💚 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. |
Summary: Add is_refernece flag in convert function Test Plan: python3 test/test_quantization.py TestQuantizeEagerOps.test_conv_transpose_2d Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D34188856](https://our.internmc.facebook.com/intern/diff/D34188856) [ghstack-poisoned]
|
@terrychenism has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
torch/ao/quantization/quantize.py
Outdated
| if is_reference: | ||
| mapping = get_default_static_quant_reference_module_mappings() |
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 should do this in _convert, to keep everything in the same place
Summary: Add is_refernece flag in convert function Test Plan: python3 test/test_quantization.py TestQuantizeEagerOps.test_conv_transpose_2d Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D34188856](https://our.internmc.facebook.com/intern/diff/D34188856) [ghstack-poisoned]
Summary: Add is_refernece flag in convert function Test Plan: python3 test/test_quantization.py TestQuantizeEagerOps.test_conv_transpose_2d Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D34188856](https://our.internmc.facebook.com/intern/diff/D34188856) [ghstack-poisoned]
Summary: Add is_refernece flag in convert function Test Plan: python3 test/test_quantization.py TestQuantizeEagerOps.test_conv_transpose_2d Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D34188856](https://our.internmc.facebook.com/intern/diff/D34188856) [ghstack-poisoned]
|
@terrychenism has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Summary: Add is_refernece flag in convert function Test Plan: python3 test/test_quantization.py TestQuantizeEagerOps.test_conv_transpose_2d Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D34188856](https://our.internmc.facebook.com/intern/diff/D34188856) [ghstack-poisoned]
|
@terrychenism has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
| module, mapping=None, inplace=False, remove_qconfig=True, | ||
| convert_custom_config_dict=None): | ||
| is_reference=False, convert_custom_config_dict=None): | ||
| r"""Converts submodules in input module to a different module according to `mapping` |
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.
maybe add some docs for is_reference flag?
jerryzh168
left a comment
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, would be better to have a more detailed summary message as well. e.g. talk about the motivation and impact of the change and how the is_reference flag is implemented
torch/ao/quantization/quantize.py
Outdated
| if is_reference: | ||
| mapping = get_default_static_quant_reference_module_mappings() |
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.
actually not like this, this should go within the L530 branch I think
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.
user should be able to overwrite the default mapping with explicit mappings, if user do not provide any mapping, we can provide a default mapping based on is_reference flag
jerryzh168
left a comment
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.
need to change the place for is_reference check in _convert function
Summary: Add is_refernece flag in convert function Test Plan: python3 test/test_quantization.py TestQuantizeEagerOps.test_conv_transpose_2d Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D34188856](https://our.internmc.facebook.com/intern/diff/D34188856) [ghstack-poisoned]
|
@terrychenism has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
torch/ao/quantization/quantize.py
Outdated
| """ | ||
| if mapping is None: | ||
| mapping = get_default_static_quant_module_mappings() | ||
| if is_reference: |
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: the following is a little bit better
if is_reference:
...
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.
or just a single line with
mapping = xxx if is_reference else yyy
Summary: Add is_refernece flag in convert function Test Plan: python3 test/test_quantization.py TestQuantizeEagerOps.test_conv_transpose_2d Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D34188856](https://our.internmc.facebook.com/intern/diff/D34188856) [ghstack-poisoned]
|
@terrychenism has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Summary: 1. Add is_reference flag in convert function if is_reference = true, using the default reference module mapping 2. add linear reference module and test case Test Plan: python3 test/test_quantization.py TestQuantizeEagerOps.test_conv_transpose_2d Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D34188856](https://our.internmc.facebook.com/intern/diff/D34188856) [ghstack-poisoned]
|
@terrychenism has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Summary: 1. Add is_reference flag in convert function if is_reference = true, using the default reference module mapping 2. add linear reference module and test case Test Plan: python3 test/test_quantization.py TestQuantizeEagerOps.test_conv_transpose_2d Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D34188856](https://our.internmc.facebook.com/intern/diff/D34188856) [ghstack-poisoned]
|
@terrychenism has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Summary: 1. Add is_reference flag in convert function if is_reference = true, using the default reference module mapping 2. add linear reference module and test case Test Plan: python3 test/test_quantization.py TestQuantizeEagerOps.test_conv_transpose_2d Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D34188856](https://our.internmc.facebook.com/intern/diff/D34188856) [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: #72755 Add is_refernece flag in convert function Test Plan: python3 test/test_quantization.py TestQuantizeEagerOps.test_conv_transpose_2d Imported from OSS Reviewed By: mruberry Differential Revision: D34188856 fbshipit-source-id: 291014a7b3b4d4b40ca0ca76a80711097dcc4b58
|
Hey @terrychenism. |
Summary: Pull Request resolved: pytorch/pytorch#72755 Add is_refernece flag in convert function Test Plan: python3 test/test_quantization.py TestQuantizeEagerOps.test_conv_transpose_2d Imported from OSS Reviewed By: mruberry Differential Revision: D34188856 fbshipit-source-id: 291014a7b3b4d4b40ca0ca76a80711097dcc4b58 (cherry picked from commit cfba3b8dc0373708712c0d847d590f0d587df002)
Summary: Pull Request resolved: pytorch/pytorch#72755 Add is_refernece flag in convert function Test Plan: python3 test/test_quantization.py TestQuantizeEagerOps.test_conv_transpose_2d Imported from OSS Reviewed By: mruberry Differential Revision: D34188856 fbshipit-source-id: 291014a7b3b4d4b40ca0ca76a80711097dcc4b58 (cherry picked from commit cfba3b8dc0373708712c0d847d590f0d587df002)
Stack from ghstack (oldest at bottom):
Summary:
Add is_reference flag in convert function
if is_reference = true, using the default reference module mapping
add linear reference module and test case
Test Plan:
python3 test/test_quantization.py TestQuantizeEagerOps.test_conv_transpose_2d
Reviewers:
Subscribers:
Tasks:
Tags:
Differential Revision: D34188856