-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[qat] Add FakeQuantize Module #21767
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
Differential Revision: D15728503 Differential Version: 84919348
Differential Revision: D15728503 Differential Version: 84919576
Differential Revision: D15728503 Differential Version: 85103016
Differential Revision: D15375695 Differential Version: 85144759
Differential Revision: D15483071 Differential Version: 85154440
Differential Revision: D15375695 Differential Version: 85155178
Differential Revision: D15554224 Differential Version: 85162142
Differential Revision: D15483071 Differential Version: 85187565
Differential Revision: D15483071 Differential Version: 85213062
Differential Revision: D15554224 Differential Version: 85213957
Differential Revision: D15375695 Differential Version: 85219380
Differential Revision: D15554224 Differential Version: 85217753
Differential Revision: D15554183 Differential Version: 85267282
Differential Revision: D15554183 Differential Version: 85267665
Differential Revision: D15483071 Differential Version: 85322492
Differential Revision: D15554224 Differential Version: 85325488
Differential Revision: D15554224 Differential Version: 85330125
Differential Revision: D15483071 Differential Version: 85331722
Differential Revision: D15375695 Differential Version: 85439410
Differential Revision: D15483071 Differential Version: 85439430
Differential Revision: D15554224 Differential Version: 85439441
Differential Revision: D15554183 Differential Version: 85439445
Differential Revision: D16185556 Differential Version: 86296584
Differential Revision: D16185556 Differential Version: 86309733
Differential Revision: D15728503 Differential Version: 86310060
dzhulgakov
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 close
| Y.copy_(X); // We might want to just return the input here. | ||
| return Y; | ||
| } | ||
| TORCH_CHECK(self.scalar_type() == ScalarType::Float); |
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.
in a sense of generality - anything preventing you supporting other float types?
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 only implemented quantize_linear and dequantize for float right now, but we could also do the double to float conversion when we convert to quantized model. Not sure how valuable it is to support more types though, do we train in double in practice?
| def enalbe(self): | ||
| self.enable_fq = True | ||
|
|
||
| def calculate_qparams(self): |
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: why do you need this method? is it part of public api?
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.
yes, we are using the same signature as Observer
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 need this because of the conversion, in from_float, we'll call calculate_params on observer(fake_quant). see later prs for more context.
Differential Revision: D15728503 Differential Version: 86365862
Differential Revision: D15728503 Differential Version: 86368540
dzhulgakov
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.
build failures look legit
Differential Revision: D15728503 Differential Version: 86404688
Differential Revision: D15728503 Differential Version: 86408181
Differential Revision: D15728503 Differential Version: 86414971
Differential Revision: D15728503 Differential Version: 86421747
Differential Revision: D15728503 Differential Version: 86438127
Differential Revision: D15728503 Differential Version: 86495867
Differential Revision: D15728503 Differential Version: 86499899
dzhulgakov
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 to me module one tiny issue
torch/quantization/fake_quantize.py
Outdated
| self.enabled = True | ||
|
|
||
| def disable(self): | ||
| self.enable(False) |
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.
does it work? I think you're missing the arg for enable
Differential Revision: D15728503 Differential Version: 86507651
|
This pull request has been merged in f7de9be. |
Summary: Pull Request resolved: pytorch/pytorch#21767 Adding FakeQuantize Module for quantization aware training Reviewed By: dzhulgakov Differential Revision: D15728503 fbshipit-source-id: 2a9a6a362812ede3deac42b93dddca35987bd8e6
Stack:
:black_circle: #21767 [qat] Add FakeQuantize Module 💚
Adding FakeQuantize Module
for quantization aware training
Differential Revision: D15728503