fix: propagate NaN in arg reductions - #4291
Open
atirna wants to merge 5 commits into
Open
Conversation
Apply the repository clang-format (v21) to the CUDA arg-reduce changes so pre-commit CI passes on the PR.
Contributor
|
Sorry about that, I checked for prs before setting up a fork CI and didn't check after. Just tested yours and it's solid. Good work! |
Author
|
hey @erwinzhang7 thank you! for taking time to check this pr. sorry it ended up being competing pr |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Fixes #4274 by making
argminandargmaxselect the firstNaN, matching MLX min/max propagation and NumPy/PyTorch behavior. The implementation covers CPU, Metal, and CUDA reduction paths, including pairwise GPU reductions where separate partials contain NaNs.Checklist
pre-commit run --all-filesto format my code / installed pre-commit prior to committing changes (passed on the formatting commit; see 03694f5)Tests
cmake --build build-metal --target tests -j2./build-metal/tests/tests --test-case='test arg reduce NaN'(12 assertions)./build-metal/tests/tests --test-case='test arg reduce*'(188 assertions)The full Metal suite has pre-existing linalg failures on this host (271 passed, 6 failed); there were no arg-reduce failures. CUDA is not available locally.