8000 [quant] Move dropout replacement to `move_model_to_eval` (#108184) by andrewor14 · Pull Request #108255 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

[quant] Move dropout replacement to move_model_to_eval (#108184) #108255

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 1 commit into from
Sep 5, 2023

Conversation

andrewor14
Copy link
Contributor

Summary: This commit adds a public facing
torch.ao.quantization.move_model_to_eval util function for QAT users. Instead of calling model.eval() on an exported model (which doesn't work, see #103681), the user would call this new util function instead. This ensures special ops such as dropout and batchnorm (not supported yet) will have the right behavior when the graph is later used for inference.

Note: Support for an equivalent move_model_to_train will be added in the future. This is difficult to do for dropout currently because the eval pattern of dropout is simply a clone op, which we cannot just match and replace with a dropout op.

Test Plan:
python test/test_quantization.py TestQuantizePT2E.test_move_model_to_eval

Reviewers: jerryzh168, kimishpatel

Subscribers: jerryzh168, kimishpatel, supriyar

Differential Revision: D48814735
Pull Request resolved: #108184
Approved by: https://github.com/jerryzh168

Summary: This commit adds a public facing
`torch.ao.quantization.move_model_to_eval` util function
for QAT users. Instead of calling model.eval() on an exported
model (which doesn't work, see
#103681), the user
would call this new util function instead. This ensures special
ops such as dropout and batchnorm (not supported yet) will have
the right behavior when the graph is later used for inference.

Note: Support for an equivalent `move_model_to_train` will be
added in the future. This is difficult to do for dropout
currently because the eval pattern of dropout is simply a clone
op, which we cannot just match and replace with a dropout op.

Test Plan:
python test/test_quantization.py TestQuantizePT2E.test_move_model_to_eval

Reviewers: jerryzh168, kimishpatel

Subscribers: jerryzh168, kimishpatel, supriyar

Differential Revision: [D48814735](https://our.internmc.facebook.com/intern/diff/D48814735)
Pull Request resolved: #108184
Approved by: https://github.com/jerryzh168
@andrewor14 andrewor14 requested a review from jerryzh168 as a code owner August 30, 2023 17:30
@github-actions github-actions bot added the release notes: quantization release notes category label Aug 30, 2023
@pytorch-bot
Copy link
pytorch-bot bot commented Aug 30, 2023

🔗 Helpful Links

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

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

❌ 1 New Failure, 16 Pending

As of commit 041320a with merge base 138e289 (image):

NEW FAILURE - The following job has failed:

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

@andrewor14 andrewor14 added the module: correctness (silent) issue that returns an incorrect result silently label Sep 5, 2023
@osalpekar osalpekar merged commit 04c1e07 into release/2.1 Sep 5, 2023
@github-actions github-actions bot deleted the move_model_to_eval_2.1 branch March 1, 2025 02:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: correctness (silent) issue that returns an incorrect result silently release notes: quantization release notes category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0