Skip to content

Conversation

@kurtamohler
Copy link
Collaborator

@kurtamohler kurtamohler commented Aug 19, 2025

Stack from ghstack (oldest at bottom):

Fixes #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.

[ghstack-poisoned]
kurtamohler added a commit that referenced this pull request Aug 19, 2025
@pytorch-bot
Copy link

pytorch-bot bot commented Aug 19, 2025

🔗 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 Failures

As of commit 7b3870f with merge base b3e215b (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 ciflow/mps Run MPS tests (subset of trunk) release notes: mps Release notes category labels Aug 19, 2025
[ghstack-poisoned]
kurtamohler added a commit that referenced this pull request Aug 20, 2025
kurtamohler added a commit to kurtamohler/pytorch that referenced this pull request Aug 20, 2025
@pytorchmergebot
Copy link
Collaborator

Starting merge as part of PR stack under #161071

pytorchmergebot pushed a commit that referenced this pull request Aug 23, 2025
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
@github-actions github-actions bot deleted the gh/kurtamohler/47/head branch September 23, 2025 02:08
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants