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

[quant][pt2] Fix and rename move_model_to_eval (#108891) #109027

Merged
merged 1 commit into from Sep 11, 2023

Conversation

andrewor14
Copy link
Contributor

@andrewor14 andrewor14 commented Sep 11, 2023

Summary:
This commit fixes two silent correctness problems with the current implementation of move_model_to_eval:

(1) Previously the user had to manually call eliminate_dead_code before calling move_model_to_eval, otherwise the dropout pattern won't actually get eliminated. This is because subgraph rewriter complains the match is not self-contained, and so silently does not do the replacement.

(2) We wish to error when the user calls model.train() or model.eval() on an exported model. This error is raised correctly immediately after export today, but no longer raised after the user calls prepare or convert.

We fix (1) by moving the eliminate_dead_code call into move_model_to_eval, and fix (2) by ensuring the respective errors are thrown after prepare and convert as well.

Additionally, this commit renames move_model_to_eval to move_exported_model_to_eval to be more explicit.

Test Plan:
python test/test_quantization.py TestQuantizePT2E.test_disallow_eval_train
python test/test_quantization.py TestQuantizePT2E.test_move_exported_model_to_eval

Imported from OSS

Differential Revision: D49097293

Pull Request resolved: #108891
Approved by: https://github.com/jerryzh168

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @Xia-Weiwen @wenzhe-nrv @jiayisunx @peterbell10 @ipiszy @ngimel @yf225 @chenyang78 @kadeng @muchulee8 @aakhundov

@pytorch-bot
Copy link

pytorch-bot bot commented Sep 11, 2023

🔗 Helpful Links

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

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

✅ No Failures

As of commit dbb26dc with merge base 138e289 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@pytorch-bot pytorch-bot bot added the release notes: quantization release notes category label Sep 11, 2023
@andrewor14 andrewor14 added the module: correctness (silent) issue that returns an incorrect result silently label Sep 11, 2023
@github-actions github-actions bot added module: inductor and removed module: correctness (silent) issue that returns an incorrect result silently labels Sep 11, 2023
Summary:
This commit fixes two silent correctness problems with
the current implementation of `move_model_to_eval`:

(1) Previously the user had to manually call `eliminate_dead_code`
before calling `move_model_to_eval`, otherwise the dropout pattern
won't actually get eliminated. This is because subgraph rewriter
complains the match is not self-contained, and so silently does
not do the replacement.

(2) We wish to error when the user calls `model.train()` or
`model.eval()` on an exported model. This error is raised
correctly immediately after export today, but no longer raised
after the user calls prepare or convert.

We fix (1) by moving the `eliminate_dead_code` call into
`move_model_to_eval`, and fix (2) by ensuring the respective
errors are thrown after prepare and convert as well.

Additionally, this commit renames `move_model_to_eval` to
`move_exported_model_to_eval` to be more explicit.

bypass-github-export-checks

Test Plan:
python test/test_quantization.py TestQuantizePT2E.test_disallow_eval_train
python test/test_quantization.py TestQuantizePT2E.test_move_exported_model_to_eval

Imported from OSS

Differential Revision: D49097293

Pull Request resolved: #108891
Approved by: https://github.com/jerryzh168
@atalman atalman merged commit 7e23b49 into release/2.1 Sep 11, 2023
86 checks passed
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.

None yet

2 participants