Skip to content

enhance: avoid unnecessary fallback in _bincount on CUDA with deterministic #3087

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

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

hyukkyukang
Copy link

@hyukkyukang hyukkyukang commented May 8, 2025

What does this PR do?

Update _bincount to use native torch.bincount on CUDA when deterministic algorithms are enabled (PyTorch ≥ 2.1), as this use case is now officially supported. Retain the fallback implementation for MPS, XLA, and older PyTorch versions. Also improved the docstring to reflect updated backend support and trade-offs.

Fixes #3086

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--3087.org.readthedocs.build/en/3087/

…nistic mode

Update _bincount to use native torch.bincount on CUDA when deterministic algorithms are enabled (PyTorch ≥ 2.1), as this use case is now officially supported. Retain the fallback implementation for MPS, XLA, and older PyTorch versions. Also improved the docstring to reflect updated backend support and trade-offs.
enhance: avoid unnecessary fallback in _bincount on CUDA with determi…
@SkafteNicki SkafteNicki added this to the v1.7.x milestone May 9, 2025
@SkafteNicki SkafteNicki added enhancement New feature or request bug / fix Something isn't working and removed enhancement New feature or request labels May 9, 2025
@mergify mergify bot added the has conflicts label May 9, 2025
@mergify mergify bot removed the has conflicts label May 9, 2025
Copy link

codecov bot commented May 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70%. Comparing base (74bdb26) to head (6b1e16a).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #3087    +/-   ##
=======================================
- Coverage      70%     70%    -0%     
=======================================
  Files         359     345    -14     
  Lines       19892   19702   -190     
=======================================
- Hits        13931   13742   -189     
+ Misses       5961    5960     -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 9, 2025
@Borda Borda changed the title enhance: avoid unnecessary fallback in _bincount on CUDA with determi… #1 enhance: avoid unnecessary fallback in _bincount on CUDA with deterministic May 9, 2025
@Borda Borda enabled auto-merge (squash) May 9, 2025 13:19
@Borda
Copy link
Member

Borda commented May 14, 2025

@hyukkyukang seems that the GPU tests are failing for a reason related to your change...
for PT 2.7 and CUDA 12.3
RuntimeError: called a synchronizing CUDA operation

@Borda Borda marked this pull request as draft June 4, 2025 09:02
auto-merge was automatically disabled June 4, 2025 09:02

Pull request was converted to draft

@mergify mergify bot removed the ready label Jun 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug / fix Something isn't working waiting on author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Avoid unnecessary fallback in _bincount when deterministic mode is enabled on CUDA (PyTorch ≥ 2.1)
3 participants