Repository navigation
inkling2 metal: fuse relative bias projection into decode and prompt attention - #5000
Conversation
|
The clean trial of zig build test-inkling2-host test-inkling2-metal-host test-inkling2-metal-capabilities tf-kernel-contract -Dfixed-cpu -j2 --summary all
./zig-out/bin/tf-kernel-contract --only 'metal inkling2'I also tried the landing order #4980 ( Igor Lessio - AIFLOW LABS |
|
Thanks, @gilby. The fusion keeps the 16-tap order and BF16 rounding before scoring. The frozen baselines match the parent, and the reported replacement parity and planted controls are useful. Safe for bounded A/B with full checkpoint/build identities and serial, resume and draft/plain checks. In the combined stack, retain the load guards and grouped-expert scratch while removing the old table pipeline and buffer.
|
2d955fd to
e66d1f5
Compare
|
I tested the combined tree on M5 Max with this PR at The #4995 pairing conflicts only in the name and size tables in zig build test-inkling2-host test-inkling2-metal-host test-inkling2-metal-capabilities \
tf-kernel-contract -Dfixed-cpu -j2 --summary all
./zig-out/bin/tf-kernel-contract --only 'metal inkling2'The combined tree passed 157 tests with ten skipped. All 67 Metal kernels passed, all 81 planted controls were caught, and no launch exceeded its limits. The fused scalar and prompt attention probes matched the frozen kernels bit for bit, and the four grouped expert kernels retained their bitwise comparisons. Checkpoint performance and served resume/draft parity were outside this run. Igor Lessio - AIFLOW LABS |
e66d1f5 to
e718a8d
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, each layer's Inkling 2 attention launches a separatetf_ink2_rel_tablekernel to materialize the[rows * heads, 1024]BF16 relative-bias table (rel_tab) beforetf_ink2_attn_scalar/tf_ink2_attn_promptread it back from global memory.After: removes
tf_ink2_rel_tableand therel_tabscratch buffer, and computes the same BF16-rounded relative bias on the fly directly fromrelandprojin identical projection tap order insidetf_ink2_attn_scalar(decode attention) andtf_ink2_attn_prompt(prompt attention). Adds reference parity proofs and planted controls against savedmainkernel baselines inmetal_inkling2_attention_ref.zigandmetal_inkling2_attention_controls.zig.main(47a605aa12,git merge-tree --write-treeclean:ed0f3ca88a)atc overlap --json:changedFiles: 12,myPullRequests: [],overlaps: [].Checks on this head
e66d1f50a0python3 tools/pr_check.py --base origin/main(python3 tools/zig/lean_check.py):lean 164 vs 164, 0 new,0 error(s)(12changed files);zig fmt --check build.zig zigandgit diff --check origin/main..HEADexit0.zig build compile-inkling2-native-host: exit0.zig build test-inkling2-host -Dcpu=apple_m1 -Doptimize=ReleaseFast:45 passed; 4 skipped; 0 failed(skipped: 4 optional checkpoint/tokenizer env tests).zig build test-inkling2-metal-host -Dcpu=apple_m1 -Doptimize=ReleaseFastbinary:104 passed; 6 skipped; 0 failed(skipped: env-gated checkpoint/alloc tests and 2 JPEG tests pending matchinglibjpeg-turbo).Receipt
--no-drafts --parallel 4,0cross-legtoken_sha256mismatches across all decode and cold-prefill cells on both machines):mainvs branch):--no-drafts --parallel 4 --context 8192,T=0.0,--tokens 128 --reps 2):c=1:code:16.80 -> 17.35 tok/s(+3.27%);chat:16.85 -> 17.30 tok/s(+2.67%).c=4:code:37.45 -> 39.45 tok/s(+5.34%, TTFT0.529 -> 0.524s,-0.85%);chat:38.40 -> 40.80 tok/s(+6.25%, TTFT1.712 -> 1.708s,-0.29%).--no-drafts --context 16384 --prompt-cache-gib 0):2048(2077prompt tokens):92.3 -> 92.5 tok/s(+0.11%,22.497s -> 22.458s).8192(8233prompt tokens):90.8 -> 91.0 tok/s(+0.11%,90.599s -> 90.528s).mainvs branch):--no-drafts --parallel 4 --context 8192,T=0.0,1.0,--tokens 128 --reps 2):c=1:code T=0.0:13.40 -> 13.55 tok/s(+1.12%);chat T=0.0:13.50 -> 13.65 tok/s(+1.11%, TTFT-0.32%);code T=1.0:13.45 -> 13.60 tok/s(+1.12%, TTFT-0.38%);chat T=1.0:13.55 -> 13.70 tok/s(+1.11%, TTFT-0.20%).c=4:code T=0.0:21.40 -> 21.80 tok/s(+1.87%, TTFT-1.04%);chat T=0.0:22.90 -> 23.40 tok/s(+2.18%);code T=1.0:21.35 -> 21.70 tok/s(+1.64%, TTFT-0.52%);chat T=1.0:22.90 -> 23.40 tok/s(+2.18%, TTFT-0.40%).--no-drafts --context 16384 --prompt-cache-gib 0):2048(2077prompt tokens):30.2 -> 30.6 tok/s(+1.32%,68.767s -> 67.879s).8192(8233prompt tokens):30.0 -> 30.2 tok/s(+0.67%,274.145s -> 272.625s).attention.metal,prompt_attention.metal,attention.zig,attention_plan.zig,forward.zig,state.zig, and attention contract/baseline/reference tests.2d955fd616stacked oned70f71aa7, Zig0.17.0-Dcpu=apple_m1 -Doptimize=ReleaseFast, Apple M5 Max (applegpu_g17), Apple M5 Ultra 512 GiB, Apple M5 Pro 64 GiB; checkpoint Inkling-2-Mini.tf_ink2_attn_scalar) and prompt attention (tf_ink2_attn_prompt) across Apple Silicon Metal GPUs; Apple M1/M2/M3/M4 not directly run on this slice.0cross-legtoken_sha256mismatches across allplain(--skip-serial) andprefillA-B-B-A legs on both Apple M5 Ultra and Apple M5 Pro;0-ULP bitwise BF16 parity against savedmainbaseline kernels verified bymetal_inkling2_attention_ref.zig.+2.67%..+6.25%on Apple M5 Ultra;+1.11%..+2.18%on Apple M5 Pro across allc=1,4andT=0.0,1.0cells).--prompt-cache-gib 0)2048/8192:+0.11%/+0.11%(22.497->22.458s/90.599->90.528s) on Apple M5 Ultra;+1.32%/+0.67%(68.767->67.879s/274.145->272.625s) on Apple M5 Pro.Kernel contract, only when a GPU kernel is new or changed
tf_ink2_attn_scalarandtf_ink2_attn_promptto project relative bias on the fly in identical BF16-rounded tap order, removingtf_ink2_rel_tableand therel_tabbuffer.66/66planted controls on Apple M5 Max (2d955fd616) and56/56on Apple M5 Pro fail red as planted (0missed), including relative-bias projection and tap-order parity controls inmetal_inkling2_attention_controls.zig.SUMMARYline and exit status:e66d1f50a0, rebased on47a605aa12):SUMMARY 62 kernels: 62 pass gates 1-4, 0 fail, 0 known findings; 66 controls: 66 red as planted, 0 missed; 0 limit problems; gates 13792 ms, limits 155 ms(exit0).f90c6a429c):SUMMARY 49 kernels: 49 pass gates 1-4, 0 fail, 0 known findings; 56 controls: 56 red as planted, 0 missed; 0 limit problems; gates 11214 ms, limits 7 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.