Skip to content

[Metal] Enable Metal 4 shader compilation#19595

Open
oraluben wants to merge 2 commits into
apache:mainfrom
oraluben:tvm-for-cooperative-tensor
Open

[Metal] Enable Metal 4 shader compilation#19595
oraluben wants to merge 2 commits into
apache:mainfrom
oraluben:tvm-for-cooperative-tensor

Conversation

@oraluben
Copy link
Copy Markdown
Contributor

Use the latest SDK language version when available so generated MPP tensor_ops shaders can compile on M5+ while preserving the existing fallback for older SDKs.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a preprocessor check to support MTLLanguageVersion4_0 in the Metal runtime. Feedback indicates that since MTLLanguageVersion constants are enums and not macros, the current check will always evaluate to false, rendering the change ineffective. It is suggested to use SDK version macros for proper feature detection.

Comment thread src/runtime/metal/metal_module.mm Outdated
Use the latest SDK language version when available so generated MPP tensor_ops shaders can compile on M5+ while preserving the existing fallback for older SDKs.
@oraluben oraluben force-pushed the tvm-for-cooperative-tensor branch from 7c4074d to d19d152 Compare May 23, 2026 11:10
@tlopex
Copy link
Copy Markdown
Member

tlopex commented May 25, 2026

Seems that there is something wrong with CI. Could you retrigger it? @oraluben

Copy link
Copy Markdown
Member

@tlopex tlopex left a comment

Choose a reason for hiding this comment

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

Thanks for updating the feature detection to use the SDK version macro.

I’m concerned that selecting MTLLanguageVersion4_0 solely based on the build SDK can introduce a runtime compatibility regression. A TVM binary built with a macOS 26 SDK may still run on systems/devices where Metal 4 is not supported, but this change would request MSL 4.0 for every Metal runtime compilation, including shaders that would otherwise compile fine with MTLLanguageVersion2_3.

Could we avoid making Metal 4 the unconditional language version whenever the build SDK exposes it? For example, either add a runtime/device capability guard, or try Metal 4 only when needed and fall back to MTLLanguageVersion2_3 if compilation fails.

Also, please clarify what environment was used to validate the new branch, since the current CI does not appear to exercise the __MAC_OS_X_VERSION_MAX_ALLOWED >= 260000 path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants