Skip to content

[BE][MPS] Migrate remaining logical ops to Metal - #195592

Closed
malfet wants to merge 3 commits into
gh/malfet/1028/basefrom
gh/malfet/1028/head
Closed

malfet wants to merge 3 commits into
gh/malfet/1028/basefrom
gh/malfet/1028/head

Conversation

@malfet

@malfet malfet commented Sep 1, 2026 •

Copy link
Copy Markdown
Collaborator

Stack from ghstack (oldest at bottom):

Using c10:metal::cast_to<bool> primitive to have consistent behavior for complex numbers, which fixes bug in MPSGraph implementation when op was called for complex types (previously only real part were checked, not complex value is truthy when either real or complex parts are nonzero)

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

Attention! native_functions.yaml was changed

If you are adding a new function or defaulted argument to native_functions.yaml, you cannot use it from pre-existing Python frontend code until our FC window passes (two weeks). Split your PR into two PRs, one which adds the new C++ functionality, and one that makes use of it from Python, and land them two weeks apart. See https://github.com/pytorch/pytorch/wiki/PyTorch's-Python-Frontend-Backward-and-Forward-Compatibility-Policy#forwards-compatibility-fc for more info.

@pytorch-bot pytorch-bot Bot added ciflow/mps Run MPS tests (subset of trunk) release notes: mps Release notes category labels Sep 1, 2026
@pytorch-bot

pytorch-bot Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

As of commit 4143e8c with merge base e0942cc (image):
💚 Looks good so far! There are no failures yet. 💚

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

[ghstack-poisoned]
[ghstack-poisoned]
@malfet

malfet commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator Author

@pytorchbot merge -f "Lint + MPS are green"

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

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

orrangetabby17 pushed a commit to orrangetabby17/pytorch that referenced this pull request Sep 2, 2026
Using `c10:metal::cast_to<bool>` primitive to have consistent behavior for complex numbers, which fixes bug in MPSGraph implementation when op was called for complex types (previously only real part were checked, not complex value is truthy when either real or complex parts are nonzero)

Pull Request resolved: pytorch#195592
Approved by: https://github.com/Skylion007
pytorchmergebot pushed a commit that referenced this pull request Sep 2, 2026
That is just a binary op using all the existing binary iterator machinery plus `c10::metal::pow` functor, yields 2x speedups on small tensors, on part on large ones

`pow_Scalar_Tensor` still must be a separate dispatch, as unified machinery converts Double to float tensors

Allows one to remove some xfails where MPSGraph handling of ineger powers diverges and remove complex xfails (although with a small tolerance adjustement, because Metal and host triage functions slightly differ)

Also remove some non-relevant functions from UNSUPPORTED_COMPLEX_OPS
list
Pull Request resolved: #195585
Approved by: https://github.com/Skylion007, https://github.com/Isalia20
ghstack dependencies: #195592
Sanskaaar1 pushed a commit to Sanskaaar1/pytorch that referenced this pull request Sep 8, 2026
Using `c10:metal::cast_to<bool>` primitive to have consistent behavior for complex numbers, which fixes bug in MPSGraph implementation when op was called for complex types (previously only real part were checked, not complex value is truthy when either real or complex parts are nonzero)

Pull Request resolved: pytorch#195592
Approved by: https://github.com/Skylion007
Sanskaaar1 pushed a commit to Sanskaaar1/pytorch that referenced this pull request Sep 8, 2026
That is just a binary op using all the existing binary iterator machinery plus `c10::metal::pow` functor, yields 2x speedups on small tensors, on part on large ones

`pow_Scalar_Tensor` still must be a separate dispatch, as unified machinery converts Double to float tensors

Allows one to remove some xfails where MPSGraph handling of ineger powers diverges and remove complex xfails (although with a small tolerance adjustement, because Metal and host triage functions slightly differ)

Also remove some non-relevant functions from UNSUPPORTED_COMPLEX_OPS
list
Pull Request resolved: pytorch#195585
Approved by: https://github.com/Skylion007, https://github.com/Isalia20
ghstack dependencies: pytorch#195592
@github-actions
github-actions Bot deleted the gh/malfet/1028/head branch November 13, 2026 01:47
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 topic: bug fixes topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants