-
Notifications
You must be signed in to change notification settings - Fork 31.7k
update test_can_load_with_global_device_set with a hack
#37553
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
Conversation
|
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the |
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Cyrilvallez
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kind of convoluted (not your fault haha)... Don't you think that simply running in a subprocess would be better?
|
yeah, i didn't see it is decorated with |
Cyrilvallez
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, LGTM! Much simpler and foolproof! Let's just add a small comment about why we're doing it!
Co-authored-by: Cyril Vallez <[email protected]>
…gface#37553) * fix * fix * fix * Update tests/test_modeling_common.py Co-authored-by: Cyril Vallez <[email protected]> * fix --------- Co-authored-by: ydshieh <[email protected]> Co-authored-by: Cyril Vallez <[email protected]>
* fix * trigger CI --------- Co-authored-by: ydshieh <[email protected]>
…gface#37553) * fix * fix * fix * Update tests/test_modeling_common.py Co-authored-by: Cyril Vallez <[email protected]> * fix --------- Co-authored-by: ydshieh <[email protected]> Co-authored-by: Cyril Vallez <[email protected]>
* fix * trigger CI --------- Co-authored-by: ydshieh <[email protected]>
What does this PR do?
torch.set_default_devicehas some unexpected impacts on other tests even if we try to restore the origin value by calling it at the end of the test. See #37551 for one example that is fixed there.This PR uses
torch._GLOBAL_DEVICE_CONTEXTto do something more close to the internal mechanism intorch.set_default_deviceto perform the cleanup, seehttps://github.com/pytorch/pytorch/blob/e229ce34c4ab8cd4e2800227615be32fb362b1e6/torch/__init__.py#L1205-L1218
Running
will pass on this PR while it fails on the base commit (b33edf1) of this PR.