Skip to content

[metal] Add MetalBackend method overrides for codegen#1852

Merged
aditvenk merged 1 commit intomainfrom
aditvenk/stack/18
Apr 1, 2026
Merged

[metal] Add MetalBackend method overrides for codegen#1852
aditvenk merged 1 commit intomainfrom
aditvenk/stack/18

Conversation

@aditvenk
Copy link
Copy Markdown
Contributor

@aditvenk aditvenk commented Mar 27, 2026

@aditvenk aditvenk force-pushed the aditvenk/stack/17 branch from 50c2a72 to d56d963 Compare March 27, 2026 22:35
@aditvenk aditvenk force-pushed the aditvenk/stack/18 branch from 079ec49 to c1ffd7c Compare March 27, 2026 22:35
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 27, 2026
@aditvenk aditvenk marked this pull request as draft March 27, 2026 22:47
@aditvenk aditvenk changed the base branch from aditvenk/stack/17 to main March 27, 2026 22:47
@aditvenk aditvenk changed the base branch from main to aditvenk/stack/17 March 27, 2026 22:48
@aditvenk aditvenk marked this pull request as ready for review March 27, 2026 22:48
@aditvenk aditvenk requested review from jansel, malfet and oulgen March 27, 2026 22:54
@aditvenk aditvenk marked this pull request as draft March 28, 2026 00:11
@aditvenk aditvenk changed the base branch from aditvenk/stack/17 to main March 28, 2026 00:11
@aditvenk aditvenk force-pushed the aditvenk/stack/18 branch from c1ffd7c to 60b3b28 Compare March 28, 2026 00:12
@aditvenk aditvenk changed the base branch from main to aditvenk/stack/17 March 28, 2026 00:13
@aditvenk aditvenk marked this pull request as ready for review March 28, 2026 00:14
@aditvenk aditvenk marked this pull request as draft March 28, 2026 01:23
@aditvenk aditvenk changed the base branch from aditvenk/stack/17 to main March 28, 2026 01:23
@aditvenk aditvenk force-pushed the aditvenk/stack/18 branch from 60b3b28 to f407364 Compare March 28, 2026 01:24
@aditvenk aditvenk changed the base branch from main to aditvenk/stack/17 March 28, 2026 01:26
@aditvenk aditvenk marked this pull request as ready for review March 28, 2026 01:26
@aditvenk aditvenk marked this pull request as draft March 28, 2026 01:37
@aditvenk aditvenk changed the base branch from aditvenk/stack/17 to main March 28, 2026 01:37
@aditvenk aditvenk marked this pull request as draft March 28, 2026 02:44
@aditvenk aditvenk changed the base branch from aditvenk/stack/23 to main March 28, 2026 02:44
@aditvenk aditvenk force-pushed the aditvenk/stack/18 branch from 682bce6 to 8565279 Compare March 28, 2026 02:45
@aditvenk aditvenk changed the base branch from main to aditvenk/stack/23 March 28, 2026 02:45
@aditvenk aditvenk marked this pull request as ready for review March 28, 2026 02:45
@aditvenk aditvenk marked this pull request as draft March 28, 2026 04:44
@aditvenk aditvenk changed the base branch from aditvenk/stack/23 to main March 28, 2026 04:44
@aditvenk aditvenk force-pushed the aditvenk/stack/18 branch from 8565279 to 99bfd78 Compare March 28, 2026 04:44
@aditvenk aditvenk changed the base branch from main to aditvenk/stack/23 March 28, 2026 04:45
@aditvenk aditvenk marked this pull request as ready for review March 28, 2026 04:45
@aditvenk aditvenk marked this pull request as draft March 28, 2026 04:47
@aditvenk aditvenk changed the base branch from aditvenk/stack/23 to main March 28, 2026 04:47
@aditvenk aditvenk force-pushed the aditvenk/stack/18 branch from 99bfd78 to af77035 Compare March 28, 2026 04:47
@aditvenk aditvenk changed the base branch from main to aditvenk/stack/23 March 28, 2026 04:47
@aditvenk aditvenk marked this pull request as ready for review March 28, 2026 04:48
@aditvenk aditvenk marked this pull request as draft March 28, 2026 06:46
@aditvenk aditvenk changed the base branch from aditvenk/stack/23 to main March 28, 2026 06:46
@aditvenk aditvenk force-pushed the aditvenk/stack/18 branch from af77035 to 72032bf Compare March 28, 2026 06:46
@aditvenk aditvenk marked this pull request as ready for review March 28, 2026 06:47
@aditvenk aditvenk marked this pull request as draft March 28, 2026 17:18
@aditvenk aditvenk marked this pull request as ready for review March 28, 2026 17:19
Copy link
Copy Markdown
Contributor

@jansel jansel left a comment

Choose a reason for hiding this comment

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

Is there test coverage for this? Maybe it would be good to get things working to the point you can compile a basic add kernel.

Comment on lines +2429 to +2433
def reshape_expr(self, expr: str, shape: str) -> str:
return expr

def broadcast_to_expr(self, expr: str, shape: str) -> str:
return expr
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this is right.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Metal uses per-thread scalar dispatch — each thread processes one element, so there are no block dimensions. Hence, these are identity operations. Tests coming up in #1794 and #1796.

I also have matmul tests in an unpublished PRs on top of this current stack. Matmuls will use a cooperative thread model, similar to cute

@aditvenk
Copy link
Copy Markdown
Contributor Author

Is there test coverage for this? Maybe it would be good to get things working to the point you can compile a basic add kernel.

Tests for copy kernels are coming in later PR in the stack: #1794
Tests for elementwise are also in the same stack: #1796

I broke up 1794 in smaller PRs for easier reviewing.

Add MetalBackend overrides for index_type, constexpr, program_id,
grid_index, full/reshape/broadcast_to/zeros expressions, where/min,
autotune, transform_host_arg, and launcher_keyword_args.

stack-info: PR: #1852, branch: aditvenk/stack/18
@aditvenk aditvenk marked this pull request as draft March 31, 2026 04:49
@aditvenk aditvenk force-pushed the aditvenk/stack/18 branch from 72032bf to 28567a8 Compare March 31, 2026 04:50
@aditvenk aditvenk marked this pull request as ready for review March 31, 2026 04:50
@aditvenk aditvenk merged commit 826f989 into main Apr 1, 2026
20 of 21 checks passed
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 Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants