Skip to content

Conversation

manuelcandales
Copy link
Contributor

Adds bfloat16/float32 working implementations of the following AOTI shim ops:

  • aoti_torch_mps_mm_out
  • aoti_torch_mps_convolution
  • aoti_torch_mps__scaled_dot_product_attention_math_for_mps

Adds a stub implementation of aoti_torch_mps_addmm_out

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

manuelcandales commented Oct 10, 2025

@pytorch-bot
Copy link

pytorch-bot bot commented Oct 10, 2025

🔗 Helpful Links

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

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

❌ 2 New Failures

As of commit 9d69769 with merge base f4d801a (image):

NEW FAILURES - The following jobs have failed:

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

[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
* ExecutorTorch implementation of aoti_torch_mps_mm_out.
* Performs simple matrix multiplication: out = self @ mat2
*/
AOTITorchError aoti_torch_mps_mm_out(
Copy link
Contributor

Choose a reason for hiding this comment

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

Does custom ops use caching mechanism like the ETMetalShaderLibrary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, not yet. These fallback ops are implemented using MPSGraph, so, here we would be caching the graph. This is something I want to look into later when optimizing performance. But this deserves time. In particular, since I never understood why MPSGraph operations have a non-trivial CPU overhead in PyTorch, in spite of PyTorch having a caching mechanism for MPSGraphs.

Comment on lines +1182 to +1183
// For attention weights, zero-fill the GPU buffer (shared memory allows CPU memset)
std::memset(attn_contents_ptr, 0, attn_size_bytes);
Copy link
Contributor

Choose a reason for hiding this comment

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

do you need zero filling here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, I though it was nicer to return 0, rather than some random stuff.


// Set output tensor handles
*ret0 = out_tensor_handle;
*ret1 = attn_tensor_handle;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is ret1 actually populated or just zerod

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just zeroed.
We are using MPSGraph's scaledDotProductAttention which only returns the output tensor.
We need to return an attention tensor because we need to match _scaled_dot_product_attention_math_for_mps signature. But we don't really need it, it gets thrown away here

[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
Base automatically changed from gh/manuelcandales/142/head to main October 17, 2025 01:58
[ghstack-poisoned]
@manuelcandales manuelcandales merged commit 7b7525e into main Oct 17, 2025
143 of 145 checks passed
@manuelcandales manuelcandales deleted the gh/manuelcandales/143/head branch October 17, 2025 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. release notes: none Do not include this in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants