Repository navigation
inkling2 metal: match kernel threadgroup reservations and enforce load guards - #4981
Conversation
|
I tested the landing order main I also ran the device contract on an M5 Max (128 GB, macOS 27.2, Xcode 27.2, Zig 0.17.0): zig build tf-kernel-contract -Dcpu=apple_m1 -Doptimize=ReleaseFast
./zig-out/bin/tf-kernel-contract --only 'metal inkling2'Exit 0. Igor Lessio - AIFLOW LABS |
|
Thanks, @gilby. The reservation attributes match the existing launches, the shader bodies are unchanged, and the new load guards clean up before returning an error. The host and contract results, including the combined M5 check, support this bounded fix. Ready to land with the normal final-tree checks. The M3 result keeps its disclosed compile overlay; it is not a run of this exact head, and it is not a speed comparison.
|
|
I checked the three-way integration on On M5 Max, Igor Lessio - AIFLOW LABS |
|
I tested exact train #5016 zig build test-inkling2-host test-inkling2-metal-host test-inkling2-launch-map-host compile-inkling2-native-host tf-kernel-contract -Dfixed-cpu -j2 --summary all
./zig-out/bin/tf-kernel-contract --only 'metal inkling2'The exact train passed 148 tests with 10 skips. On device all 61 kernels passed, all 65 planted controls were caught, and all 71 Inkling launch-limit checks passed. I also combined #5016, #5014 and post-#4895 main This checks the host gates and M5 launch behavior in both trees. I did not run an exact-head M3 device test or a full checkpoint. Igor Lessio - AIFLOW LABS |
…d guards Refs ashhart#4961 - Add explicit max_total_threads_per_threadgroup(32|128|256) attributes matching launch records across glue, glue_split, loop, loop_split, runtime, and dspark Metal shaders to clear offline M1/M2 reservation mismatches. - Enforce pipeline.maxThreads() guards at load time in attention, glue, loop, dspark_kernels, and model. - Verify shader reservation attributes against contract records in host tests.
e299674 to
6d8cd4a
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: on
main, runningtf-kernel-contract --only "metal inkling2"against offline Metal targets flagged 6ReservationCodeMismatchlimit failures becauseglue.metal,glue_split.metal,loop.metal,loop_split.metal,runtime.metal, anddspark.metalomitted explicit[[max_total_threads_per_threadgroup(N)]]attributes matching their launch records, andattention.zig,glue.zig,loop.zig,dspark_kernels.zig, andmodel.ziglacked load-timepipeline.maxThreads()guards. After: every kernel in those 6 shaders carries explicit[[max_total_threads_per_threadgroup(32|128|256)]]matching.reserved = .threads, load-timemaxThreads()checks return named errors when exceeded, and host tests verify the shader attributes against contract records.main(3795e6054c), 1 commit (e299674146, 15 changed files,79 insertions(+), 14 deletions(-)).atc overlap --json: Checked one299674146againstmain(changedFiles: 15,workingTree_overlaps: [],conflicts: []).Checks on this head
e299674146tools/pr_check.py:lean 165 vs 165, 0 new,15 changed files,0 error(s). Touched.zigline counts max299lines (<= 600).-Dcpu=apple_m1 -Doptimize=ReleaseFast):zig fmt --check build.zig zigandgit diff --check origin/main..HEADone299674146— exit0.e299674146):zig build test-inkling2-host test-inkling2-metal-host:51/51 steps succeeded; 146/156 tests passed (10 skipped)(test-inkling2-host:45 pass, 4 skip;test-inkling2-metal-host:101 pass, 6 skip)../zig-out/bin/tf-kernel-contract --only "metal inkling2":SUMMARY 61 kernels: 61 pass gates 1-4, 0 fail, 0 known findings; 65 controls: 65 red as planted, 0 missed; 0 limit problems(gates 10183 ms, limits 522 ms, exit0).Metal 3, identical 15-file patch35dae9476ewith 2-linethreadqualifier overlay onprompt_attention.metallines 11 and 15):./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 10448 ms, limits 92 ms, exit0).e299674146.max_total_threads_per_threadgroupattributes<= 256and offline limit checks).Receipt
ReservationCodeMismatchlimit failures without altering runtime arithmetic, dispatch widths, or kernel behavior (seeBENCH_GATED_SKIPnote on Inkling 2 Mini Metal V4: exact-serial scaling, GPU sampling, DFlash 2 acceleration, and kernel fusions #4961 for the separateMTLIndirectCommandBufferinvestigation).inkling2Metal shaders (dspark.metal,glue.metal,glue_split.metal,loop.metal,loop_split.metal,runtime.metal) and Metal pipeline loaders (attention.zig,dspark_kernels.zig,glue.zig,loop.zig,model.zig) plus shader attribute unit tests.e299674146onmain3795e6054c(M3 Ultra contract on identical patch35dae9476e), Zig0.17.0-Dcpu=apple_m1 -Doptimize=ReleaseFast, Apple M5 Max (applegpu_g17), Apple M3 Ultra 512 GiB (Metal 3).<= 256threads/TG).1-4with0findings.n/a— compile-time reservation attributes and load-timemaxThreads()checks only).n/a— no prompt arithmetic or launch geometry change).Kernel contract, only when a GPU kernel is new or changed
[[max_total_threads_per_threadgroup(32|128|256)]]attributes matching contract records across 31 existing kernels inglue.metal,glue_split.metal,loop.metal,loop_split.metal,runtime.metal, anddspark.metal(no new kernels added or replaced).e299674146) and 55 controls (M3 Ultra35dae9476e) fail red as planted (0missed).SUMMARYline and exit status:e299674146):SUMMARY 61 kernels: 61 pass gates 1-4, 0 fail, 0 known findings; 65 controls: 65 red as planted, 0 missed; 0 limit problems; gates 10183 ms, limits 522 ms(exit0).Metal 3,35dae9476e+ 2-lineprompt_attention.metalthreadoverlay):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 10448 ms, limits 92 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.