Repository navigation
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
Draft
sethforprivacy wants to merge 37 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
This was referenced Nov 22, 2026
This was referenced Nov 22, 2026
5 of 6 tasks
8 tasks done
4 of 5 tasks
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
|
BlivionIaG
added a commit
to BlivionIaG/TensorFold
that referenced
this pull request
Nov 24, 2026
- A prompt pass reads every expert's and projection's weights once, so 256 rows a pass read them a quarter as often as 64 and fill the expert tiles. - Every row's sums are the same at every chunk width (the routed experts, projections and gates are bit-equal to the one-row kernels); the sliding ring grows to 1,280 keys. - The loop-gates contract probe also runs 200 rows. - Same change as the chunk width of ashhart#4608 (a9fae61), which has no effect on a chip without tensor units until a grouped simdgroup-matrix path like ashhart#4756's is under it. - Cold 2,048 tokens on an M4 Pro, A-B-B-A: 22.76 and 22.69 s before, 15.53 and 15.52 s after; greedy chat hashes, cold 2,048 (de3c13467508) and 8,192 (dc7ec8d3a016) tokens equal to main's.
5 of 8 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
Two things about Mini's prompt pass on Metal, a commit each:
prefill_step), the lane host runs the other streams' rounds between chunks, and--decode-sharesets the split.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 and 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 (55de80afd). This pull request's own commits area9fae61aeand530fca3f5.atc overlap --json: not run; ATC is not installed on the machine that pushes.a9fae61ae, chunks of up to 256 rows. With #4523 a tensor-unit tile of an expert takes 16 of the expert's route pairs, and a tile costs the same with one live pair as with sixteen. A 64-row chunk gives an expert 4 pairs on average (64 rows, 8 of 128 experts each), so most of a tile is idle; 256 rows give it 16.prompt_rowsand the row limits of the glue, loop and runtime plans go from 64 to 256, with the scratch they size (the router's dots, the gates' intermediates, the experts' pair lists). The sliding ring is the window plus a chunk less one, rounded to 64, so it goes from 1,088 to 1,280 rows and the geometry guard with it: a stream's state grows by 30 MiB.530fca3f5, a chunk a call.feed's loop body becomesfeedChunk;prefillFnopens the stream and loops it,prefillStepFnopens the stream on its first call and runs one chunk a call, at the cuts the whole pass makes (the stream's planned chunks and kept marks). The backend reportsfill_at. With the drafter, the wrapper asks for a chunk's feature rows after each step, so a stepped chunk's rows stay addressable until the next forward (fill_tap); the prompt's last row is kept as before.max_rowsis not used, as the family declares nochunk_invariant(the host's cap is 512 rows, over this family's chunk in any case).Why the reply is the same. A row's sums do not depend on the rows beside it in a chunk, which #4523 keeps by running one kernel at every width. Measured on this head with a debug switch for the chunk size that is not in the diff: each of three prompts (384, 8,424 and 54,024 tokens) gives one
token_shaat 64 and at 256 rows a chunk.Checks on this head
530fca3f5.serving_test.zig, new: "Mini Metal fills a prompt a chunk a call to the whole pass's first row and features". A 64-token prompt planned in three chunks, filled whole on one stream and a step at a time on another: the steps end where the cuts are,fill_atfollows them, each chunk's feature rows are held after its step and an earlier chunk's are not, and the last feature row, the first token and its logprob row equal the whole pass's. It needs the checkpoint (TF_INKLING2_METAL_DIR) and skips without it. With the checkpoint it passes on this stack with Metal loader: a checkpoint span of 16 GiB or more loads (each pread capped at 1 GiB) #4435's read cap applied; the file's two older tests fail there with and without this change, for the reason given in 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.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 45 kernels: 45 pass gates 1-4, 0 fail, 0 known findings; 45 controls: 45 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, where the wider chunk runs the M3 kernels. CUDA and HIP are not touched.Receipt
55de80afdagainst this head.inkling2_loopMetal path, prompts.--decode-sharenow acts on this family's prompts, as it does on the families that already fill a chunk a call.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 and 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 at their current heads and Metal loader: a checkpoint span of 16 GiB or more loads (each pread capped at 1 GiB) #4435's read cap applied.Prompt speed, one stream, the prompt's wall time to its first token:
oMLX 0.8.1 does 2,628 to 2,895 tok/s on the last prompt on this machine, so the prompt path is still short by a factor of three.
A reply decoding (plain, one stream) while a second stream sends a 6,905-token prompt:
a9fae61ae, whole pass, 256-row chunks--decode-share 0.25--decode-share 0.5The first two rows' few tokens are the ones that arrive as the prompt starts and ends; the 64-row figures are measured on this head with the debug switch for the chunk size.
Alone, that reply runs at 60 tok/s.
token_shafilled whole and a chunk a call. With the drafter, three prompts of 280, 1,054 and 3,462 tokens give the plain reply'stoken_sha(74 of 174, 71 of 173 and 77 of 167 drafts accepted), so the drafter takes the stepped chunks' rows as it took the whole pass's.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 (175 and 134 drafts accepted).Checklist
prefill_step, which the backend does not have before; it skips without the checkpoint.)"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (Drafted equals plain and concurrent equals solo on this head. A resumed prompt equals a fresh one 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, and did not before it on any head of this stack; this pull request does not change that either way.)--drafter, no slower than without it. (Against 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: prompts are faster and decode is unchanged. A prompt beside a decoding reply takes 6 % longer by default, which is the reply's rounds.)