Repository navigation
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
Draft
sethforprivacy wants to merge 43 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
This was referenced Nov 22, 2026
This was referenced Nov 22, 2026
5 of 6 tasks
8 tasks done
ashhart
force-pushed
the
lead/inkling2-mini
branch
from
November 23, 2026 19:59
3e0e9bc to
f790014
Compare
ashhart
force-pushed
the
lead/inkling2-mini
branch
3 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
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 prompt fills in chunks of up to 256 rows, and every stream's cache carries a 166 MB buffer to stage a chunk's convolution taps. After, two commits:
642bb4f78: a chunk wider than a window stages its taps in the scratch it runs in, so a cache stages a window only (12 MB).9f88b8008: chunks of up to 1,024 rows. A stream filling beside other streams keeps to 256, and the host's--decode-sharecap applies as for other chunk-invariant families.A 45K-token prompt goes from 1,634 to 1,892 tok/s with the same reply. A stream's fixed state goes from 380 to 352 MB.
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 and 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 (2d7a9c90c). This pull request's own commits are642bb4f78and9f88b8008.atc overlap --json: not run; ATC is not installed on the machine that pushes.Why wider. With #4631 half of a chunk is the routed experts, and of that 30 % is reading all 128 experts' weights, which a chunk does once however many rows it has, and the multiply runs on tiles of 16 of an expert's pairs that 256 rows leave about two thirds full. On a 44K-token prompt a chunk of 256 rows takes 152.5 ms of GPU time on average, one of 512 takes 274 and one of 1,024 takes 519: 137 and 130 ms for the same 256 rows.
642bb4f78, where the taps are staged. A cache staged3 + max_rowsrows of every convolution's input, so its staging buffer grew with the widest chunk for every stream, though only a verify window needs it past the forward (the accepted rows choose the new history).Scratchnow has a staging buffer for chunks wider than a window, andforward.zig'sstagedpicks it by the chunk's rows; a cache's own buffer holdsstage_rows, three rows and a window. A chunk that wide is one stream's rows, so one buffer a scratch is enough. No arithmetic changes.9f88b8008, the rows.prompt_rowsand the row limits go to 1,024, with the scratch they size; the sliding ring is the window plus a chunk less one, so 2,048 rows where it was 1,280. A scratch keeps full-vocabulary logits for a round's rows only (batch_rows), not for every prompt row.prefill_steptakes the host'smax_rows, and beside other streams caps a chunk at 256 rows itself, so that their rounds wait no longer than they did; the backend declareschunk_invariantwhere the GPU has tensor units, which is where #4631 made a prompt's rows independent of the chunk.Checks on this head
9f88b8008.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.runtime_test.zig's staged-offset checks now run onstage_rows.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.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: they take the wider chunks too, on the M3 kernels, and do not declarechunk_invariant; I could not measure there. CUDA and HIP are not touched.Receipt
2d7a9c90cagainst this head.inkling2_loopMetal path, prompts and every stream's state.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.lane_bench.py--drafter--drafterbench_concurrent.py --alone --serial(12 of 12 equal their solo runs, plain and with the drafter), the four of the concurrency check and the three turns of a chat with the prompt cache on and off. In a development tree with a switch for the chunk size, one 44K-token prompt gives onetoken_shaat 256, 512 and 1,024 rows a chunk, and a resumed turn equals a fresh one where the kept state falls at 2,048 tokens.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: a prompt's projections and sliding attention on the tensor units (a 45K prompt 906 to 1,634 tok/s) #4631: prompts are faster, decode is unchanged.)