Document -target as mandatory when building the shader metallib - #379
Document -target as mandatory when building the shader metallib#379arkavo-com wants to merge 1 commit into
Conversation
Without -target, `metal` compiles for whatever the installed SDK defaults to rather than for this package's .macOS(.v26) deployment target. Kernels built for a newer OS than the one running them load fine, resolve every function, and produce correct output at roughly a quarter of the speed — nothing about the result looks wrong. The trap is that the default is correct until an SDK bump moves it. The committed VRMMetalKitShaders.metallib is air64_v28-apple-macosx26.0.0 because it was built in Oct 2025, before the bump, not because the documented commands were right. Rebuilding it under Xcode 27 without -target yields air64_v29-apple-macosx27.0.0 and the slowdown. Not hypothetical: this shipped in arkavo-agent 0.4.0 and cost ~4x on decode (15.9 vs 59.6 tok/s, M4 mini, same binary, only the kernel library swapped) — see arkavo-agent PR #192. Also switches the link step from the `metallib` packager to the `metal` driver, which validates its inputs against the target it links for, and adds a metal-lipo verification step to run before committing a rebuilt metallib. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xw8w7bQMjujBgZYiqPzVur
| This is not hypothetical: it shipped in `arkavo-agent` 0.4.0 and cost ~4x on decode | ||
| (15.9 vs 59.6 tok/s, measured M4 mini, same binary, only the library swapped). See | ||
| arkavo-agent PR #192. |
There was a problem hiding this comment.
💡 Quality: Benchmark figure in doc (59.6 tok/s) differs from PR description (62.5)
The PR description's comparison table reports 62.5 tok/s for the explicit-target case, but the committed CLAUDE.md text (and commit message) says 59.6 tok/s for the same comparison. This won't affect build correctness, but a reader cross-referencing the linked arkavo-agent PR #192 or the PR description against the doc may be confused by the mismatched number. Reconcile the figure so the doc and the PR narrative agree (e.g. update the PR description or the doc text to the same value).
Was this helpful? React with 👍 / 👎
|
Note Automatic reviews are paused because your team has used its included automatic processing for this billing period (headroom scales with your seat count). You can still comment "Gitar review" to run one anytime, and automatic reviews resume on their own by August 1. Add seats for more headroom. Code Review 👍 Approved with suggestions 0 resolved / 1 findingsDocuments the mandatory -target flag in CLAUDE.md for building shader metallib files to prevent performance degradation from SDK default mismatches. Consider reconciling the benchmark figure in the documentation with the PR description. 💡 Quality: Benchmark figure in doc (59.6 tok/s) differs from PR description (62.5)The PR description's comparison table reports 62.5 tok/s for the explicit-target case, but the committed CLAUDE.md text (and commit message) says 59.6 tok/s for the same comparison. This won't affect build correctness, but a reader cross-referencing the linked arkavo-agent PR #192 or the PR description against the doc may be confused by the mismatched number. Reconcile the figure so the doc and the PR narrative agree (e.g. update the PR description or the doc text to the same value). 🤖 Prompt for agentsWas this helpful? React with 👍 / 👎 | Gitar |
Why
The shader-build commands in
CLAUDE.mdpass no-target, sometalcompiles for whatever theinstalled SDK defaults to rather than for this package's
.macOS(.v26)deployment target.Kernels built for a newer OS than the one running them load fine, resolve every function, and
produce correct output — at roughly a quarter of the speed. Nothing about the result looks
wrong, which is exactly what makes it dangerous.
This is not hypothetical
It shipped in
arkavo-agent0.4.0 and cost ~4x on decode. Measured on an M4 mini, gemma-4 E2BQ4_K_M, same binary with only the kernel library swapped:
air64_v29-apple-macosx27.0.0(target defaulted)air64_v28-apple-macosx26.0.0(target explicit)Root cause and fix: arkavo-ai/arkavo-agent#192.
Why this repo has not been bitten yet
Sources/VRMMetalKit/Resources/VRMMetalKitShaders.metallibis currentlyair64_v28-apple-macosx26.0.0— correct. But that is because it was built in Oct 2025, beforethe SDK default moved, not because the documented commands are right. The default is correct
until a toolchain bump moves it. Rebuilding that metallib today under Xcode 27 with the commands
as written produces
air64_v29-apple-macosx27.0.0and the slowdown, with no source change andnothing in review to catch it.
What changed
Docs only — no code, no rebuilt binary.
-target air64-apple-macos26.0on the compile step, with an explanation of why it is not optional.metallibpackager to themetaldriver, which validates itsinputs against the target it links for.
metallibaccepts whatever AIR it is handed.metal-lipo -infoverification step to run before committing a rebuilt metallib(
air64_v28expected;v29means the target was defaulted).makeDefaultLibrary(); an iOS artifact would need its own-target air64-apple-ios26.0build.Branch name is
fix/workflowfor historical reasons — it carried unrelated work that has sincelanded on
main, and this is now the only commit on it.🤖 Generated with Claude Code
https://claude.ai/code/session_01Xw8w7bQMjujBgZYiqPzVur