Skip to content

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

sethforprivacy wants to merge 43 commits into
ashhart:mainfrom
sethforprivacy:inkling2-mini-metal-wide

Conversation

@sethforprivacy

Copy link
Copy Markdown
Contributor

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:

  1. 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).
  2. 9f88b8008: chunks of up to 1,024 rows. A stream filling beside other streams keeps to 256, and the host's --decode-share cap 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.

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 staged 3 + max_rows rows 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). Scratch now has a staging buffer for chunks wider than a window, and forward.zig's staged picks it by the chunk's rows; a cache's own buffer holds stage_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_rows and 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_step takes the host's max_rows, and beside other streams caps a chunk at 256 rows itself, so that their rounds wait no longer than they did; the backend declares chunk_invariant where the GPU has tensor units, which is where #4631 made a prompt's rows independent of the chunk.

Checks on this head

  • Head commit: 9f88b8008.
  • Lean checker, on the base and on this head: 167 and 167, 0 new.
  • Tests run:
    • 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. runtime_test.zig's staged-offset checks now run on stage_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 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: they take the wider chunks too, on the M3 kernels, and do not declare chunk_invariant; I could not measure there. CUDA and HIP are not touched.

Receipt

#4631 This head
A 45,246-token prompt, lane_bench.py 1,634 tok/s (27.7 s to the first token) 1,892 (23.9 s)
A 44,424-token prompt, alone 26.7 s 22.6 s
A 6,905-token prompt beside a decoding stream 4.2 s 4.2 s
That stream's median and longest gap while the prompt fills 149 and 297 ms 150 and 297 ms
One stream, plain, code and chat 60.5 and 61.1 tok/s 60.3 and 60.9
One stream, --drafter 121.9 and 91.1 124.2 and 93.4
Four streams, --drafter 275.8 and 224.8 276.9 and 225.8

Checklist

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 3 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

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