Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MPS] add support for aten::nextafter #109685

Closed
wants to merge 2 commits into from
Closed

Conversation

igm503
Copy link
Contributor

@igm503 igm503 commented Sep 20, 2023

Fixes #77764 (comment)

Adds support for aten::nextafter to the MPS backend. Supports float and half types.

Notes:

  • I've added nextafter to the output_grad_check XFAILLIST since neither this nor the cpu implementations have grad functions
  • Metal Shading Language 3.1 seems to have a native nextafter() function, so once that's available, this kernel can just call that.

@pytorch-bot pytorch-bot bot added ciflow/mps Run MPS tests (subset of trunk) release notes: mps Release notes category labels Sep 20, 2023
@pytorch-bot
Copy link

pytorch-bot bot commented Sep 20, 2023

🔗 Helpful Links

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

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

✅ No Failures

As of commit 1392c39 with merge base 0317626 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@soulitzer soulitzer added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Sep 20, 2023
@qqaatw
Copy link
Collaborator

qqaatw commented Oct 3, 2023

Small suggestion: As you mentioned, the MSL 3.1 supports nextafter natively. I think we could use __METAL_VERSION__ macro to branch off from the custom implementation used below Metal 3.1. Below is an example:

#if __METAL_VERSION__ >= 300
constant IndexAB * indexAB [[buffer(0)]],
#else
constant IndexAB & indexAB [[buffer(0)]],
#endif

@kulinseth
Copy link
Collaborator

Small suggestion: As you mentioned, the MSL 3.1 supports nextafter natively. I think we could use __METAL_VERSION__ macro to branch off from the custom implementation used below Metal 3.1. Below is an example:

#if __METAL_VERSION__ >= 300
constant IndexAB * indexAB [[buffer(0)]],
#else
constant IndexAB & indexAB [[buffer(0)]],
#endif

I think he meant when that’s available he can call that function directly . I didn’t see that native function being called in this pr . In metal 3.1 time we would still need this code path to have it working for older os

@qqaatw
Copy link
Collaborator

qqaatw commented Oct 3, 2023

Small suggestion: As you mentioned, the MSL 3.1 supports nextafter natively. I think we could use __METAL_VERSION__ macro to branch off from the custom implementation used below Metal 3.1. Below is an example:

#if __METAL_VERSION__ >= 300
constant IndexAB * indexAB [[buffer(0)]],
#else
constant IndexAB & indexAB [[buffer(0)]],
#endif

I think he meant when that’s available he can call that function directly . I didn’t see that native function being called in this pr . In metal 3.1 time we would still need this code path to have it working for older os

I meant we can have both implementations, native one and custom one, in the kernel and use the macro to determine which one should be used. (it's ok to have it in a follow-up, don't want to block this PR).

@kulinseth
Copy link
Collaborator

Small suggestion: As you mentioned, the MSL 3.1 supports nextafter natively. I think we could use __METAL_VERSION__ macro to branch off from the custom implementation used below Metal 3.1. Below is an example:

#if __METAL_VERSION__ >= 300
constant IndexAB * indexAB [[buffer(0)]],
#else
constant IndexAB & indexAB [[buffer(0)]],
#endif

I think he meant when that’s available he can call that function directly . I didn’t see that native function being called in this pr . In metal 3.1 time we would still need this code path to have it working for older os

I meant we can have both implementations, native one and custom one, in the kernel and use the macro to determine which one should be used. (it's ok to have it in a follow-up, don't want to block this PR).

Agreed . Let’s do a follow up on this case , for simple cases unless it becomes perf critical it’s nice to have consistent code path from maintenance stand point

@igm503
Copy link
Contributor Author

igm503 commented Oct 3, 2023

Small suggestion: As you mentioned, the MSL 3.1 supports nextafter natively. I think we could use __METAL_VERSION__ macro to branch off from the custom implementation used below Metal 3.1. Below is an example:

#if __METAL_VERSION__ >= 300
constant IndexAB * indexAB [[buffer(0)]],
#else
constant IndexAB & indexAB [[buffer(0)]],
#endif

I think he meant when that’s available he can call that function directly . I didn’t see that native function being called in this pr . In metal 3.1 time we would still need this code path to have it working for older os

I meant we can have both implementations, native one and custom one, in the kernel and use the macro to determine which one should be used. (it's ok to have it in a follow-up, don't want to block this PR).

Agreed . Let’s do a follow up on this case , for simple cases unless it becomes perf critical it’s nice to have consistent code path from maintenance stand point

So I'll merge this, but y'all think it would be worth following qqaatw's idea of branching based on MSL version? I'm happy to throw that in on a follow up pr if so.

@igm503
Copy link
Contributor Author

igm503 commented Oct 3, 2023

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Oct 3, 2023
@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

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

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) ciflow/trunk Trigger trunk jobs on your pull request Merged open source release notes: mps Release notes category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

General MPS op coverage tracking issue
6 participants