Repository navigation
inkling2 metal: exact-serial grouped routed experts for rows >= 2 - #4995
Conversation
|
I tested main zig build tf-kernel-contract -Dcpu=apple_m1 -Doptimize=ReleaseFast
./zig-out/bin/tf-kernel-contract --only 'metal inkling2'Exit 0. I also checked the reported #3076 overlap. At Igor Lessio - AIFLOW LABS |
|
Thanks, @gilby. Each grouped output keeps its ascending serial sum and rounding points, and results return to their original route positions before the unchanged combine. The contracts compare complete bytes with the old kernels, with controls for missing blocks, pairs and arithmetic changes. This is ready for the remaining comparisons. Please retain the full checkpoint/build identities and serial, resumed and memory evidence. The reported M5 single-stream latency increase and small M3 single-stream decode losses still need comparisons on an otherwise idle machine; gains in other cells do not settle them. The M3 overlay remains part of that receipt's scope.
|
38dfab1 to
0e09b9f
Compare
|
I reran the grouped-expert checks on M5 Max after trial-merging zig build test-inkling2-host test-inkling2-metal-host tf-kernel-contract -Dfixed-cpu -j2 --summary all
./zig-out/bin/tf-kernel-contract --only 'metal inkling2 experts'150 host tests passed with 10 skipped. All 17 expert kernels passed, all 30 planted controls were caught, and there were zero launch-limit problems. Each of the four grouped NVFP4 and MXFP8 gate/up and down entries matched its single-pair reference bit for bit across 16 shapes. This covers the rebased host/device contract. I didn't rerun the model-backed serial, resume, latency or memory comparisons on this head. Igor Lessio - AIFLOW LABS |
0e09b9f to
41bd6e1
Compare
|
The rebased zig build test-inkling2-host test-inkling2-metal-host tf-kernel-contract -Dfixed-cpu -j2 --summary all
./zig-out/bin/tf-kernel-contract --only 'metal inkling2 experts'This verifies the rebased kernel and host tests. Whole-checkpoint latency, memory and resume comparisons were outside my run. Igor Lessio - AIFLOW LABS |
41bd6e1 to
ffc7b03
Compare
ffc7b03 to
65642e7
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,routedExpertsdispatches one weight read per(token, slot)route pair viatf_ink2_{nvfp4,mxfp8}_{gu,down}, re-reading expert weights for every row whenrows >= 2(concurrent decode batches, speculative verification, and prompt prefill). After: whenrows >= 2(chunked at<= 64rows per prompt/batch slice),routedExpertsrunstf_ink2_expert_groupon GPU without host readback to bucket route pairs by expert ID into<= 8-pair work tiles and dispatchestf_ink2_{nvfp4,mxfp8}_{gu,down}_grouped, sharing expert weight loads across up to 8 active pairs per tile while keeping each per-output dot identical tomain's serial chain (0ULP drift, exact bit-identical outputs);rows == 1keeps the existing ungrouped path.main(f3c0fa8c65, includes#5000and#5058), 1 commit (ffc7b038cb, 10 changed files,1009 insertions(+), 39 deletions(-)).atc overlap --json: Checked onffc7b038cbagainstmain(f3c0fa8c65, cleangit merge-tree --write-treef7960f64e770040afcd7189c7c97f6220d6141fc):changedFiles: 10,overlaps: [].Checks on this head
ffc7b038cbpython3 tools/pr_check.py --base origin/main --pr 4995:lean 164 vs 164, 0 new,10 changed files,0 error(s)(1advisory warning: noCHANGELOG.mdline). Touched file line counts max544lines (<= 600:experts.metal544,zig/tests/contract/metal_inkling2_experts.zig535,metal_inkling2_experts_grouped.zig518,forward.zig422,state.zig375,experts.zig287,experts_test.zig162,metal_inkling2_experts_controls.zig161,experts_plan.zig150,inkling2_experts_metal_records.zig27).-Dcpu=apple_m1 -Doptimize=ReleaseFast):zig fmt --check build.zig zigandgit diff --check origin/main..HEADonffc7b038cb: exit0.ffc7b038cb):zig build -Dcpu=apple_m1 -Doptimize=ReleaseFast: exit0.zig build compile-inkling2-native-host: exit0.zig build compile-inkling2-native-host -Dtarget=x86_64-windows: exit0.zig build compile-native-cuda-windows: exit0.zig build test-inkling2-host -Dcpu=apple_m1 -Doptimize=ReleaseFast:45 pass, 4 skip (49 total)(exit0).zig build test-inkling2-controls-host:24 pass (24 total)(exit0).zig build test-kernel-contract:45/45 steps succeeded; 259/259 tests passed(exit0).zig build tf-kernel-contract -Doptimize=ReleaseFast: exit0.zig build test-inkling2-metal-host -Dcpu=apple_m1 -Doptimize=ReleaseFast:112 pass, 6 skip (118 total)(0failed;2JPEG tests skipped pending newerlibjpeg-turbo, exit0)../zig-out/bin/tf-kernel-contract --only "metal inkling2":SUMMARY 67 kernels: 67 pass gates 1-4, 0 fail, 0 known findings; 81 controls: 81 red as planted, 0 missed; 0 limit problems; gates 16821 ms, limits 212 ms(exit0)../zig-out/bin/tf-kernel-contract --only "metal inkling2 experts":SUMMARY 17 kernels: 17 pass gates 1-4, 0 fail, 0 known findings; 30 controls: 30 red as planted, 0 missed; 0 limit problems; gates 6479 ms, limits 61 ms(exit0).38dfab19f7,Metal 3compile-fix overlay; grouped kernel math unchanged):./zig-out/bin/tf-kernel-contract --only "metal inkling2":SUMMARY 53 kernels: 53 pass gates 1-4, 0 fail, 0 known findings; 68 controls: 68 red as planted, 0 missed; 0 limit problems; gates 13170 ms, limits 8 ms(exit0).ffc7b038cb.Receipt
--tokens 128 --reps 2,--parallel 4 --context 8192) comparingmainvs grouped experts on Inkling-2-Mini (BF16/NVFP4/MXFP8), with0cross-legtoken_sha256mismatches across every cell:--no-drafts,--skip-serial):c=1:code T=0.0:16.15 -> 16.20(+0.31%, TTFT0.222 -> 0.179s,-19.37%);chat T=0.0:16.10 -> 16.15(+0.31%, TTFT0.511 -> 0.483s,-5.48%);code T=1.0:16.15 -> 16.25(+0.62%, TTFT0.207 -> 0.235s,+13.25%);chat T=1.0:16.10 -> 16.15(+0.31%, TTFT0.507 -> 0.398s,-21.40%).c=4:code T=0.0:34.85 -> 40.40 tok/s(+15.93%, TTFT0.496 -> 0.426s,-14.10%);chat T=0.0:34.95 -> 39.95 tok/s(+14.31%, TTFT1.720 -> 1.064s,-38.16%);code T=1.0:34.45 -> 40.95 tok/s(+18.87%, TTFT0.508 -> 0.418s,-17.70%);chat T=1.0:34.80 -> 40.85 tok/s(+17.39%, TTFT1.716 -> 1.051s,-38.75%).--draftertarget):c=1:code T=0.0:26.10 -> 31.30 tok/s(+19.92%, TTFT-30.41%);chat T=0.0:23.25 -> 27.95 tok/s(+20.22%, TTFT-34.99%);code T=1.0:19.10 -> 23.05 tok/s(+20.68%, TTFT-9.93%);chat T=1.0:23.00 -> 27.70 tok/s(+20.43%, TTFT-36.50%).c=4:code T=0.0:29.90 -> 46.50 tok/s(+55.52%, TTFT0.555 -> 0.354s,-36.13%);chat T=0.0:23.10 -> 35.95 tok/s(+55.63%, TTFT1.815 -> 1.122s,-38.18%);code T=1.0:22.80 -> 33.30 tok/s(+46.05%, TTFT0.524 -> 0.358s,-31.61%);chat T=1.0:21.70 -> 32.05 tok/s(+47.70%, TTFT1.824 -> 1.122s,-38.47%).--no-drafts --context 16384 --prompt-cache-gib 0):2048(2077prompt tokens):92.3 -> 174.9 tok/s(+89.54%,22.496s -> 11.870s).8192(8233prompt tokens):90.9 -> 170.8 tok/s(+87.84%,90.582s -> 48.208s).Metal 3compile-fix overlay):--no-drafts,--skip-serial):c=1:code T=0.0:12.40 -> 12.40(0.00%, TTFT0.401 -> 0.209s,-47.94%);chat T=0.0:12.50 -> 12.40(-0.80%, TTFT0.967 -> 0.458s,-52.64%);code T=1.0:12.40 -> 12.40(0.00%, TTFT0.399 -> 0.174s,-56.34%);chat T=1.0:12.50 -> 12.45(-0.40%, TTFT0.960 -> 0.492s,-48.70%).c=4:code T=0.0:23.70 -> 33.65 tok/s(+41.98%, TTFT0.980 -> 0.469s,-52.19%);chat T=0.0:24.85 -> 34.10 tok/s(+37.22%, TTFT3.510 -> 1.442s,-58.94%);code T=1.0:23.75 -> 34.30 tok/s(+44.42%, TTFT0.982 -> 0.412s,-57.97%);chat T=1.0:24.95 -> 34.90 tok/s(+39.88%, TTFT3.473 -> 1.393s,-59.88%).--draftertarget):c=1:code T=0.0:17.20 -> 22.20 tok/s(+29.07%, TTFT-54.48%);chat T=0.0:15.25 -> 19.80 tok/s(+29.84%, TTFT-54.50%);code T=1.0:14.40 -> 18.10 tok/s(+25.69%, TTFT-55.57%);chat T=1.0:15.10 -> 19.70 tok/s(+30.46%, TTFT-56.37%).c=4:code T=0.0:14.95 -> 36.00 tok/s(+140.80%, TTFT1.031 -> 0.448s,-56.60%);chat T=0.0:10.30 -> 24.60 tok/s(+138.83%, TTFT3.617 -> 1.461s,-59.62%);code T=1.0:12.70 -> 26.85 tok/s(+111.42%, TTFT1.017 -> 0.476s,-53.20%);chat T=1.0:10.10 -> 22.80 tok/s(+125.74%, TTFT3.644 -> 1.460s,-59.94%).--no-drafts --context 16384 --prompt-cache-gib 0):2048(2077prompt tokens):42.2 -> 129.9 tok/s(+207.34%,49.220s -> 16.001s).8192(8233prompt tokens):36.9 -> 124.9 tok/s(+238.48%,223.364s -> 65.915s).inkling2Metal routed experts shader (experts.metal), expert dispatch/plan/host tests (experts.zig,experts_plan.zig,experts_test.zig), Metal forward/scratch (forward.zig,state.zig), and kernel contract registry/tests (inkling2_experts_metal_records.zig,metal_inkling2_experts.zig,metal_inkling2_experts_controls.zig,metal_inkling2_experts_grouped.zig).rows >= 2).ffc7b038cbstacked onmain(f3c0fa8c65, includes#5000and#5058), Zig0.17.0-Dcpu=apple_m1 -Doptimize=ReleaseFast, Apple M5 Max (applegpu_g17), Apple M5 Ultra 512 GiB, Apple M3 Ultra 512 GiB; checkpoint Inkling-2-Mini (A-B-B-A served receipts recorded pre-rebase on41bd6e1162againstmain9961ca4920).guanddownprojections whenrows >= 2across Apple Silicon Metal GPUs (NVFP4layers0..19,MXFP8layers20..23).0cross-legtoken_sha256mismatches across all A-B-B-A legs (plain,dspark,prefill) on both Apple M5 Ultra and Apple M3 Ultra; grouped kernels compute identical per-pair serial dot chains asmain.+18.87%plain /+55.63%self-drafted on Apple M5 Ultra; up to+44.42%plain /+140.80%self-drafted on Apple M3 Ultra).--prompt-cache-gib 0):+89.54%(2048) /+87.84%(8192) on Apple M5 Ultra;+207.34%(2048) /+238.48%(8192) on Apple M3 Ultra; TTFT improved up to-38.75%(M5 Ultra) and-59.94%(M3 Ultra).Kernel contract, only when a GPU kernel is new or changed
metal inkling2 experts tf_ink2_expert_group(128threads,2096bytes TG memory) — GPU route-pair bucketing kernel (<= 8pairs/tile).metal inkling2 experts tf_ink2_nvfp4_gu_grouped(32threads) — grouped companion totf_ink2_nvfp4_guforrows >= 2.metal inkling2 experts tf_ink2_nvfp4_down_grouped(32threads) — grouped companion totf_ink2_nvfp4_downforrows >= 2.metal inkling2 experts tf_ink2_mxfp8_gu_grouped(32threads) — grouped companion totf_ink2_mxfp8_guforrows >= 2.metal inkling2 experts tf_ink2_mxfp8_down_grouped(32threads) — grouped companion totf_ink2_mxfp8_downforrows >= 2.81/81planted controls across allmetal inkling2suites (30/30inmetal inkling2 experts, Apple M5 Maxffc7b038cb) and68/68planted controls (Apple M3 Ultra pre-rebase38dfab19f7) fail red as planted (0missed), including grouped bucket, tile, and output controls inmetal_inkling2_experts_controls.zig.SUMMARYline and exit status:ffc7b038cb,--only "metal inkling2"):SUMMARY 67 kernels: 67 pass gates 1-4, 0 fail, 0 known findings; 81 controls: 81 red as planted, 0 missed; 0 limit problems; gates 16821 ms, limits 212 ms(exit0).ffc7b038cb,--only "metal inkling2 experts"):SUMMARY 17 kernels: 17 pass gates 1-4, 0 fail, 0 known findings; 30 controls: 30 red as planted, 0 missed; 0 limit problems; gates 6479 ms, limits 61 ms(exit0).38dfab19f7,Metal 3overlay):SUMMARY 53 kernels: 53 pass gates 1-4, 0 fail, 0 known findings; 68 controls: 68 red as planted, 0 missed; 0 limit problems; gates 13170 ms, limits 8 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.