Repository navigation
inkling2: coalesce multi-row logits on Metal with 0-ULP contract parity - #5135
Conversation
da78c25 to
2e70cab
Compare
|
Thank you, @gilby. The tiled variants preserve the baseline's The remaining qualification is current-main-versus-head serving A/B on one M5 and one M3 Ultra with the pinned original Inkling 2 Mini checkpoint and its DSpark weights. The supplied serving receipt used an older base/head. The nonfinite parity gate also needs rows 1, 9 and 17 to cover r4, r16 and r32 alongside the existing r8 case. The branch merges cleanly on today's main. SAFE TO A/B once those exact cells are recorded.
|
2e70cab to
6b429e2
Compare
|
Thank you, @gilby, and thanks for adding the nonfinite cases across all four row variants. Inkling 2 Mini A/Bs against main, plain decode at 1 and 4 streams on chat and code, greedy and sampled:
The shader and dispatch in your latest push are byte-identical to what those runs measured (only the contract registration changed), so this goes into a landing train now.
|
|
Updated 1. Nonfinite Parity Update & Kernel Contracts (
|
| Hardware | Mode | code T=0 c=1 |
code T=0 c=4 |
chat T=0 c=1 |
chat T=0 c=4 |
code T=1 c=1 |
code T=1 c=4 |
chat T=1 c=1 |
chat T=1 c=4 |
Mismatches |
|---|---|---|---|---|---|---|---|---|---|---|
| Apple M5 Ultra 512 GiB | plain |
35.65->35.70 (+0.14%) |
55.50->57.80 (+4.14%) |
36.00->35.40 (-1.67%) |
56.40->59.05 (+4.70%) |
35.85->35.65 (-0.56%) |
56.05->58.85 (+5.00%) |
35.95->35.50 (-1.25%) |
57.05->59.55 (+4.38%) |
0 |
| Apple M5 Ultra 512 GiB | dspark |
55.40->55.40 (+0.00%) |
119.70->124.60 (+4.09%) |
37.70->39.05 (+3.58%) |
79.75->86.10 (+7.96%) |
32.05->32.05 (+0.00%) |
54.25->56.30 (+3.78%) |
31.60->32.70 (+3.48%) |
75.45->81.15 (+7.55%) |
0 |
| Apple M3 Ultra 512 GiB | plain |
27.30->27.55 (+0.92%) |
41.60->43.60 (+4.81%) |
27.35->27.25 (-0.37%) |
42.50->44.50 (+4.71%) |
27.35->27.35 (+0.00%) |
42.40->44.40 (+4.72%) |
27.25->27.20 (-0.18%) |
43.20->45.10 (+4.40%) |
0 |
| Apple M3 Ultra 512 GiB | dspark |
40.90->43.05 (+5.26%) |
98.75->106.40 (+7.75%) |
28.25->29.60 (+4.78%) |
64.10->75.35 (+17.55%) |
24.70->25.00 (+1.21%) |
44.80->47.35 (+5.69%) |
24.05->28.25 (+17.46%) |
58.20->62.30 (+7.04%) |
0 |
6b429e2 to
709fbd3
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:
tf_inkling2_logitsinzig/kernels/metal/inkling2/glue.metallaunched 1 thread per(vocab, row)reading unembedding weights strided across threads and re-reading unembedding weights separately for every row in a multi-stream / speculative verification batch.After: adds coalesced, multi-row tiled Metal logits kernels
tf_inkling2_coalesced_logits_r{4,8,16,32}(selected vialogitLaunch(rows)/glue.logits()) that stage 32 unembedding rows of 16bfloat2elements in threadgroup memory (sh_w[32][33]) and tileTILE_Rhidden vectors (sh_h) while preserving exactk = 0..2303sequential FP32 accumulation, BF16 rounding beforesoftcap30, and zero-ULP bit-for-bit output parity againsttf_inkling2_logits(logitsBaseline()kept for single/baseline comparison & contract reference).V5-1).origin/main(a44ffee88ae0a8dfbe037f345513875d32d53757), 1 commit (2e70cabde8bfbfebcef1e1c29d0cccc9b07e796e, 10 changed files).Checks on this head
2e70cabde8bfbfebcef1e1c29d0cccc9b07e796e(rebased cleanly ontoa44ffee88a#5001).python3 tools/pr_check.py --base origin/main --pr 5135:0 error(s), 4 warning(s)(advisory--pr/ inherited cycles;lean 164 vs 164, 0 new; import cycle edges 24 vs 24, 0 new). All touched files<= 564lines (glue.metal564,glue.zig257,glue_test.zig274,inkling2_glue_metal_records.zig23,metal_inkling2_logits.zig239,metal_inkling2_logits_controls.zig114,metal_inkling2_glue.zig504,kernel_contract.zig303,metal_inkling2_controls_host.zig16,metal_inkling2_main.zig61).zig fmt --check build.zig zigexit0;git diff --check origin/main..HEADexit0.Zig 0.17.0,-Dcpu=apple_m1 -Doptimize=ReleaseFast, Apple M5 Maxapplegpu_g17):zig build test-inkling2-host(47 pass, 4 skip),test-inkling2-metal-host(119 pass, 6 skip),test-inkling2-controls-host(26 pass),test-inkling2-launch-map-host(2 pass),test-kernel-contract,compile-inkling2-native-host, andtest-inkling2-logits-probe(3 pass) all exited0(100/100 steps,488/498pass,10pre-existing skips)../zig-out/bin/tf-kernel-contract):applegpu_g17, tensor unitstrue)--only "metal inkling2":SUMMARY 72 kernels: 72 pass gates 1-4, 0 fail, 0 known findings; 88 controls: 88 red as planted, 0 missed; 0 limit problems; gates 15376 ms, limits 660 ms(includingtf_inkling2_logits_coalescedworst error0.000across 17 shapes and0limit problems forr4/r8/r16/r32).applegpu_g15, tensor unitsfalse):--only "metal inkling2 logits"(1 kernels: 1 pass gates 1-4, 0 fail; 3 controls: 3 red as planted, 0 missed; 0 limit problems) and--only "metal inkling2 glue"(10 kernels: 10 pass gates 1-4, 0 fail; 13 controls: 13 red as planted, 0 missed; 0 limit problems).pmset -g thermpre/post every served A-B-B-A leg across all three Macs): nominal throughout (no CPU/thermal/performance warning recorded).Receipt
origin/main8f11b41ba0758821ebfd224fcccf664dcbddd5fcvsda78c251c79e2118aa10dfe44e97644f61f360fe,bench_concurrent.py --alone --serial --levels 1,4 --temperatures 0,1 --tokens 128 --reps 2 --seed 42;0cross-legtoken_sha256mismatches across all 48 cells across all 3 Macs):--no-drafts):code T=0 c=134.10 -> 34.35(+0.73%),c=454.70 -> 57.15(+4.48%);chat T=0 c=134.45 -> 34.35(-0.29%),c=455.40 -> 58.15(+4.96%);code T=1 c=134.05 -> 34.25(+0.59%),c=455.45 -> 58.00(+4.60%);chat T=1 c=134.40 -> 34.10(-0.87%),c=456.40 -> 59.00(+4.61%).--drafter {TARGET}):code T=0 c=154.30 -> 55.70(+2.58%),c=4110.75 -> 127.75(+15.35%);chat T=0 c=137.55 -> 38.55(+2.66%),c=478.65 -> 91.60(+16.47%);code T=1 c=130.70 -> 30.80(+0.33%),c=453.20 -> 55.65(+4.61%);chat T=1 c=130.35 -> 36.65(+20.76%,tpc 1.058 -> 2.169),c=476.95 -> 80.40(+4.48%).--no-drafts):code T=0 c=125.85 -> 26.90(+4.06%),c=448.75 -> 49.55(+1.64%);chat T=0 c=126.00 -> 27.05(+4.04%),c=451.10 -> 52.05(+1.86%);code T=1 c=125.50 -> 26.90(+5.49%),c=439.25 -> 39.80(+1.40%);chat T=1 c=125.75 -> 27.00(+4.85%),c=443.05 -> 43.50(+1.05%).--drafter {TARGET}):code T=0 c=134.60 -> 33.85(-2.17%),c=448.20 -> 49.45(+2.59%);chat T=0 c=124.55 -> 25.05(+2.04%),c=451.75 -> 52.90(+2.22%);code T=1 c=121.45 -> 22.20(+3.50%),c=437.85 -> 38.40(+1.45%);chat T=1 c=122.25 -> 22.40(+0.67%),c=443.80 -> 45.60(+4.11%).--no-drafts):code T=0 c=126.00 -> 26.40(+1.54%),c=441.35 -> 42.95(+3.87%);chat T=0 c=126.35 -> 26.25(-0.38%),c=442.05 -> 43.75(+4.04%);code T=1 c=126.20 -> 26.20(0.00%),c=441.85 -> 43.65(+4.30%);chat T=1 c=126.15 -> 26.25(+0.38%),c=442.80 -> 44.55(+4.09%).--drafter {TARGET}):code T=0 c=139.90 -> 42.25(+5.89%),c=497.85 -> 105.65(+7.97%);chat T=0 c=128.30 -> 29.15(+3.00%),c=464.15 -> 74.50(+16.13%);code T=1 c=124.10 -> 24.10(0.00%),c=442.65 -> 47.10(+10.43%);chat T=1 c=123.25 -> 27.75(+19.35%,tpc 1.049 -> 2.133),c=457.80 -> 62.00(+7.27%).zig/kernels/metal/inkling2/glue.metal,zig/src/families/inkling2/metal/glue.zig,glue_test.zig,zig/src/core/contract/inkling2_glue_metal_records.zig,zig/build/kernel_contract.zig,zig/tests/contract/metal_inkling2_{logits,logits_controls,glue,controls_host,main}.zig.2e70cabde8bfbfebcef1e1c29d0cccc9b07e796eonorigin/maina44ffee88ae0a8dfbe037f345513875d32d53757(3-Mac A-B-B-A served runs measured on pre-rebase treeda78c251c79e2118aa10dfe44e97644f61f360feon8f11b41ba0prior to#5001merge), Zig0.17.0-Dcpu=apple_m1 -Doptimize=ReleaseFast, Apple M5 Max (applegpu_g17), Apple M5 Ultra 512 GiB, Apple M5 Pro 64 GiB, Apple M3 Ultra 512 GiB; checkpoint Inkling-2-Mini.glue.logits); verified on Apple M5 and Apple M3 families; non-Apple GPU backends not modified.0-ULP bit-for-bit parity vstf_inkling2_logits(worst = 0.000across 17 contract shapes;0cross-legtoken_sha256mismatches across all 48 A-B-B-A served cells across 3 Macs).+4.96%plain (c=4) and+16.47%/+20.76%DSpark on M5 Ultra;+5.49%plain /+4.11%DSpark on M5 Pro;+4.30%plain /+19.35%DSpark on M3 Ultra.1logits row at prompt tail).Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.--drafter, no slower than without it, greedy and sampled.