Skip to content

Inkling 2 Mini on Metal: wide prompt chunks take the routed experts on turned tiles, 16 weight rows by 32 of an expert's pairs an op - #4649

Draft
sethforprivacy wants to merge 45 commits into
ashhart:mainfrom
sethforprivacy:inkling2-mini-metal-turned
Draft

sethforprivacy wants to merge 45 commits into
ashhart:mainfrom
sethforprivacy:inkling2-mini-metal-turned

Conversation

@sethforprivacy

Copy link
Copy Markdown
Contributor

What this changes

Before: a tensor-unit tile of the routed experts is 32 weight rows by 16 of an expert's pairs, at every chunk width. After: a chunk of more than 512 rows takes the same products on tiles turned the other way, 16 weight rows by 32 of the expert's pairs an op. A 1,024-row chunk gives an expert 64 pairs on average, so a 32-pair band is full, and a block of weights is decoded once for 32 pairs where it was decoded once for 16.

A 1,024-row prompt chunk at 16K tokens of context goes from 428 to 403 ms of GPU time, and a 45K-token prompt from 2,078 to 2,212 tok/s served. Same bits.

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

The kernels. ink2_units_t<FP8, GU> is ink2_units with the tile turned: a threadgroup is 16 weight rows of one expert, and each simdgroup's op takes 32 of the expert's pairs, where ink2_units takes 32 weight rows by 16 pairs. The four entries are tf_ink2_{nvfp4,mxfp8}_{gu,down}_units_t. The decode of a weight block, the scale, the gate and the epilogue are the same code.

Why the bits are the same. An output is one (pair, weight row) dot product. Both tiles accumulate it over the same 16-column steps in the same order with the same operands; the tile's orientation decides which outputs share an op, not an output's terms. So the width may choose between them, as #4523's rule allows only for kernels with one result: a row's sums still do not depend on the chunk it came in. Every served reply has the hash it had on #4645, among them the prompts that fill in 1,024-row chunks.

Who takes which. experts.units picks by the call's rows: over 512, the turned tiles. Rounds, and prompt chunks beside other streams (256 rows at most since #4644), stay on #4523's tiles. experts.unitsTurned asks for the turned tiles at any width, which is how the contract reaches them with small shapes.

Checks on this head

  • Head commit: 84ab2c63f.
  • 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.
    • 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. Four of the kernels and four of the controls are new: each turned entry against float64 on seven shapes, one of them 40 rows of one expert so that the pairs cross a 32-pair band, and its control (the NVFP4 factor doubled, the MXFP8 scale's exponent off by one) red at the first shape.
    • 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, which have no tensor units and never load these kernels. CUDA and HIP are not touched.

Receipt

GPU time of a 1,024-row prompt chunk at 16K tokens of context, and of a 45K-token prompt in all (a development tree that is this stack with timing switches):

#4645 This head
The chunk 428 ms 403
The 45K-token prompt, tokens a second of GPU time 2,186 2,314

Served:

#4645 This head
A 45,246-token prompt, lane_bench.py 2,078 tok/s (21.8 s to the first token) 2,212 (20.5 s)
A 6,905-token prompt beside a decoding stream 4.1 s 4.1 s
One stream, plain, code and chat (short prompts) 60.6 and 61.2 tok/s 60.5 and 61.1
One stream, --drafter 124.8 and 93.1 123.5 and 92.0
Four streams, plain 215.9 and 217.5 215.8 and 217.8
Four streams, --drafter 277.4 and 226.0 276.8 and 226.0

The decode rows do not reach the change (a round is at most a few dozen rows); they are there to show the build is otherwise the same. The drafted chat prompt's three repetitions were 96.1, 90.8 and 92.0.

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 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:48
@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