Skip to content

Conversation

@kulinseth
Copy link
Collaborator

@kulinseth kulinseth commented Apr 16, 2023

Fixes #88415

Need to run inductor/test_cpu_select_algorithm

cc @mcarilli @ptrblck @leslie-fang-intel @jgong5

@pytorch-bot pytorch-bot bot added ciflow/mps Run MPS tests (subset of trunk) release notes: jit release notes category labels Apr 16, 2023
@pytorch-bot
Copy link

pytorch-bot bot commented Apr 16, 2023

🔗 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 Failures

As of commit c5aec31 with merge base 71383dd (image):
💚 Looks good so far! There are no failures yet. 💚

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

@kulinseth kulinseth added the ciflow/trunk Trigger trunk jobs on your pull request label Apr 21, 2023
@mikaylagawarecki mikaylagawarecki added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Apr 25, 2023
@kulinseth kulinseth force-pushed the autocast branch 2 times, most recently from 786f3f1 to 424cf41 Compare April 26, 2023 06:25
Copy link
Collaborator

@albanD albanD left a 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) {
Copy link
Collaborator

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?

@johnrichardrinehart
Copy link

@kulinseth It seems there is still some work to be done, here. What's your plan to address some of these comments?

@albanD
Copy link
Collaborator

albanD commented Jun 22, 2023

Any update on this @kulinseth ?

@kulinseth
Copy link
Collaborator Author

Any update on this @kulinseth ?

Yes, I need to rebase and update here. I will do it this week.

@johnrichardrinehart
Copy link

@kulinseth Still in progress? Looks so based on #104191 .

@djollieb
Copy link

@kulinseth Is there any update on this please? This change would fix so many issues. Thank you

@kulinseth
Copy link
Collaborator Author

@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

@johnrichardrinehart
Copy link

@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 ?

@diffractometer
Copy link

@kulinseth I'll buy you a coffee!

@john1089
Copy link

john1089 commented Sep 9, 2023

Any updates @kulinseth ?

@PhilippeFerreiraDeSousa

@kulinseth Can we do something to help?

@malfet malfet removed the release notes: jit release notes category label Sep 5, 2024
@malfet
Copy link
Contributor

malfet commented Sep 5, 2024

can bf16 remain as an option, please?

@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?

@pytorchmergebot
Copy link
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

Chao1Han pushed a commit to Chao1Han/pytorch that referenced this pull request Sep 20, 2024
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]>
@bastienjalbert
Copy link

bastienjalbert commented Oct 12, 2024

@malfet, @skotapati why the PR has been closed ? And if the code has been effectively merged, on which release would it be available ?

ntamotsu added a commit to ntamotsu/fork_python-audio-separator that referenced this pull request Oct 12, 2024
Note: May be unnecessary after PyTorch PR (ref: pytorch/pytorch#99272) is released.
@hvaara
Copy link
Contributor

hvaara commented Oct 15, 2024

@malfet, @skotapati why the PR has been closed ?

@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

image

The changes proposed in this PR was added in main in 144fde4.

And if the code has been effectively merged, on which release would it be available ?

It is in the release branch for 2.5 and I expect it'll be available in 2.5.0.

@awmartin
Copy link

awmartin commented Oct 28, 2024

I get the following warning for autocast on MPS using pytorch 2.6.0 nightly:

sam2/.env/lib/python3.11/site-packages/torch/amp/autocast_mode.py:332: UserWarning: In MPS autocast, but the target dtype is not supported. Disabling autocast.
MPS Autocast only supports dtype of torch.bfloat16 currently.

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 torch.float16 as per this line. Is this expected? Or is the warning message on line 330 incorrect?

@hvaara
Copy link
Contributor

hvaara commented Oct 29, 2024

I created #139190 to add some context and track a fix. tl;dr: The error message is incorrect and should be updated. Thanks for reporting the issue, @awmartin!

@hvaara
Copy link
Contributor

hvaara commented Oct 31, 2024

I added a proposal to extend MPS autocast support to bf16 in #139390.

cc @awmartin

@awmartin
Copy link

@hvaara Much appreciated!

beveradb pushed a commit to nomadkaraoke/python-audio-separator that referenced this pull request Nov 2, 2024
* 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
pytorchmergebot pushed a commit that referenced this pull request Nov 20, 2024
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]>
pobin6 pushed a commit to pobin6/pytorch that referenced this pull request Dec 5, 2024
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-no-td Do not run TD on this PR ciflow/mps Run MPS tests (subset of trunk) ciflow/trunk Trigger trunk jobs on your pull request Merged module: amp (automated mixed precision) autocast open source release notes: mps Release notes category Reverted topic: improvements topic category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable AMP for MPS devices