-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[MPS] Add support for autocast in MPS #99272
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/99272
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit c5aec31 with merge base 71383dd ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
786f3f1 to
424cf41
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 pretty good. Mostly questions about testing.
| m.fallback(torch::CppFunction::makeFallthrough()); | ||
| } | ||
|
|
||
| TORCH_LIBRARY_IMPL(aten, AutocastMPS, m) { |
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.
Not really a blocker for the PR, are these actually different from the fp16 rules we already have for autograd?
|
@kulinseth It seems there is still some work to be done, here. What's your plan to address some of these comments? |
|
Any update on this @kulinseth ? |
Yes, I need to rebase and update here. I will do it this week. |
|
@kulinseth Still in progress? Looks so based on #104191 . |
|
@kulinseth Is there any update on this please? This change would fix so many issues. Thank you |
Yes , I will cleanup and rebase again . Will have something by early next week to try |
Any updates @kulinseth ? |
|
@kulinseth I'll buy you a coffee! |
|
Any updates @kulinseth ? |
|
@kulinseth Can we do something to help? |
@bghira can you please elaborate why/when you need something like that? But if this is the case, we definitely should extend it in follow-up PR, but perhaps rules should be different that for fp16, aren't they? |
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 |
Fixes pytorch#88415 Need to run inductor/test_cpu_select_algorithm Pull Request resolved: pytorch#99272 Approved by: https://github.com/malfet Co-authored-by: Siddharth Kotapati <[email protected]> Co-authored-by: Nikita Shulga <[email protected]> Co-authored-by: Roy Hvaara <[email protected]>
|
@malfet, @skotapati why the PR has been closed ? And if the code has been effectively merged, on which release would it be available ? |
Note: May be unnecessary after PyTorch PR (ref: pytorch/pytorch#99272) is released.
@bastienjalbert The PR is closed because merging code in PyTorch is more complicated than GitHub's default workflow and is handled by bot commands. If you're interested in learning more about what goes on in the process you can take a look at the workflow file. When the workflow completes successfully the bot closes the PR The changes proposed in this PR was added in
It is in the release branch for 2.5 and I expect it'll be available in 2.5.0. |
|
I get the following warning for autocast on MPS using pytorch 2.6.0 nightly: My offending code (taken from Segment Anything 2.1 sample code) appears to reference the proper dtype: with torch.inference_mode(), torch.autocast("mps", dtype=torch.bfloat16):However, it seems the actual supported type is |
|
@hvaara Much appreciated! |
* Activate torch.cuda.amp.autocast() for roformer inference * Use `autocast()` for all inference. Update torch (2.3.1 -> 2.4.1) to use `is_autocast_available()`. * Fix autocast error on Apple Silicon Macs Note: May be unnecessary after PyTorch PR (ref: pytorch/pytorch#99272) is released. * Small refactor * A new flag `use_autocast` is added to Separator class and CLI. - Default value is False - Autocast is used only if flag is True and device supports it * Update README * Small refactor
This PR adds support for bf16 autocast. Most of the code and ideas are copied from #99272. Most of the heavy lifting was done by AI. Fixes #139386 Pull Request resolved: #139390 Approved by: https://github.com/malfet Co-authored-by: Kulin Seth <[email protected]> Co-authored-by: Nikita Shulga <[email protected]>
This PR adds support for bf16 autocast. Most of the code and ideas are copied from pytorch#99272. Most of the heavy lifting was done by AI. Fixes pytorch#139386 Pull Request resolved: pytorch#139390 Approved by: https://github.com/malfet Co-authored-by: Kulin Seth <[email protected]> Co-authored-by: Nikita Shulga <[email protected]>

Fixes #88415
Need to run inductor/test_cpu_select_algorithm
cc @mcarilli @ptrblck @leslie-fang-intel @jgong5