KEMBAR78
[MPS] Add CompileShader method by malfet · Pull Request #141478 · pytorch/pytorch · GitHub
Skip to content

Conversation

@malfet
Copy link
Contributor

@malfet malfet commented Nov 25, 2024

Stack from ghstack (oldest at bottom):

This allows one to do something like that

import torch
x = torch.ones(10, device="mps")
m = torch.mps._compile_shader("""
   kernel void foo(device float* x, uint idx [[thread_position_in_grid]]) {
     x[idx] += idx;
   }
")
m.foo(x)

And in general enables writing custom operators using Metal shaders purely in Python

@pytorch-bot
Copy link

pytorch-bot bot commented Nov 25, 2024

🔗 Helpful Links

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

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

✅ No Failures

As of commit 8b827fa with merge base 95e7fcf (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 Nov 25, 2024
malfet added a commit that referenced this pull request Nov 25, 2024
ghstack-source-id: 9622dee
Pull Request resolved: #141478
@malfet malfet marked this pull request as draft November 25, 2024 06:11
malfet added a commit that referenced this pull request Nov 25, 2024
ghstack-source-id: 98879ec
Pull Request resolved: #141478
malfet added a commit that referenced this pull request Nov 25, 2024
ghstack-source-id: 2709938
Pull Request resolved: #141478
malfet added a commit that referenced this pull request Nov 26, 2024
ghstack-source-id: fec0ed8
Pull Request resolved: #141478
[ghstack-poisoned]
@qqaatw
Copy link
Collaborator

qqaatw commented Nov 28, 2024

I'm curious about the use of this addition since it accepts one argument only. I assume there is no cuda counterpart in PyTorch.

[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
@malfet
Copy link
Contributor Author

malfet commented Dec 3, 2024

I'm curious about the use of this addition since it accepts one argument only. I assume there is no cuda counterpart in PyTorch.

@qqaatw it's still work in progress :) But final version will accept any number of arguments. As for usefulness, at the very least it unblocks quick prototyping and usecases like shader toys, but in the long run it can enable a pretty advanced codegen.

[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
@malfet
Copy link
Contributor Author

malfet commented Dec 11, 2024

@pytorchbot revert -m "Broke doctests, by trying to run MPS example on Linux" -c nosignal

@pytorchmergebot
Copy link
Collaborator

@pytorchbot successfully started a revert job. Check the current status here.
Questions? Feedback? Please reach out to the PyTorch DevX Team

pytorchmergebot added a commit that referenced this pull request Dec 11, 2024
This reverts commit 0478fee.

Reverted #141478 on behalf of https://github.com/malfet due to Broke doctests, by trying to run MPS example on Linux ([comment](#141478 (comment)))
@pytorchmergebot
Copy link
Collaborator

@malfet your PR has been successfully reverted.

@pytorchmergebot pytorchmergebot added Reverted ci-no-td Do not run TD on this PR labels Dec 11, 2024
@malfet malfet added the no-runner-experiments Bypass Meta/LF runner determinator label Dec 11, 2024
[ghstack-poisoned]
[ghstack-poisoned]
@malfet malfet requested a review from a team as a code owner December 11, 2024 01:36
@malfet
Copy link
Contributor Author

malfet commented Dec 11, 2024

@pytorchbot merge -f "No pain no gain"

@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

Esquains pushed a commit to Esquains/study1 that referenced this pull request Dec 15, 2024
ghstack-source-id: 0d9e621
Pull Request resolved: pytorch/pytorch#141478
@github-actions github-actions bot deleted the gh/malfet/71/head branch January 11, 2025 02:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-no-td Do not run TD on this PR ciflow/mps Run MPS tests (subset of trunk) Merged no-runner-experiments Bypass Meta/LF runner determinator release notes: mps Release notes category Reverted topic: improvements topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants