Add fake quantize operator that works in backward pass#40532
Add fake quantize operator that works in backward pass#40532durumu wants to merge 7 commits intogh/durumu/6/basefrom
Conversation
[ghstack-poisoned]
💊 CI failures summary and remediationsAs of commit b9993f4 (more details on the Dr. CI page):
🕵️ 7 new failures recognized by patternsThe following CI failures do not appear to be due to upstream breakages (reran 1 job to discount flakiness):
|
Differential Revision: [D22217029](https://our.internmc.facebook.com/intern/diff/D22217029) [ghstack-poisoned]
Differential Revision: [D22217029](https://our.internmc.facebook.com/intern/diff/D22217029) [ghstack-poisoned]
Differential Revision: [D22217029](https://our.internmc.facebook.com/intern/diff/D22217029) [ghstack-poisoned]
Differential Revision: [D22217029](https://our.internmc.facebook.com/intern/diff/D22217029) [ghstack-poisoned]
Differential Revision: [D22217029](https://our.internmc.facebook.com/intern/diff/D22217029) [ghstack-poisoned]
Differential Revision: [D22217029](https://our.internmc.facebook.com/intern/diff/D22217029) [ghstack-poisoned]
|
Unlanding. This broke multiple OSS CI builds. Example failure: |
ghstack-source-id: 331009d Pull Request resolved: pytorch/pytorch#40532 Adds unit test for validating correctness ghstack-source-id: 331009d Pull Request resolved: pytorch/pytorch#40715
Summary: This diff adds FakeQuantizeWithBackward. This works the same way as the regular FakeQuantize module, allowing QAT to occur in the forward pass, except it has an additional quantize_backward parameter. When quantize_backward is enabled, the gradients are fake quantized as well (dynamically, using hard-coded values). This allows the user to see whether there would be a significant loss of accuracy if the gradients were quantized in their model. Pull Request resolved: pytorch#40532 Test Plan: The relevant test for this can be run using `python test/test_quantization.py TestQATBackward.test_forward_and_backward` Reviewed By: supriyar Differential Revision: D22217029 Pulled By: durumu fbshipit-source-id: 7055a2cdafcf022f1ea11c3442721ae146d2b3f2
This diff adds
FakeQuantizeWithBackward. This works the same way as the regularFakeQuantizemodule, allowing QAT to occur in the forward pass, except it has an additionalquantize_backwardparameter. Whenquantize_backwardis enabled, the gradients are fake quantized as well (dynamically, using hard-coded values). This allows the user to see whether there would be a significant loss of accuracy if the gradients were quantized in their model.Stack from ghstack:
Differential Revision: D22217029