-
Notifications
You must be signed in to change notification settings - Fork 25.2k
[quant][pt2e] Add support for FixedQParamsQuantizationSpec #102439
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
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/102439
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit cced745: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This pull request was exported from Phabricator. Differential Revision: D46153082 |
This pull request was exported from Phabricator. Differential Revision: D46153082 |
86e06c4
to
f32bf7e
Compare
quant_min=0, | ||
quant_max=255, | ||
qscheme=torch.per_tensor_affine, | ||
scale=2.0 / 256.0, |
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.
Hi @jerryzh168, May I ask a question about this fixed scale and zp value of sigmoid
? The output range of sigmoid
is among 0-1, so why we set the fixed scale as 2.0 / 256.0
and fixed zp as 128
.
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 sorry I think this is not correct, I was trying to copy from https://github.com/pytorch/pytorch/blob/main/torch/ao/quantization/backend_config/_common_operator_config_utils.py but was writing down the wrong parameters, thanks for the comment!
f32bf7e
to
b11336e
Compare
This pull request was exported from Phabricator. Differential Revision: D46153082 |
b11336e
to
1821274
Compare
This pull request was exported from Phabricator. Differential Revision: D46153082 |
1821274
to
48a72dc
Compare
This pull request was exported from Phabricator. Differential Revision: D46153082 |
…02439) Summary: Pull Request resolved: pytorch#102439 This PR adds support for FixedQParamsQuantizationSpec: ``` dataclass(eq=True, frozen=True) class FixedQParamsQuantizationSpec(QuantizationSpecBase): dtype: torch.dtype scale: float zero_point: int quant_min: Optional[int] = None quant_max: Optional[int] = None qscheme: Optional[torch.qscheme] = None ``` This is useful to define quantization spec for operators like sigmoid which has predefined and fixed scale/zero_point Test Plan: ``` buck2 test mode/opt caffe2/test:quantization_pt2e -- 'caffe2/test:quantization_pt2e' buck2 test mode/opt caffe2/test:quantization_pt2e -- --exact 'caffe2/test:quantization_pt2e - test_fixed_qparams_qspec (quantization.pt2e.test_quantize_pt2e.TestQuantizePT2E)' ``` Reviewed By: kimishpatel Differential Revision: D46153082 fbshipit-source-id: efe352792d9b178648423da04264b89f7bf35923
This pull request was exported from Phabricator. Differential Revision: D46153082 |
48a72dc
to
cced745
Compare
@pytorchbot merge (Initiating merge automatically since Phabricator Diff has merged) |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Summary:
This PR adds support for FixedQParamsQuantizationSpec:
This is useful to define quantization spec for operators like sigmoid which has predefined and fixed scale/zero_point
Test Plan:
Reviewed By: kimishpatel
Differential Revision: D46153082