Skip to content

Fix invalid indices bug for max_unpool2d/3d on MPS#163036

Closed
can-gaa-hou wants to merge 3 commits intopytorch:mainfrom
can-gaa-hou:max_unpool
Closed

Fix invalid indices bug for max_unpool2d/3d on MPS#163036
can-gaa-hou wants to merge 3 commits intopytorch:mainfrom
can-gaa-hou:max_unpool

Conversation

@can-gaa-hou
Copy link
Contributor

Fixes #163035

@pytorch-bot
Copy link

pytorch-bot bot commented Sep 16, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/163036

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 20e4e0c with merge base 456fbea (image):
💚 Looks good so far! There are no failures yet. 💚

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

@pytorch-bot pytorch-bot bot added the release notes: mps Release notes category label Sep 16, 2025
@can-gaa-hou
Copy link
Contributor Author

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Sep 16, 2025
@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: Approvers from one of the following sets are needed:

  • superuser (pytorch/metamates)
  • Core Reviewers (mruberry, lezcano, Skylion007, ngimel, peterbell10, ...)
  • Core Maintainers (soumith, gchanan, ezyang, dzhulgakov, malfet, ...)
Details for Dev Infra team Raised by workflow job

Failing merge rule: Core Maintainers

Copy link
Contributor

@malfet malfet left a comment

Choose a reason for hiding this comment

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

Thank you for working on the change, but I'm a bit suspicious why this is tested only for MPS?
Also, use simpler error checking message and print entire shape rather than having separate output for 2d and 3d cases, which would also eliminate the need for may-be unsued

Co-authored-by: Nikita Shulga <2453524+malfet@users.noreply.github.com>
@pytorch-bot pytorch-bot bot removed the ciflow/trunk Trigger trunk jobs on your pull request label Sep 17, 2025
@mikaylagawarecki mikaylagawarecki added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Sep 18, 2025
Copy link
Contributor

@malfet malfet left a comment

Choose a reason for hiding this comment

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

Looks good to me, code looks much neater now

@malfet malfet added topic: bug fixes topic category ciflow/mps Run MPS tests (subset of trunk) labels Sep 18, 2025
@pytorch-bot
Copy link

pytorch-bot bot commented Sep 18, 2025

To add the ciflow label ciflow/mps please first approve the workflows that are awaiting approval (scroll to the bottom of this page).

This helps ensure we don't trigger CI on this PR until it is actually authorized to do so. Please ping one of the reviewers if you do not have access to approve and run workflows.

@pytorch-bot pytorch-bot bot removed the ciflow/mps Run MPS tests (subset of trunk) label Sep 18, 2025
@malfet
Copy link
Contributor

malfet commented Sep 18, 2025

@pytorchbot merge

@pytorch-bot
Copy link

pytorch-bot bot commented Sep 18, 2025

Pull workflow has not been scheduled for the PR yet. It could be because author doesn't have permissions to run those or skip-checks keywords were added to PR/commits, aborting merge. Please get/give approval for the workflows and/or remove skip ci decorators before next merge attempt. If you think this is a mistake, please contact PyTorch Dev Infra.

@can-gaa-hou
Copy link
Contributor Author

Looks good to me, code looks much neater now

Thanks for the review!

@can-gaa-hou
Copy link
Contributor Author

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Sep 19, 2025
@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

mansiag05 pushed a commit to mansiag05/pytorch that referenced this pull request Sep 22, 2025
Fixes pytorch#163035
Pull Request resolved: pytorch#163036
Approved by: https://github.com/kulinseth, https://github.com/malfet

Co-authored-by: Nikita Shulga <2453524+malfet@users.noreply.github.com>
cleonard530 pushed a commit to cleonard530/pytorch that referenced this pull request Sep 22, 2025
Fixes pytorch#163035
Pull Request resolved: pytorch#163036
Approved by: https://github.com/kulinseth, https://github.com/malfet

Co-authored-by: Nikita Shulga <2453524+malfet@users.noreply.github.com>
dsashidh pushed a commit to dsashidh/pytorch that referenced this pull request Sep 26, 2025
Fixes pytorch#163035
Pull Request resolved: pytorch#163036
Approved by: https://github.com/kulinseth, https://github.com/malfet

Co-authored-by: Nikita Shulga <2453524+malfet@users.noreply.github.com>
@malfet
Copy link
Contributor

malfet commented Jan 9, 2026

I must have been blind when reviewing this PR:

  • Test only tests CPU behavior
  • And check in maxunpool introduces a sync point, which is a big no no

malfet added a commit that referenced this pull request Jan 9, 2026
Introduced by #163036

I should have rejected that PR during the review


ghstack-source-id: 75c86d2
Pull-Request: #172046
malfet added a commit that referenced this pull request Jan 9, 2026
Introduced by #163036

I should have rejected that PR during the review

ghstack-source-id: 770c1f1
Pull-Request: #172046
@can-gaa-hou
Copy link
Contributor Author

Sorry about that. The check introduced a sync point on MPS, and the test only validated CPU behavior. I’ll be more careful about host-side reads/reductions on MPS paths and make sure tests cover the intended device next time. Thanks for catching and fixing this.

cc @malfet

malfet added a commit that referenced this pull request Jan 9, 2026
Introduced by #163036

I should have rejected that PR during the review

ghstack-source-id: ff2883b
Pull-Request: #172046
pytorchmergebot pushed a commit that referenced this pull request Jan 9, 2026
Introduced by #163036, that I should have rejected, but ship have sailed
Also, delete unnecessary `test_max_unpool_invalid_indices` as those checks  are already covered by `test_MaxUnpool_index_errors` , but they were skipped in the past as test is marked slow (though it should have been marked as such only for CUDA)

Pull Request resolved: #172046
Approved by: https://github.com/manuelcandales
ghstack dependencies: #172051, #172052
pytorchbot pushed a commit that referenced this pull request Jan 9, 2026
Introduced by #163036, that I should have rejected, but ship have sailed
Also, delete unnecessary `test_max_unpool_invalid_indices` as those checks  are already covered by `test_MaxUnpool_index_errors` , but they were skipped in the past as test is marked slow (though it should have been marked as such only for CUDA)

Pull Request resolved: #172046
Approved by: https://github.com/manuelcandales
ghstack dependencies: #172051, #172052

(cherry picked from commit 9469ce4)
malfet added a commit that referenced this pull request Jan 9, 2026
[MPS] Remove error-checking sync point from MaxUnpool (#172046)

Introduced by #163036, that I should have rejected, but ship have sailed
Also, delete unnecessary `test_max_unpool_invalid_indices` as those checks  are already covered by `test_MaxUnpool_index_errors` , but they were skipped in the past as test is marked slow (though it should have been marked as such only for CUDA)

Pull Request resolved: #172046
Approved by: https://github.com/manuelcandales
ghstack dependencies: #172051, #172052

(cherry picked from commit 9469ce4)

Co-authored-by: Nikita Shulga <nshulga@meta.com>
hinriksnaer pushed a commit to hinriksnaer/pytorch that referenced this pull request Jan 12, 2026
Introduced by pytorch#163036, that I should have rejected, but ship have sailed
Also, delete unnecessary `test_max_unpool_invalid_indices` as those checks  are already covered by `test_MaxUnpool_index_errors` , but they were skipped in the past as test is marked slow (though it should have been marked as such only for CUDA)

Pull Request resolved: pytorch#172046
Approved by: https://github.com/manuelcandales
ghstack dependencies: pytorch#172051, pytorch#172052
SergeyTyshkevich pushed a commit to SergeyTyshkevich/chart2 that referenced this pull request Jan 19, 2026
Introduced by pytorch/pytorch#163036

I should have rejected that PR during the review

ghstack-source-id: 770c1f1
Pull-Request: pytorch/pytorch#172046

ghstack-source-id: c97ccf1
Pull Request resolved: pytorch/pytorch#172077
SergeyTyshkevich pushed a commit to SergeyTyshkevich/chart2 that referenced this pull request Jan 19, 2026
Introduced by pytorch/pytorch#163036

I should have rejected that PR during the review

ghstack-source-id: 770c1f1
Pull-Request: pytorch/pytorch#172046

ghstack-source-id: 8fccd95
Pull Request resolved: pytorch/pytorch#172080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged open source release notes: mps Release notes category topic: bug fixes 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.

[MPS] max_unpool2d/max_unpool3d did not raise an error for invaid indices

7 participants