Skip to content

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
ashhart:mainfrom
sethforprivacy:inkling2-mini-metal-chunks
Draft

sethforprivacy wants to merge 37 commits into
ashhart:mainfrom
sethforprivacy:inkling2-mini-metal-chunks

Conversation

@sethforprivacy

@sethforprivacy sethforprivacy commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Two things about Mini's prompt pass on Metal, a commit each:

  1. Before: a prompt fills in chunks of up to 64 rows. After: up to 256. A 45K-token prompt goes from 702 to 905 tok/s, with the same reply.
  2. Before: a prompt fills in one call, so every other stream's reply waits for all of it: a reply decoding beside a 6,905-token prompt got no token for 6.9 s of the prompt's 7.1. After: the backend fills a chunk a call (prefill_step), the lane host runs the other streams' rounds between chunks, and --decode-share sets the split.

This is a proposal on top of #4387, opened as a draft.

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_rows and 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 becomes feedChunk; prefillFn opens the stream and loops it, prefillStepFn opens 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 reports fill_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_rows is not used, as the family declares no chunk_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_sha at 64 and at 256 rows a chunk.

Checks on this head

  • Head commit: 530fca3f5.
  • Lean checker, on the base and on this head: 167 and 167, 0 new.
  • Tests run:
    • 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_at follows 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.
    • The six Inkling host steps (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 zig and git diff --check: clean.
  • CI: not yet reported when this was written.
  • Not run, and why: the whole zig build test test-golden on 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

Prompt speed, one stream, the prompt's wall time to its first token:

Prompt 64 rows a chunk 256 rows a chunk
384 tokens 0.4 s 0.3 s
8,424 tokens 11.1 s (759 tok/s) 8.4 s (1,003)
54,024 tokens 79.6 s (679) 60.2 s (897)
45,246 tokens, the lane benchmark's 702 tok/s 905

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:

The reply's rate during the prompt Its longest gap The prompt's wall time
#4523's chunk (64 rows), whole pass 0.7 tok/s 9.7 s 9.8 s
a9fae61ae, whole pass, 256-row chunks 1.0 tok/s 6.9 s 7.1 s
This head 4.1 tok/s 0.55 s 7.5 s
This head, --decode-share 0.25 14.9 tok/s 0.30 s 9.7 s
This head, --decode-share 0.5 26.6 tok/s 0.30 s 13.8 s

The 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.

  • Exactness: the 8,424 and 384-token prompts give the same token_sha filled whole and a chunk a call. With the drafter, three prompts of 280, 1,054 and 3,462 tokens give the plain reply's token_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).
  • Decode on this head, TensorFold's clients, 256 tokens, greedy, three reps: plain 59.5 and 59.9 tok/s on the two prompts and 182.4 and 181.2 in total at four streams; with the drafter 106.1 and 79.4, and 236.9 and 188.2 at four streams (the build also has 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). On 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 head the same four were 59.5 and 59.9, 182.8 and 181.6, 100.4 and 79.3, 237.8 and 189.1; the drafted code prompt runs at 100 to 106 from one server start to the next on both heads, so decode is unchanged. oMLX 0.8.1 on the chat prompt, same client: 72.5 with its drafter and 54.9 without, 126.6 at four streams.
  • Peak footprint: 21 GB plain and 22 GB with the drafter; they were 20 and 21 with 64-row chunks.
  • Licence of any new weights or drafter, or "n/a": n/a.

Checklist

  • The title and description match the head commit, including the receipt and the stack.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency. (The new test calls prefill_step, which the backend does not have before; it skips without the checkpoint.)
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.
  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
  • Drafted output equals "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.)
  • No precision traded for speed. If the bits change, the description says which sums change and why. (No sums change: each prompt gives the same reply at 64 and 256 rows a chunk.)
  • Decode and prompt processing are no slower than main at one stream and the widest admitted; with --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.)

ashhart and others added 30 commits November 21, 2026 16:05
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.
@ashhart
ashhart force-pushed the lead/inkling2-mini branch 4 times, most recently from aefb063 to c41911e Compare November 24, 2026 09:43
@ashhart
ashhart deleted the branch ashhart:lead/inkling2-mini November 24, 2026 09:43
@ashhart ashhart closed this Nov 24, 2026
@ashhart ashhart reopened this Nov 24, 2026
@ashhart
ashhart changed the base branch from lead/inkling2-mini to main November 24, 2026 09:49
@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
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 main. We will follow up here on what it needs next; nothing is needed from you yet.

  • Synthena

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants