-
Notifications
You must be signed in to change notification settings - Fork 24.1k
Move mps_linear forward to use MPS kernels directly instead of MPSGraph #152210
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
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/152210
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 20 Pending, 1 Unrelated FailureAs of commit 8727017 with merge base 1d3e8f3 ( NEW FAILURE - The following job has failed:
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. |
49b4351
to
76a1b48
Compare
acaeb1d
to
06a28bb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
@pytorchbot rebase |
@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here |
Rebase failed due to Command
Raised by https://github.com/pytorch/pytorch/actions/runs/14910649119 |
…echanism for improved perf.
MPSSequoiaOps header to Linear. Add check for macos version to use correct code path to avoid breaking previous OS.
06a28bb
to
f855f95
Compare
bool is_macos_15_or_newer = is_macos_13_or_newer(MacOSVersion::MACOS_VER_15_0_PLUS); | ||
if (is_macos_15_or_newer) { | ||
_mps_linear_nograph(input, weight, bias, output); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it would be nice to just replace it with if() { return;}
(Doing it now)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, though feels a bit like too much boilerplate code, but will look into it later
@pytorchbot merge -f "Lint + MPS are green" |
Merge startedYour change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
This PR moves
mps_linear
to use MPSNDArrays and call into the MPS kernel directly instead of going through MPSGraph. It also adds a caching mechanism for reusing MPS kernels as there is also a small overhead attached to creating the kernel object.The impact of the improvement is relatively more significant for small input kernels where the MPSGraph overhead represents a larger portion of the overall execution time of the operation but the speedup shows for both small and large input sizes as expected.
mps_linear
before the changes:mps_linear
after the changes:cc @kulinseth @albanD @malfet @DenisVieriu97