-
Notifications
You must be signed in to change notification settings - Fork 229
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
[be] Add SimpleFakeQuantize for QAT #114
Conversation
Summary: This commit adds a simpler version of toq.FakeQuantize to be used for various flavors of QAT. In the future we should deprecate toq.FakeQuantize in favor of this new class. Test Plan: python test/quantization/test_qat_quant_api.py Reviewers: jerryzh168 Subscribers: jerryzh168, supriyar
observer_attrs = [ | ||
"ch_axis", "dtype", "qscheme", "quant_min", "quant_max", | ||
"eps", "is_dynamic", "scale", "zero_point", | ||
] | ||
if name in observer_attrs: | ||
return getattr(self.observer, name) |
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 just use if hasattr(self,observer, name)
instead of hardcoding
def calculate_qparams(self) -> Tuple[torch.Tensor, torch.Tensor]: | ||
return self.observer.calculate_qparams() |
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 could potentially reroute function calls as well I think, maybe add a TODO here?
) | ||
|
||
|
||
class SimpleFakeQuantize(FakeQuantizeBase): |
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.
Do we have docs on what an Observer and a fake quant op is?
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.
Let's spend some time chatting about the higher level design behind this. Do you have some docs I could read up on?
Closing after some offline discussions. We'll put all observation/fq logic in the linear module itself so we don't need another class. |
Update readme Update README.md (pytorch#113) update README.md Update README.md (pytorch#114) Update README.md (pytorch#115) Update Readme.md
Summary: This commit adds a simpler version of toq.FakeQuantize to be used for various flavors of QAT. In the future we should deprecate toq.FakeQuantize in favor of this new class.
Test Plan:
python test/quantization/test_qat_quant_api.py
Reviewers: jerryzh168
Subscribers: jerryzh168, supriyar