Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/155183
Note: Links to docs will display an error until the docs builds have been completed. ❌ 3 Cancelled Jobs, 2 PendingAs of commit 80f5d62 with merge base 31d12b3 ( CANCELLED JOBS - The following jobs were cancelled. Please retry:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced Jun 5, 2025
cyyever
approved these changes
Jun 5, 2025
dcci
approved these changes
Jun 5, 2025
Skylion007
approved these changes
Jun 5, 2025
malfet
added a commit
that referenced
this pull request
Jun 5, 2025
By using `TensorIterator..with_32bit_indexing()` primitive Add `bind_tensors` helper function that correctly sets up MPS tensors originating from TensorIterator TODO: Add unit test, based on ``` python -c "import torch;print((torch.rand(1, 1024, 1024, dtype=torch.bfloat16, device='mps') + torch.rand(5000, 1, 1, dtype=torch.bfloat16, device='mps')).sin())" ``` ghstack-source-id: dd9ed1b Pull Request resolved: #155183
Collaborator
Author
|
@pytorchbot merge -f "Lint + MPS are green" |
Collaborator
Merge startedYour change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
pytorchmergebot
pushed a commit
that referenced
this pull request
Oct 23, 2026
) ## Linked issue or supporting maintainer Fixes #201835 ## BC-breaking? No ## Summary (human written only) <!-- Point to the issue for relevant design discussion. If not discussed there (rare), add up to one paragraph. Overly verbose descriptions will be considered spam. --> The test_mps function test_64bits_binops assumes <= 16 GiB of GPU Mem is required, however, this is not the case due to broadcasting where a + b makes a 9.77 GiB tensor and another .sin() makes a second 9.77 GiB, where the sum becomes 9.77 GiB * 2 > 16 GiB. Using .sin_() writes the result back to the first tensor, so it only use a total of 9.77 GiB of memory well below 16 GiB. From the code, it continues the test if GPU Mem > 16 GiB which is not true. https://github.com/pytorch/pytorch/blob/3c53c6fe501fd43f2ae33490b0aee276c6e0db6e/test/test_mps.py#L10531-L10532 ## Agent details (if applicable) > Prepared with Claude Code (Opus 5.5) at my request; the commands below were run on my M4 Pro. > > Test-only change in `test/test_mps.py`. `test_64bit_binops` kept `a + b` and `(a + b).sin()` alive together (2 x 9.77 GiB), above the 17.76 GiB GPU working set of a 24 GB Mac and at 92% of the 21.3 GiB working set of CI's M2 runners, where it was disabled as flaky (#190665). It now computes the sine in place and frees its tensors at the end, like the other `TestLargeTensors` tests. > > Tested on an Apple M4 Pro (24 GB, macOS 27.0.1): > > ``` > PYTORCH_TEST_WITH_SLOW=1 python test/test_mps.py TestLargeTensors.test_64bit_binops > PYTORCH_TEST_WITH_SLOW=1 python test/test_mps.py TestLargeTensors > spin quicklint > ``` > > Before: `OutOfMemoryError: MPS command buffer execution failed: Insufficient Memory`. After: OK in 3 of 3 runs; the class passes and 2 to 4 of the 64-bit `cat` tests that follow no longer skip for memory. Coverage check: with `exec_unary_kernel` temporarily changed to dispatch only its first 32-bit chunk, the patched test fails (98.6% of the checked elements wrong), so it still covers #155183. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Pull Request resolved: #201836 Approved by: https://github.com/malfet Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Stack from ghstack (oldest at bottom):
By using
TensorIterator::with_32bit_indexing()primitiveAdd
bind_tensorshelper function that correctly sets up MPS tensors originating from TensorIteratorTODO: Add comments to bind_tensors as well asunit test, based on
Fixes #154828