Repository navigation
Inkling 2 Mini on Metal: six fewer steps a visit, the convolutions read their rows in place and the running sums take theirs (plain decode 61 to 63 tok/s, same bits) - #4689
Draft
sethforprivacy wants to merge 47 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
…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
…16 weight rows by 32 of an expert's pairs an op
… skips the bias and key tests on far tiles, and loads a query row four values at a time
…re, and the running sums take theirs: six steps fewer a visit
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
A visit of a round is a chain of barrier-separated steps, 27 on a gated visit, and at one row most of them are waiting, not working. This removes six of them without changing a sum. One plain stream goes from 61.0 and 61.6 tok/s to 62.7 and 63.3, four plain streams from 217 to 224, and a 45K-token prompt from 2,376 to 2,417 tok/s.
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, 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, 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 and Inkling 2 Mini on Metal: the prompt kernel keeps one set of sums in registers and skips the bias on far tiles (prefill 2,215 to 2,376 tok/s at 45K, same bits) #4666 (232ee08a3). This pull request's own commit isf6876bf0c. It needs 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'sstaged; the rest of the stack is where it was measured.atc overlap --json: not run; ATC is not installed on the machine that pushes.1. A convolution reads its rows where they are (one step). Each of a visit's four convolutions had a step of its own that copied a stream's three old rows and the launch's rows into one staged run of taps, and a barrier before the convolution read them.
tf_inkling2_conv_staticandtf_inkling2_conv_dynamicnow take the old rows and the launch's rows as two buffers (ink_tappicks by row), so the copies run beside the convolution instead of before it. The staged taps are still written: the commit at the end of the forward reads them.2. The running sums take their convolution themselves (five steps). After the attention output and after the expert output the visit ran a staging step, a static convolution, and then a pointwise kernel that adds the result to the running sum.
tf_ink2_attention_partialandtf_ink2_mlp_partialnow compute that convolution for their own element, with the same expression and the same BF16 store between it and the add, so each of the two chains is one step where it was three.tf_ink2_mlp_partialalso writes p widened, which was the next visit's first step; the widen stays where p is set some other way (after the embedding, and after a pass's reset).The two convolution outputs had scratch buffers of their own (
attn_conv,mlp_conv), which nothing reads now; they are gone.Which bits change. None. Every expression is the one it replaces, with the same FP32 order and the same BF16 rounding between the convolution and the add. Every reply in the receipt has the hash it had on #4666.
Checks on this head
f6876bf0c.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, with a new host test of the convolution the partials take.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.zig fmt --check build.zig zigandgit diff --check: clean.mlp_partialmoves from the numeric gate to its own exact check, which also compares the widened p with the p it stored. Its planted fault (the add's sign) andattention_partial's (the block layout) stay red. The two glue convolutions bind one taps buffer at two offsets and land where they did (worst 0.978 and 0.969 of the bound).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: nothing here depends on the tensor units, so the change reaches them, and I cannot run them. CUDA and HIP are not touched.Receipt
inkling2_loopMetal path, every row.thinkingmachines/Inkling-2-Mini@ed40e7da625f594fc9c4990f5f66be24873c22d7. The served rows are the whole stack (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, Inkling 2 Mini on Metal: a window's grammar masks step by the padded vocabulary, so a structured reply passes its second row #4635 and Inkling 2 Mini DSpark on Metal: the block attends on the M5 tensor units, so a hold costs the same at any context #4660 at their current heads, Metal loader: a checkpoint span of 16 GiB or more loads (each pread capped at 1 GiB) #4435 applied), without and with this commit.One plain stream, 200 tokens,
--parallel 4 --context 65536, two server starts each (the same reply every time):That is 0.43 ms of a 14.1 ms round for six steps, about 0.07 ms a step removed.
Served,
--parallel 4 --prompt-cache-gib 0, TensorFold's clients (256 tokens, greedy, three reps) andlane_bench.py:--drafter--drafterThe drafted chat row moves by more than this change from one server start to the next (the concurrent client's one-stream row for the same prompt reads 93.6 before and 95.9 on this head), so I read the drafted rows as level to slightly faster, not as a loss.
bench_concurrent.py --alone --serial: every reply equals its solo run, plain and with the drafter, at one stream and at four, 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 before.Checklist
convis new. The two partial entries' probes bind the new buffers, so they do not run against the old kernels.)"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (All three on the stack with this commit, 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 keeps one set of sums in registers and skips the bias on far tiles (prefill 2,215 to 2,376 tok/s at 45K, same bits) #4666: plain rounds and prompts are faster; drafted rounds are level within their spread.)