Repository navigation
Inkling 2 Mini on Metal: 512-row prefill chunks, sliding NAX prompt attention, and mv_mma dense prefill (620 to 1,287 tok/s on M5 Ultra) - #4543
Closed
gilby wants to merge 33 commits into
Conversation
Derive per-visit cache access and exact arithmetic for the 48 visits so CUDA admission and kernels have a reference before serving is enabled.
Decode stored NVFP4 and MXFP8 expert weights to BF16 and launch them beside the grouped expert/vision kernels, with exact tensor baselines and planted faults.
Launch cross-pass messages, rank-64 gates, residual steps and split QKV with FP32 reductions, BF16 rounding controls and per-launch resource records.
Run all 48 visits with per-visit cache state, prompt snapshots and exact rollback. Refuse TP, vision and DSpark loading until those engines exist.
… rows where prep wrote them
…in the fewest 1,024-key folds a slot
…up to 32 rows is one launch
…uffers, independent launches side by side
… a row's sums never depend on its chunk
…t attention, and use mv_mma for prompt dense projections
Open
8 tasks done
ashhart
force-pushed
the
lead/inkling2-mini
branch
from
November 23, 2026 19:59
3e0e9bc to
f790014
Compare
Contributor
Author
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
#4523(stacked onlead/inkling2-mini),state.zigcapped prefill chunks atmax_rows = 64,attention_plan.zig:usePromptrestrictedtf_ink2_attn_promptto global layers (l.window == 0), andforward.zig:dense()looped 32-row scalar matvecs even during prefill (~620 tok/s 20.5K cold prefill on Apple M5 Ultra). After: widensmax_rows/prompt_rowsto 512 (withlogits_allcapped atbatch_rows = 32to save 384 MiB), extendstf_ink2_attn_promptwith register-cachedQand sliding-window (window > 0,partials_rh = 1) support forrows > 64, and routesdense()(rows > 32) through bit-exactdsv41_metal.mv_mma, raising 20.8K cold prefill from 620.3 to 1,286.7 tok/s (2.07x) while preserving decode speeds (49.7 tok/splainc=1,156.0 tok/splainc=4steady,63.1 tok/sDSparkc=1,144.3 tok/sDSparkc=4steady).ee248f9e3c, targetinglead/inkling2-mini); this PR adds 1 commit (d800406adc, 8 files).atc overlap --json: Built directly on top of#4523(ee248f9e3c); zero conflict with#4465or our prompt-cache PR.Checks on this head
d800406adc(stacked on Inkling 2 Mini on Metal: routed experts on the M5 tensor units at every width (16 rows 49 to 36 ms, 64 rows 138 to 84 ms) #4523ee248f9e3c)python3 tools/zig/lean_check.py: 0 new findings across all 8 touched files.zig test zig/src/families/inkling2/metal/attention_plan.zig— 5/5 passed.zig build native -Doptimize=ReleaseFast -Dcpu=apple_m1— passed.zig fmt --checkandgit diff --check— clean.tf-kernel-contract --only inkling2— 100% PASS, 0 missed controls, 0 limit problems across Apple M5 Ultra, Apple M5 Pro, and Apple M3 Ultra (details below).Receipt
#4523+#4465baseline onthinkingmachines/Inkling-2-Minied40e7da625f594fc9c4990f5f66be24873c22d7, Apple M5 Ultra 512 GiB,--prompt-cache-gib 0,T=0.0):512/2K/8K/16Kunique-salt sweep):L~512(~830 tok):447.5 tok/s→696.4 tok/s(+56%)L~2048(~2,780 tok):592.0 tok/s→1,057.5 tok/s(+79%)L~8192(~10,530 tok):630.9 tok/s→1,286.7 tok/s(2.04x)L~16384(~20,810 tok):620.3 tok/s(33.1sTTFT) →1,285.6 tok/s(16.2sTTFT, 2.07x)c=1gpu-chat:49.7 tok/s→49.65 tok/s; Plainc=4steady:156.3→156.0 tok/sc=1gpu-chat:63.11 tok/s→63.11 tok/s; DSparkc=4agg:136.4→138.4 tok/sinkling2Metalprompt_attention.metal,attention_plan.zig,attention.zig,state.zig,experts.zig,forward.zig,model.zig.#4523(ee248f9e3c), headd800406adc, Zig 0.17.0, Xcode Metal 4.0 toolchain, Apple M5 Ultra 512 GiB / M5 Pro 64 GiB (macOS 27.2.1) & M3 Ultra 512 GiB (macOS 26.6.2),thinkingmachines/Inkling-2-Minied40e7da625f594fc9c4990f5f66be24873c22d7.inkling2prompt prefill (rows > 32formv_mma,rows > 64for sliding/globaltf_ink2_attn_prompt); verified on M5 Ultra, M5 Pro, and M3 Ultra.mv_mmais bit-equal tomv; slidingtf_ink2_attn_promptuses the same BF16P@Vcontract as globaltf_ink2_attn_prompt;plain == DSpark == warm_cachedverified bit-identical (sha=2fb59b60ffd3).tools/bench_openai.py.--prompt-cache-gib 0).Kernel contract, only when a GPU kernel is new or changed
tf_ink2_attn_prompt(extended to slidingwindow > 0forrows > 64and register-cachedQ; already registered ininkling2_attention_metal_records.zigand tested inmetal_inkling2_attention.zig)tf_dsv41_mv_mma_bf16(already registered & contract-verified across M1–M5)metal_inkling2_attention_controls.zigcontrols all remain red as planted (45/45 on M5, 41/41 on M3).SUMMARYline and exit status:applegpu_g17, tensor unitstrue):SUMMARY 45 kernels: 45 pass gates 1-4, 0 fail, 0 known findings; 45 controls: 45 red as planted, 0 missed; 0 limit problems; gates 5664 ms, limits 389 ms(exit 0)applegpu_g17, tensor unitstrue):SUMMARY 45 kernels: 45 pass gates 1-4, 0 fail, 0 known findings; 45 controls: 45 red as planted, 0 missed; 0 limit problems; gates 5602 ms, limits 7 ms(exit 0)applegpu_g15, tensor unitsfalse):SUMMARY 41 kernels: 41 pass gates 1-4, 0 fail, 0 known findings; 41 controls: 41 red as planted, 0 missed; 0 limit problems; gates 5641 ms, limits 566 ms(exit 0)Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.--drafter, no slower than without it, greedy and sampled.