Skip to content

Clarify post training quantization behaviour #2778

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

Merged
merged 10 commits into from
Mar 11, 2024

Conversation

jmarintur
Copy link
Contributor

@jmarintur jmarintur commented Feb 23, 2024

Fixes #2725

Description

This PR clarifies post training quantization behaviour

Checklist

  • The issue that is being fixed is referred in the description (see above "Fixes #ISSUE_NUMBER")
  • Only one issue is addressed in this pull request
  • Labels from the issue that this PR is fixing are added to this pull request
  • No unnecessary issues are included into this pull request.

Copy link

pytorch-bot bot commented Feb 23, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/tutorials/2778

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

✅ No Failures

As of commit 3d04f5f with merge base 630c2e2 (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
Copy link
Contributor

Hi @jmarintur!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@@ -81,7 +81,7 @@ The full documentation of the `quantize_dynamic` API call is `here <https://pyto
3. Post Training Static Quantization
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This method converts both the weights and the activations to 8-bit integers beforehand so there won't be on-the-fly conversion on the activations during the inference, as the dynamic quantization does, hence improving the performance significantly.
This method converts both the weights and the activations to 8-bit integers beforehand so there wont be on-the-fly conversion on the activations during the inference, as the dynamic quantization does. While post-training static quantization can significantly enhance inference speed and reduce model size, this method may degrade the original model's performance.
Copy link
Contributor

@jerryzh168 jerryzh168 Feb 26, 2024

Choose a reason for hiding this comment

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

makes sense, can you clarify a little bit more, e.g.:

this method may degrade the original model's accuracy more compared to dynamic quantization. 

we use accuracy instead of performance, since performance could refer to inference speed and accuracy

Copy link
Contributor Author

@jmarintur jmarintur Feb 26, 2024

Choose a reason for hiding this comment

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

Hi @jerryzh168, what about adding this at the end:

Converting weights and activation functions to 8-bit integers can slightly alter the network's behavior and activation responses, leading to such variations in accuracy.

Choose a reason for hiding this comment

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

Like it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @jerryzh168, I've just pushed a few changes, please let me know if you have any other suggestions. Thank you!

Copy link
Contributor

Choose a reason for hiding this comment

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

@jmarintur "Converting weights and activation functions to 8-bit integers can slightly alter the network's behavior and activation responses, leading to such variations in accuracy." this is true for any quantization method, so probably better to remove I feel

@jmarintur jmarintur requested a review from usteiner9 February 29, 2024 21:56
@jmarintur jmarintur requested a review from jerryzh168 March 11, 2024 21:40
Copy link
Contributor

@jerryzh168 jerryzh168 left a comment

Choose a reason for hiding this comment

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

thanks!

@svekars svekars merged commit 8c48ada into pytorch:main Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

confusion in Tutorials > Quantization Recipe
5 participants