-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[MPS] Update avg_pool2d to use Metal kernel when ceil_mode=True
#161011
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
Closed
Conversation
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
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/161011
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 7b3870f with merge base b3e215b ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
kurtamohler
added a commit
to kurtamohler/pytorch
that referenced
this pull request
Aug 20, 2025
ghstack-source-id: a2f0089 Pull-Request: pytorch#161011
malfet
approved these changes
Aug 22, 2025
|
Starting merge as part of PR stack under #161071 |
pytorchmergebot
pushed a commit
that referenced
this pull request
Aug 23, 2025
Pull Request resolved: #161071 Approved by: https://github.com/Skylion007, https://github.com/malfet ghstack dependencies: #161011
markc-614
pushed a commit
to markc-614/pytorch
that referenced
this pull request
Sep 17, 2025
…ytorch#161011) Fixes pytorch#160743 The MPS impl of `avg_pool2d` seems to only give incorrect results when `ceil_mode=True`. I wrote a performance measurement script (https://github.com/kurtamohler/pytorch-perf-test-scripts/blob/0ee6e586431fc3a0035a1d1d2ce06931d913ade5/avg_pool_mps/perf_2d.py) which tests a bunch of different cases and also marks the cases where MPS and CPU results do not match. I found that if I update `avg_pool2d` to use the new Metal kernel in all cases, that fixes all the mismatches, but it also decreases performance for some of the `ceil_mode=False` cases. So I opted to only run the new Metal kernel when `ceil_mode=True`, which does not significantly decrease performance in any of the cases tested. Pull Request resolved: pytorch#161011 Approved by: https://github.com/malfet
markc-614
pushed a commit
to markc-614/pytorch
that referenced
this pull request
Sep 17, 2025
Pull Request resolved: pytorch#161071 Approved by: https://github.com/Skylion007, https://github.com/malfet ghstack dependencies: pytorch#161011
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
ciflow/mps
Run MPS tests (subset of trunk)
Merged
open source
release notes: mps
Release notes category
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.
Stack from ghstack (oldest at bottom):
avg_pool3dkernel to useopmath_t#161071avg_pool2dto use Metal kernel whenceil_mode=True#161011Fixes #160743
The MPS impl of
avg_pool2dseems to only give incorrect results whenceil_mode=True. I wrote a performance measurement script (https://github.com/kurtamohler/pytorch-perf-test-scripts/blob/0ee6e586431fc3a0035a1d1d2ce06931d913ade5/avg_pool_mps/perf_2d.py) which tests a bunch of different cases and also marks the cases where MPS and CPU results do not match.I found that if I update
avg_pool2dto use the new Metal kernel in all cases, that fixes all the mismatches, but it also decreases performance for some of theceil_mode=Falsecases. So I opted to only run the new Metal kernel whenceil_mode=True, which does not significantly decrease performance in any of the cases tested.