Repository navigation
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
Draft
sethforprivacy wants to merge 44 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
…mdgroup folds the partial sums itself
…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
8 tasks done
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
|
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:
tf_ink2_attn_promptcopies every 64-key tile of keys and values into threadgroup memory before its simdgroups read it, one BF16 value a load, 256 values apart, with two threadgroup barriers a tile. A round has three pairs a key head, so one of eight simdgroups uses what all 256 threads copied, and at a long context that copy is most of a round's attention. After, on M5, each simdgroup reads the blocks it needs from the cache, two four-value loads a lane, and there is no staging and no barrier.A one-row round at 96K tokens of context goes from 28.6 to 21.5 ms of GPU time, at 44K from 22.6 to 18.9. A 45K-token prompt goes from 1,892 to 2,078 tok/s. 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 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 (9f88b8008). This pull request's own commit isa09f3e7d7. It needs only 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's edits to the same kernel; the rest of the stack is where it was measured.atc overlap --json: not run; ATC is not installed on the machine that pushes.Why the copy is not needed. The staging was there so that a tile's rows are contiguous and its dead keys zero. A tile is 64 keys starting at a multiple of 64 (chunks are 64, or a multiple of 1,024), and a ring is a multiple of 64 rows (
ringForand the global ring both align totile_keys), so a tile never wraps its ring: its 64 rows are contiguous in the cache.ink_tile_getloads a lane's two rows of a block as twobfloat4, and gives zero for a key from the tile's live count on, which is what the copy stored. Nothing outside the tile's live rows is read.Before M5. The fragment layout there is another one (
TF_SIMD_FRAGS), and I cannot run it, so that build keeps the staging and its barriers exactly as they were, behind the same#ifdef.Which bits change. None: the operands are the same values. Every reply in the receipt has the hash it had on #4644.
Checks on this head
a09f3e7d7.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 48 kernels: 48 pass gates 1-4, 0 fail, 0 known findings; 48 controls: 48 red as planted, 0 missed; 0 limit problems, exit 0. The prompt kernel's two M5 entries (global and sliding) are the ones that exercise the change; their controls stay red.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, whose build of the kernel is unchanged. CUDA and HIP are not touched.Receipt
9f88b8008against this head.inkling2_loopMetal path: the global layers of every row, and the sliding layers of a prompt's rows.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 one-row round, plain, after a prompt of the given length (medians of 20 rounds, measured in a development tree that is this stack with timing switches):
With the attention left out a round at 44K takes 13.0 ms, so the attention's share there goes from 9.6 to 5.8 ms. One plain stream at 44K tokens of context decodes at 51.1 tok/s where it did 43.4.
Served:
lane_bench.py--drafter--drafterbench_concurrent.py --alone --serialequal their solo runs, plain and with the drafter; the concurrency check's four; a three-turn chat with the prompt cache on and off; one prompt at 64, 33, 16, 7 and 1 rows a chunk (development tree).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: 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: faster at long contexts and on prompts, unchanged at short ones.)