Repository navigation
metal: guard Inkling 2 and LFM2 generated libraries against repeated threadgroup-size attributes - #5405
Merged
Conversation
Collapse equal duplicate threadgroup attributes without changing kernel bodies, and reject conflicting bounds at build time. Route every Inkling source export through the shared check and validate the retained LFM2 prompt header before adding its reservation. Add focused source checks independent of the Apple SDK.
…t repeated threadgroup-size attributes
ashhart
force-pushed
the
lead/metal-threadgroup-guards
branch
from
November 27, 2026 19:03
5c21db5 to
a4eae69
Compare
ashhart
added a commit
that referenced
this pull request
Nov 27, 2026
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Metal compilers on current macOS refuse a kernel declaration that repeats
[[max_total_threads_per_threadgroup(N)]]and reject the whole library at load. M5 did first; since macOS 27.0 the M3 Ultra compiler does too. #5303 fixed the Inkling 2 convolution kernels that had the duplicate, and #5376 fixes the Flash Next, Nemotron and Qwen4 source rewriters. This adds the guard that keeps it fixed.[[kernel]]and prepended a 128-thread reservation, so a reservation already after the marker would have become a duplicate and a conflicting one before it would have been kept silently. It now keeps one, the value the kernel had, and refuses a conflict.Every library main emits today is byte-identical: a test reconstructs 20 library and alias hashes and lengths independently. A host test replaying the pre-#5303 Inkling 2 source fails before this change (four doubled headers) and passes after. Both landing orders with #5376 were checked.