Skip to content

fix: disable non-blocking on MPS#3101

Merged
Borda merged 3 commits into
Lightning-AI:masterfrom
ahmedhshahin:master
May 27, 2025
Merged

fix: disable non-blocking on MPS#3101
Borda merged 3 commits into
Lightning-AI:masterfrom
ahmedhshahin:master

Conversation

@ahmedhshahin

@ahmedhshahin ahmedhshahin commented May 21, 2025

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes the behavior of unexpected values when using non_blocking=True on MPS cards.
closes #3094

Before submitting
  • Was this discussed/agreed via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure to update the docs?
  • Did you write any new necessary tests?
PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃


📚 Documentation preview 📚: https://torchmetrics--3101.org.readthedocs.build/en/3101/

rank_zero_warn("Detected zero division in _safe_divide. Setting 0/0 to 0.0")
zero_division = 0.0 if zero_division == "warn" else zero_division
zero_division_tensor = torch.tensor(zero_division, dtype=num.dtype).to(num.device, non_blocking=True)
# MPS does not support non blocking

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we have a test?

@codecov

codecov Bot commented May 22, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70%. Comparing base (4c42cf2) to head (79130de).
⚠️ Report is 104 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #3101    +/-   ##
=======================================
- Coverage      70%     70%    -0%     
=======================================
  Files         357     343    -14     
  Lines       19831   19643   -188     
=======================================
- Hits        13880   13693   -187     
+ Misses       5951    5950     -1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mergify mergify Bot added the ready label May 22, 2025
@Borda Borda merged commit 23167cb into Lightning-AI:master May 27, 2025
62 checks passed
Borda added a commit that referenced this pull request May 27, 2025
* fix: disable non-blocking on MPS
* chlog

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Jirka B <j.borovec+github@gmail.com>
(cherry picked from commit 23167cb)
Borda added a commit that referenced this pull request May 28, 2025
* fix: disable non-blocking on MPS
* chlog

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Jirka B <j.borovec+github@gmail.com>
(cherry picked from commit 23167cb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants