Skip to content

Conversation

@manuelcandales
Copy link
Contributor

@manuelcandales manuelcandales commented Jun 6, 2025

Stack from ghstack (oldest at bottom):

Implements the forward and backward hardshrink operators as Metal kernels.
In order to support the lambda parameter, we extend the exec_unary_kernel and exec_binary_kernel methods. Now they take an optional Scalar and an optional ScalarType argument. When the optional ScalarType is provided, it overrides the type of the Scalar.
We add a new REGISTER_UNARY_ALPHA_OP macro, and modify the existing REGISTER_BINARY_ALPHA_OP to support the new feature.

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Jun 6, 2025

🔗 Helpful Links

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

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

⏳ 1 Pending, 9 Unrelated Failures

As of commit 525ae01 with merge base d4d0ede (image):

FLAKY - The following job failed but was likely due to flakiness present on trunk:

BROKEN TRUNK - The following jobs failed but was present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

UNSTABLE - The following job is marked as unstable, possibly due to flakiness on trunk:

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 Jun 6, 2025
manuelcandales added a commit that referenced this pull request Jun 6, 2025
ghstack-source-id: 6f45291
Pull-Request: #155304
@github-actions
Copy link
Contributor

github-actions bot commented Jun 6, 2025

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.


Caused by:

@manuelcandales manuelcandales marked this pull request as draft June 6, 2025 04:53
[ghstack-poisoned]
manuelcandales added a commit that referenced this pull request Jun 6, 2025
ghstack-source-id: 0aed9db
Pull-Request: #155304
@manuelcandales manuelcandales marked this pull request as ready for review June 6, 2025 05:51
Copy link
Contributor

@malfet malfet left a comment

Choose a reason for hiding this comment

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

type API looks a bit fragile, consider using std::pair and encode extra dtype in shader name

[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
Comment on lines +140 to +141
const std::optional<c10::Scalar> alpha = std::nullopt,
const std::optional<c10::ScalarType> scalar_arg_type = std::nullopt);
Copy link
Contributor

Choose a reason for hiding this comment

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

This API looks wrong, it should be something like

Suggested change
const std::optional<c10::Scalar> alpha = std::nullopt,
const std::optional<c10::ScalarType> scalar_arg_type = std::nullopt);
const std::optional<std::pair<c10::Scalar, c10::ScalarType>> alpha = std::nullopt,

[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
Copy link
Contributor

@malfet malfet left a comment

Choose a reason for hiding this comment

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

Thank you for working on the change

@malfet malfet added the topic: improvements topic category label Jun 10, 2025
@malfet
Copy link
Contributor

malfet commented Jun 10, 2025

@pytorchbot merge -f "Lint + MPS are green, will submit some cleanups later on"

@pytorchmergebot
Copy link
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

thatgeeman pushed a commit to thatgeeman/pytorch-docathon that referenced this pull request Jun 15, 2025
Implements the forward and backward hardshrink operators as Metal kernels.
In order to support the lambda parameter, we extend the `exec_unary_kernel`  and `exec_binary_kernel` methods. Now they take an optional Scalar and an optional ScalarType argument. When the optional ScalarType is provided, it overrides the type of the Scalar.
We add a new `REGISTER_UNARY_ALPHA_OP` macro, and modify the existing `REGISTER_BINARY_ALPHA_OP` to support the new feature.

Pull Request resolved: pytorch#155304
Approved by: https://github.com/malfet
@github-actions github-actions bot deleted the gh/manuelcandales/2/head branch July 13, 2025 02:22
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 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