Skip to content

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

Conversation

@sethforprivacy

Copy link
Copy Markdown
Contributor

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.

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_static and tf_inkling2_conv_dynamic now take the old rows and the launch's rows as two buffers (ink_tap picks 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_partial and tf_ink2_mlp_partial now 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_partial also 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

  • Head commit: f6876bf0c.
  • 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, 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 zig and git diff --check: clean.
  • CI: not yet reported when this was written.
  • What the contract checks now: the two partial entries bind taps (three old rows, then the launch's) and a convolution weight, and compare every output exactly against the convolution taken in the kernel's FP32 order, rounded to BF16, then the add. mlp_partial moves 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) and attention_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).
  • 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: nothing here depends on the tensor units, so the change reaches them, and I cannot run them. CUDA and HIP are not touched.

Receipt

One plain stream, 200 tokens, --parallel 4 --context 65536, two server starts each (the same reply every time):

tok/s
#4666 71.0, 71.1
Convolutions beside their staging (change 1 alone) 71.2, 71.1
The running sums take their convolution (change 2 alone) 72.6, 72.5
Both (this head) 73.3, 73.3

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) and lane_bench.py:

Before This head
One stream, plain, code and chat 61.0 and 61.6 tok/s 62.7 and 63.3
Four streams, plain 217.1 and 218.4 223.6 and 225.4
One stream, --drafter 125.3 and 96.8 127.3 and 93.1
Four streams, --drafter 279.6 and 228.6 283.1 and 231.2
A 45,246-token prompt 2,376 tok/s (19.0 s to the first token) 2,417 (18.7 s)
A 6,905-token prompt beside a decoding stream 3.89 s 3.83 s

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

  • Exactness: every reply above has the hash it had before. 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.
  • What I tried and left out: the router as one launch (a row's 128 dots in one threadgroup, a simdgroup taking 16 experts in turn, then the pick). It gives the same bits and is 12 % slower at one row (71.0 to 62.4 tok/s): the router's weights are cold each visit, and 128 dots side by side wait once where 16 in turn wait 16 times. A step is worth removing only where the work it holds stays as wide as it was.
  • Licence of any new weights or drafter, or "n/a": n/a.

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.
…ps in the scratch, so a stream's cache stages a window only
…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
@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