Repository navigation
Inkling 2 Mini on Metal: wide prompt chunks take the routed experts on turned tiles, 16 weight rows by 32 of an expert's pairs an op - #4649
Draft
sethforprivacy wants to merge 45 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
…e of an expert is full
…de between a prompt's chunks
…to eight rows of a window
…y for up to 16 rows
… the prompt kernel, a tile of keys a chunk
…ps in the scratch, so a stream's cache stages a window only
… cap while replies decode
…s from the cache, with no staging between
…16 weight rows by 32 of an expert's pairs an op
This was referenced Nov 22, 2026
5 of 6 tasks
8 tasks done
ashhart
force-pushed
the
lead/inkling2-mini
branch
4 times, most recently
from
November 24, 2026 09:43
aefb063 to
c41911e
Compare
Owner
|
Sorry for the noise: this was closed automatically when #4387 landed on main and its base branch was removed. It is reopened and now targets
|
4 of 5 tasks
8 tasks done
17 tasks
This branch has not been deployed
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: a tensor-unit tile of the routed experts is 32 weight rows by 16 of an expert's pairs, at every chunk width. After: a chunk of more than 512 rows takes the same products on tiles turned the other way, 16 weight rows by 32 of the expert's pairs an op. A 1,024-row chunk gives an expert 64 pairs on average, so a 32-pair band is full, and a block of weights is decoded once for 32 pairs where it was decoded once for 16.
A 1,024-row prompt chunk at 16K tokens of context goes from 428 to 403 ms of GPU time, and a 45K-token prompt from 2,078 to 2,212 tok/s served. Same bits.
This is a proposal on top of #4387, opened as a draft.
3e0e9bcb83, then Inkling 2 Mini on Metal: #4387's native build compiles, its norms write their output, and concurrent streams equal solo #4446, Inkling 2 Mini on Metal: experts, gates, router, depth mix, combine, row batching, attention chunks and a concurrent forward (1,159 to 14 ms a row on M5 Ultra) #4448, 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) #4523, Inkling 2 Mini on Metal: prompt chunks of 256 rows, filled a chunk a call (a 45K prompt 702 to 905 tok/s; replies keep decoding beside a prompt) #4608, Inkling 2 Mini on Metal: a round's logits in one pass of the vocabulary (one drafted stream 106 to 123 tok/s, four streams 237 to 281) #4618, Inkling 2 Mini on Metal: a prompt's projections and sliding attention on the tensor units (a 45K prompt 906 to 1,634 tok/s) #4631, Inkling 2 Mini on Metal: prompt chunks of up to 1,024 rows, their taps staged in the scratch (a 45K prompt 1,634 to 1,892 tok/s) #4644 and Inkling 2 Mini on Metal: the prompt kernel reads its key tiles from the cache on M5 (a round at 96K context 28.6 to 21.5 ms, a 45K prompt 1,892 to 2,078 tok/s) #4645 (a09f3e7d7). This pull request's own commit is84ab2c63f. It needs 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) #4523's tiles and Inkling 2 Mini on Metal: prompt chunks of up to 1,024 rows, their taps staged in the scratch (a 45K prompt 1,634 to 1,892 tok/s) #4644's wide chunks; the rest of the stack is where it was measured.atc overlap --json: not run; ATC is not installed on the machine that pushes.The kernels.
ink2_units_t<FP8, GU>isink2_unitswith the tile turned: a threadgroup is 16 weight rows of one expert, and each simdgroup's op takes 32 of the expert's pairs, whereink2_unitstakes 32 weight rows by 16 pairs. The four entries aretf_ink2_{nvfp4,mxfp8}_{gu,down}_units_t. The decode of a weight block, the scale, the gate and the epilogue are the same code.Why the bits are the same. An output is one (pair, weight row) dot product. Both tiles accumulate it over the same 16-column steps in the same order with the same operands; the tile's orientation decides which outputs share an op, not an output's terms. So the width may choose between them, as #4523's rule allows only for kernels with one result: a row's sums still do not depend on the chunk it came in. Every served reply has the hash it had on #4645, among them the prompts that fill in 1,024-row chunks.
Who takes which.
experts.unitspicks by the call's rows: over 512, the turned tiles. Rounds, and prompt chunks beside other streams (256 rows at most since #4644), stay on #4523's tiles.experts.unitsTurnedasks for the turned tiles at any width, which is how the contract reaches them with small shapes.Checks on this head
84ab2c63f.zig build native -Dcpu=apple_m1: compiles.test-inkling2-metal-host,test-inkling2-host,test-inkling2-controls-host,test-inkling2-launch-map-host,test-inkling2-metal-capabilities,compile-inkling2-native-host): exit 0.tf-kernel-contract --only inkling2(-Doptimize=safe):SUMMARY 52 kernels: 52 pass gates 1-4, 0 fail, 0 known findings; 52 controls: 52 red as planted, 0 missed; 0 limit problems, exit 0. Four of the kernels and four of the controls are new: each turned entry against float64 on seven shapes, one of them 40 rows of one expert so that the pairs cross a 32-pair band, and its control (the NVFP4 factor doubled, the MXFP8 scale's exponent off by one) red at the first shape.zig fmt --check build.zig zigandgit diff --check: clean.zig build test test-goldenon this head (the stack's inherited failures are listed in Inkling 2 Mini on Metal: #4387's native build compiles, its norms write their output, and concurrent streams equal solo #4446). M1 to M4, which have no tensor units and never load these kernels. CUDA and HIP are not touched.Receipt
a09f3e7d7against this head.inkling2_loopMetal path, prompt chunks of more than 512 rows (a prompt filling alone).thinkingmachines/Inkling-2-Mini@ed40e7da625f594fc9c4990f5f66be24873c22d7,--parallel 4 --prompt-cache-gib 0. The served rows have Inkling 2 Mini DSpark on Metal: attention scale 1/sqrt(128), and the recurrent step reads kappa as FP32 #4447, Inkling 2 Mini DSpark on Metal: the hold in one command buffer, and drafts priced by the engine up to the whole block (one stream 44 to 97 tok/s on code, 4 streams 77 to 184-223) #4465, Inkling 2 Mini on Metal: a prompt-cache snapshot copies each key-value head's live rows, and the real-checkpoint serving tests run to it #4607, Inkling 2 Mini on Metal: with a drafter, the window fit prices a token at a token's bytes (a 64 GB limit holds the whole window for eight streams) #4622 and Inkling 2 Mini on Metal: a window's grammar masks step by the padded vocabulary, so a structured reply passes its second row #4635 at their current heads and Metal loader: a checkpoint span of 16 GiB or more loads (each pread capped at 1 GiB) #4435 applied.GPU time of a 1,024-row prompt chunk at 16K tokens of context, and of a 45K-token prompt in all (a development tree that is this stack with timing switches):
Served:
lane_bench.py--drafter--drafterThe decode rows do not reach the change (a round is at most a few dozen rows); they are there to show the build is otherwise the same. The drafted chat prompt's three repetitions were 96.1, 90.8 and 92.0.
bench_concurrent.py --alone --serial, four streams: 12 of 12 replies equal their solo runs, plain and with the drafter, and the serial check passes. The concurrency check's four replies and a three-turn chat with the prompt cache on and off have the hashes they had on Inkling 2 Mini on Metal: the prompt kernel reads its key tiles from the cache on M5 (a round at 96K context 28.6 to 21.5 ms, a 45K prompt 1,892 to 2,078 tok/s) #4645.Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (All three on this head, the resumed prompt with Inkling 2 Mini on Metal: a prompt-cache snapshot copies each key-value head's live rows, and the real-checkpoint serving tests run to it #4607 applied.)--drafter, no slower than without it. (Against Inkling 2 Mini on Metal: the prompt kernel reads its key tiles from the cache on M5 (a round at 96K context 28.6 to 21.5 ms, a 45K prompt 1,892 to 2,078 tok/s) #4645: prompts filling alone are faster, the rest unchanged.)