You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before: on main, routedExperts dispatches one weight read per (token, slot) route pair via tf_ink2_{nvfp4,mxfp8}_{gu,down}, re-reading expert weights for every row when rows >= 2 (concurrent decode batches, speculative verification, and prompt prefill). After: when rows >= 2 (<= 64 rows per prompt chunk), routedExperts runs tf_ink2_expert_group on GPU without host readback to bucket route pairs by expert ID into <= 8-pair work tiles and dispatches tf_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 to main's serial chain (0 ULP drift, exact bit-identical outputs); rows == 1 keeps the existing ungrouped path.
Stacked on: main (ed70f71aa7), 1 commit (38dfab19f7, 10 changed files, 1006 insertions(+), 46 deletions(-)).
atc overlap --json: Checked on 38dfab19f7 against main (changedFiles: 10; clean merge against origin/main4c79cfe346 via git merge-tree --write-tree; open PR overlap check noted pullRequest: 3076 conflicts on shared file, other open PR overlaps clean).
Tests run (-Dcpu=apple_m1 -Doptimize=ReleaseFast):
zig fmt --check build.zig zig and git diff --check ed70f71aa7..HEAD on 38dfab19f7: exit 0.
Apple M5 Max (38dfab19f7):
zig build test-inkling2-host test-inkling2-metal-host -Dcpu=apple_m1 -Doptimize=ReleaseFast: 8/8 steps succeeded (exit 0, also passes under default build zig build test-inkling2-host test-inkling2-metal-host).
./zig-out/bin/tf-kernel-contract --only "metal inkling2": SUMMARY 66 kernels: 66 pass gates 1-4, 0 fail, 0 known findings; 78 controls: 78 red as planted, 0 missed; 0 limit problems; gates 12868 ms, limits 47 ms (exit 0).
Apple M3 Ultra 512 GiB (Metal 3 compile-fix overlay):
./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 (exit 0).
CI: Pending GitHub Actions on 38dfab19f7.
Not run, and why: Non-Apple GPU backends (Metal-only change); Apple M1/M2 not directly available.
Receipt
Main against branch: Matched paired A-B-B-A served runs (--tokens 128 --reps 2, --parallel 4 --context 8192) comparing main vs grouped experts on Inkling-2-Mini (BF16/NVFP4/MXFP8), with 0 cross-leg token_sha256 mismatches across every cell:
Boxes it reaches: inkling2 Metal 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).
New switch? No (always active for rows >= 2).
Environment: Commit 38dfab19f7 stacked on ed70f71aa7, Zig 0.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.
Paths and platforms the change reaches: Routed expert gu and down projections when rows >= 2 across Apple Silicon Metal GPUs (NVFP4 layers 0..19, MXFP8 layers 20..23).
Exactness: 0 cross-leg token_sha256 mismatches 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 as main.
Decode speed before and after: See A-B-B-A tables above (up to +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 speed before and after: Cold first-request prefill (--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).
Licence of any new weights or drafter: n/a.
Kernel contract, only when a GPU kernel is new or changed
Kernels registered with the contract, and the kernel each one replaces:
metal inkling2 experts tf_ink2_nvfp4_gu_grouped (32 threads) — grouped companion to tf_ink2_nvfp4_gu for rows >= 2.
metal inkling2 experts tf_ink2_nvfp4_down_grouped (32 threads) — grouped companion to tf_ink2_nvfp4_down for rows >= 2.
metal inkling2 experts tf_ink2_mxfp8_gu_grouped (32 threads) — grouped companion to tf_ink2_mxfp8_gu for rows >= 2.
metal inkling2 experts tf_ink2_mxfp8_down_grouped (32 threads) — grouped companion to tf_ink2_mxfp8_down for rows >= 2.
A planted control for each new kernel, and each one fails as planted: All 78 planted controls (Apple M5 Max 38dfab19f7) and 68 planted controls (Apple M3 Ultra) fail red as planted (0 missed), including grouped bucket, tile, and output controls in metal_inkling2_experts_controls.zig.
Each backend's SUMMARY line and exit status:
Apple M5 Max (38dfab19f7): SUMMARY 66 kernels: 66 pass gates 1-4, 0 fail, 0 known findings; 78 controls: 78 red as planted, 0 missed; 0 limit problems; gates 12868 ms, limits 47 ms (exit 0).
Apple M3 Ultra (Metal 3 overlay): 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 (exit 0).
Chips I could not run: Apple M1/M2/M4 not directly available.
Checklist
The title and description match the head commit, including the receipt and the stack.
New tests fail before the change, pass after it, and skip cleanly without their dependency.
Comments and docstrings are one line. No measurements or history in the source.
No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.
Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.
No precision traded for speed.
Decode and prompt processing are no slower than main at one stream and the widest admitted; with --drafter, no slower than without it, greedy and sampled.
I tested main 4c79cfe346d3c239ff7dfd7aa694df799755bafa, followed by #4980920224e129, #4981e299674146 and this head 38dfab19f70ea77c5fbf326bb99e0d032df5d1ea. All three trial merges were clean. On the combined tree, Apple M5 Max 128 GB, macOS 27.2, Zig 0.17.0:
I also checked the reported #3076 overlap. At f9ca20f824, it conflicts in the same nine files on plain main and on the #4995-only trial merge, with identical conflict contents after removing the generated merge labels. This run covers the M5 kernel contract and integration with the two shader PRs. It did not run an M3 or a live checkpoint.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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(<= 64rows per prompt chunk),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(ed70f71aa7), 1 commit (38dfab19f7, 10 changed files,1006 insertions(+), 46 deletions(-)).atc overlap --json: Checked on38dfab19f7againstmain(changedFiles: 10; clean merge againstorigin/main4c79cfe346viagit merge-tree --write-tree; open PR overlap check notedpullRequest: 3076conflicts on shared file, other open PR overlaps clean).Checks on this head
38dfab19f7python3 tools/pr_check.py --base ed70f71aa7:lean 165 vs 165, 0 new,10 changed files,0 error(s),1 warning(s)(advisory--pr NUMBER). Touched file line counts max535lines (<= 600:zig/tests/contract/metal_inkling2_experts.zig535,metal_inkling2_experts_grouped.zig518,experts.metal470,forward.zig389,state.zig376,experts.zig202,experts_test.zig162,metal_inkling2_experts_controls.zig160,experts_plan.zig150,inkling2_experts_metal_records.zig27).-Dcpu=apple_m1 -Doptimize=ReleaseFast):zig fmt --check build.zig zigandgit diff --check ed70f71aa7..HEADon38dfab19f7: exit0.38dfab19f7):zig build test-inkling2-host test-inkling2-metal-host -Dcpu=apple_m1 -Doptimize=ReleaseFast:8/8 steps succeeded(exit0, also passes under default buildzig build test-inkling2-host test-inkling2-metal-host)../zig-out/bin/tf-kernel-contract --only "metal inkling2":SUMMARY 66 kernels: 66 pass gates 1-4, 0 fail, 0 known findings; 78 controls: 78 red as planted, 0 missed; 0 limit problems; gates 12868 ms, limits 47 ms(exit0).Metal 3compile-fix overlay):./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).38dfab19f7.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).38dfab19f7stacked oned70f71aa7, 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.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.38dfab19f7) and 68 planted controls (Apple M3 Ultra) fail red as planted (0missed), including grouped bucket, tile, and output controls inmetal_inkling2_experts_controls.zig.SUMMARYline and exit status:38dfab19f7):SUMMARY 66 kernels: 66 pass gates 1-4, 0 fail, 0 known findings; 78 controls: 78 red as planted, 0 missed; 0 limit problems; gates 12868 ms, limits 47 ms(exit0).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.