Repository navigation
inkling2 metal: add explicit thread qualifiers in prompt attention helpers - #4980
Conversation
|
I reproduced the compiler failure on main xcrun -sdk macosx metal -std=metal4.0 -fmetal-math-mode=safe -c prompt.metal -o prompt.airThe pre-M5 source (with One wording detail for the receipt: Igor Lessio - AIFLOW LABS |
|
Thanks @gilby. The change adds only the five thread qualifiers in the two helper signatures; all arithmetic and call sites are unchanged. It merges cleanly. The compiler comparison covers both assembled shader variants, and the receipt now distinguishes the pre-M5 hardware path under MSL 4.0 from Metal 3.2 language support. The latter remains a separate limitation. This qualifier fix is ready to land from the source review.
|
920224e to
857c9f2
Compare
|
Thank you @gilby. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes. |
What this changes
Before: compiling
zig/kernels/metal/inkling2/prompt_attention.metalfor Apple M3 Ultra's pre-M5 shader path under macOS 26 failed withLibraryLoadbecause helper parameterss,mm,ll,a, andbinink_prompt_rhandink_foldomitted explicitthreadaddress-space qualifiers. After: both helpers declarethreadreferences explicitly (const thread InkPromptSeg& s,thread float& mm, ...), making Inkling 2 Mini's pre-M5 shader path inprompt_attention.metalcompile and pass natively on Apple M3 Ultra with zero arithmetic change.main(3795e6054c), 1 commit (920224e129, 1 changed file).atc overlap --json: Checked on920224e129againstmain(changedFiles: 1,0open-PR conflicts).Checks on this head
920224e129tools/pr_check.py:lean 165 vs 165, 0 new,1 changed files,0 error(s).zig fmt --check build.zig zigandgit diff --check origin/main..HEADon920224e129— exit0.8614421446on Apple M3 Ultra 512 GiB (pre-M5 shader path compiled viaCompileOptions.mlx()MSL 4.0, zero overlays,-Dcpu=apple_m1 -Doptimize=ReleaseFast):./zig-out/bin/tf-kernel-contract --only "metal inkling2":SUMMARY 48 kernels: 48 pass gates 1-4, 0 fail, 0 known findings; 55 controls: 55 red as planted, 0 missed; 0 limit problems(gates 11128 ms, limits 107 ms, exit0).Inkling-2-Minied40e7da):--no-drafts(16tokens,sha=8c6985a37103,12.78 tok/s,ttft=0.49s) and--drafter(16tokens,sha=8c6985a37103,24.49 tok/s,ttft=0.512s).920224e129.Receipt
mainfailsLibraryLoadon Metal 3 when compilingprompt_attention.metal; with this 2-linethreadqualifier fix, Apple M3 Ultra's pre-M5 shader path compiles natively (48/48kernels pass gates 1-4,55/55red controls,0limits) and serves both plain (12.78 tok/s,sha=8c6985a37103) and drafted (24.49 tok/s,sha=8c6985a37103) bit-identically.inkling2Metalprompt_attention.metal(tf_ink2_attn_prompt).920224e129onmain3795e6054c(M3 Ultra contract & live smoke on identical patch8614421446), Zig0.17.0-Dcpu=apple_m1 -Doptimize=ReleaseFast, Apple M3 Ultra 512 GiB (macOS 26.6.2, pre-M5 shader path viaCompileOptions.mlx()MSL 4.0),Inkling-2-Minied40e7da625f594fc9c4990f5f66be24873c22d7.prompt_attention.metalon macOS 26 (note:CompileOptions.mlx()compiles with MSL 4.0 even on pre-M5 hardware; with-std=metal3.2, sharedmpphelpers still fail separately). M5 tensor-unit paths accept explicitthreadqualifiers identically.--draftersmoke check bit-identical (sha=8c6985a37103);tf_ink2_attn_promptpasses contract gates1-4with0math changes.12.78 tok/splain,24.49 tok/sdrafted on M3 Ultra smoke).ttft=0.49splain,0.512sdrafted on short smoke prompt).Kernel contract, only when a GPU kernel is new or changed
tf_ink2_attn_promptinprompt_attention.metal(no new kernels added or replaced).metal inkling2planted controls fail red as planted on Apple M3 Ultra (0missed).SUMMARYline and exit status: Apple M3 Ultra (pre-M5 shader path,CompileOptions.mlx()MSL 4.0,8614421446):SUMMARY 48 kernels: 48 pass gates 1-4, 0 fail, 0 known findings; 55 controls: 55 red as planted, 0 missed; 0 limit problems; gates 11128 ms, limits 107 ms(exit0).Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.--drafter, no slower than without it, greedy and sampled.