Skip to content

[MPS] Migrate logit_backward and tanh_backward to Metal - #195601

Closed
malfet wants to merge 2 commits into
gh/malfet/1029/basefrom
gh/malfet/1029/head
Closed

malfet wants to merge 2 commits into
gh/malfet/1029/basefrom
gh/malfet/1029/head

Conversation

@malfet

@malfet malfet commented Sep 1, 2026 •

Copy link
Copy Markdown
Collaborator

Stack from ghstack (oldest at bottom):

Last MPSGraph backward ops in this stub family (sigmoid_backward was already
native). logit_backward carries its eps scalar via the binary-alpha path;
tanh_backward gains complex support for free.

Co-Authored-By: Claude Opus 4.8 [email protected]

[ghstack-poisoned]
@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/195601

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

✅ No Failures

As of commit 081c23e 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.

@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

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.

inline T operator()(const T grad_output, const T output) {
return c10::metal::mul(
grad_output,
c10::metal::conj(T(1, 0) - c10::metal::mul(output, output)));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is mul output better than output square?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

if output is complex, you'll need to mul, don't you?

[ghstack-poisoned]
malfet added a commit that referenced this pull request Sep 1, 2026
Last MPSGraph backward ops in this stub family (sigmoid_backward was already
native). logit_backward carries its eps scalar via the binary-alpha path;
tanh_backward gains complex support for free.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
ghstack-source-id: ff4f88a
Pull-Request: #195601
@malfet malfet added the topic: improvements topic category label Sep 2, 2026
@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

Sanskaaar1 pushed a commit to Sanskaaar1/pytorch that referenced this pull request Sep 8, 2026
Last MPSGraph backward ops in this stub family (sigmoid_backward was already
native). logit_backward carries its eps scalar via the binary-alpha path;
tanh_backward gains complex support for free.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pull Request resolved: pytorch#195601
Approved by: https://github.com/Skylion007
@github-actions
github-actions Bot deleted the gh/malfet/1029/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: improvements topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants