-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[MPS] Add Python Module Bindings for the MPS backend #94417
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
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/94417
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 FailuresAs of commit 2ba30c2: NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
I'm working on a fix to address CI failures on other backends caused by this PR. |
malfet
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.
Some parts of the code is re-exporting MPS properties which are already available in torch.backends.mps package and also copy-n-pastes anti-patterns from old days of CUDA.(like lazy-init)
Please request re-review when this feedback is addressed.
5c1d31f to
60437cd
Compare
|
Sounds pretty good. Thanks for the changes. Only small things. |
fefd8ae to
dc46d04
Compare
albanD
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.
Sounds good!
Thanks for the updates.
|
@pytorchbot rebase |
|
@pytorchbot successfully started a rebase job. Check the current status here |
|
Tried to rebase and push PR #94417, but it was already up to date |
|
The dynamo CI failure is unrelated to this PR and is due to following failed issue #89395. |
|
@pytorchbot merge -f "Lint and MPS tests are green" |
Merge startedYour change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
- Enable global manual seeding via torch.manual_seed() + test case - Add torch.mps.synchronize() to wait for MPS stream to finish + test case - Enable the following python interfaces for MPS: torch.mps.get_rng_state() torch.mps.set_rng_state() torch.mps.is_available() torch.mps.synchronize() torch.mps.manual_seed() torch.mps.seed() torch.mps.is_initialized() torch.mps.init()
- This patch fixes a regression caused by recent MPS module interface. Since we now compile torch._C.is_mps_available() only if USE_MPS is defined, then it may cause failures on CUDA (and other devices when USE_MPS is not defined) if we upstream. So, this patch checks if is_mps_available is implemented first and then calls it. - Also use the unique name `default_mps_generator` to avoid conflicts with CPU default generator
- Removed USE_MPS condition when adding python binding definitions - Replaced the global attribute setting of default_mps_generator with torch.C_._mps_get_default_generator() - Removed redundant hasattr() checks - Error out in MPSHooks::isOnMacOS13orNewer() if MPS not available - Removed is_available() and is_macos13_or_newer() from torch.mps (already exists in torch.backends.mps)
This should fix the failure with test_public_bindings.py
- Remove import torch.mps from test_mps - Add torch::mps namespace
|
Successfully rebased |
cc771b7 to
2ba30c2
Compare
|
Thanks @huydhn. The commit 2ba30c2 should fix the problem with the bad forking problem. I tested with |
|
You can add |
|
@pytorchbot merge -g |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
kulinseth
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.
Looks good.
torch.manual_seed()+ test casetorch.mps.synchronize()to wait for MPS stream to finish + test casetorch.mps.[get_rng_state(), set_rng_state(), synchronize(), manual_seed(), seed()]mps.rstto document thetorch.mpsmodule.test_public_bindings.pyDescription of new files added:
torch/csrc/mps/Module.cpp: implementstorch._Cmodule functions fortorch.mpsandtorch.backends.mps.torch/mps/__init__.py: implements Python bindings fortorch.mpsmodule.