Skip to content

Sanitize '-' in make_template_hash for metal kernel - #4584

Merged
zcbenz merged 2 commits into
ml-explore:mainfrom
gokay-ai:fix/metal-kernel-negative-template-hash
Oct 2, 2026
Merged

zcbenz merged 2 commits into
ml-explore:mainfrom
gokay-ai:fix/metal-kernel-negative-template-hash

Conversation

@gokay-ai

Copy link
Copy Markdown
Contributor

Problem

Fixes #4579.

make_template_hash only rewrote <, >, and , . A negative int template arg (e.g. ("V", -1)) put a literal - into the generated Metal kernel name, which is not a valid C++ identifier, so compilation failed with Unable to build metal library from source.

Fix

Treat - like the other sanitized characters (replace with _).

Test

Added test_custom_metal_kernel_negative_template_int (Metal-only) using the issue repro. Couldn't run Metal on this Linux box — please check CI / Apple Silicon.

Thanks!

gokay-ai and others added 2 commits October 2, 2026 12:34
…ints

Negative int template args produced a '-' in the generated kernel name,
which is not a valid C++ identifier and broke Metal compilation (ml-explore#4579).

Signed-off-by: GokayAI <60583610+gokay-ai@users.noreply.github.com>
@zcbenz
zcbenz force-pushed the fix/metal-kernel-negative-template-hash branch from 1cc40e4 to e407096 Compare October 2, 2026 04:34
@zcbenz zcbenz changed the title fix(metal): sanitize '-' in make_template_hash for negative template ints Sanitize '-' in make_template_hash for metal kenel Oct 2, 2026
@zcbenz zcbenz changed the title Sanitize '-' in make_template_hash for metal kenel Sanitize '-' in make_template_hash for metal kernel Oct 2, 2026
@zcbenz
zcbenz merged commit 908148e into ml-explore:main Oct 2, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Negative template int breaks kernel compilation.

2 participants