Skip to content
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

Add general fake_quantize_affine op #492

Merged
merged 1 commit into from
Jul 11, 2024
Merged

Conversation

andrewor14
Copy link
Contributor

Summary: Add a general fake_quantize_affine op that simulates quantize_affine + dequantize_affine but without casting the intermediate quantized values to lower bit-widths, intended for quantization-aware training (QAT).

Test Plan:
python test/quantization/test_quant_primitives.py -k test_fake_quantize_affine

Copy link

pytorch-bot bot commented Jul 9, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/492

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

✅ No Failures

As of commit 9c60424 with merge base 12ac498 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 9, 2024
@@ -335,6 +378,62 @@ def _dequantize_affine(

return dequant.view(original_shape).to(output_dtype)


def _fake_quantize_affine(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be a top level quant primitive I think

Summary: Add a general `fake_quantize_affine` op that simulates
`quantize_affine` + `dequantize_affine` but without casting the
intermediate quantized values to lower bit-widths, intended for
quantization-aware training (QAT).

Test Plan:
python test/quantization/test_quant_primitives.py -k test_fake_quantize_affine
@andrewor14 andrewor14 merged commit 2ed010a into main Jul 11, 2024
13 checks passed
dbyoung18 pushed a commit to dbyoung18/ao that referenced this pull request Jul 31, 2024
Summary: Add a general `fake_quantize_affine` op that simulates
`quantize_affine` + `dequantize_affine` but without casting the
intermediate quantized values to lower bit-widths, intended for
quantization-aware training (QAT).

Test Plan:
python test/quantization/test_quant_primitives.py -k test_fake_quantize_affine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants