Repository navigation
Inkling 2 Mini on Metal: a window's grammar masks step by the padded vocabulary, so a structured reply passes its second row - #4635
Closed
sethforprivacy wants to merge 22 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
…y's words, so structured replies pass their second row
This was referenced Nov 22, 2026
8 tasks done
gilby
added a commit
to gilby/TensorFold
that referenced
this pull request
Nov 22, 2026
… mask stride and firstLogprobRow Fuse Stage-1 argmax into tf_inkling2_logits and add Stage-2 tf_inkling2_reduce_argmax with exact host tie-breaking and NaN-at-0 preservation. Enable gpu_tokens with async GPU-resident decode queueFn and skip unread f32 logits DRAM stores on pure-greedy unmasked no-logprobs batches while keeping mixed batches exact. Fix ashhart#4635 multi-row grammar mask stride from xgrammar padded vocab words, fix firstLogprobRow when called before first(), and add host tests and Metal kernel contracts.
This was referenced Nov 22, 2026
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
|
Owner
|
Thank you, @sethforprivacy. Every commit this PR adds is now on main inside #4387 with your authorship kept, so it ships with Inkling 2 Mini on Metal in the next release. Closing this one as landed there.
|
5 of 8 tasks
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
Before: on Metal, a Mini request with a token grammar (
response_formatwith a JSON schema, a required tool call) ends after two or three tokens withthe reply's grammar rejected a chosen token, HTTP 500. After: the reply follows its grammar.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 (97c91058f). This pull request's own commit isd536e5d05. It touchesbackend.zig's verify path only and does not depend on the other drafts.atc overlap --json: not run; ATC is not installed on the machine that pushes.The cause. The server sizes a grammar's masks by the checkpoint's
vocab_size, 201,024, so a window's masks are 6,282 words a row (grammar.vocabSize,Compiler.open).verifyFnstepped through them by the unembedding's real rows, 200,058, which is 6,252 words. Row 0's mask starts at word 0 either way, so the first token is right; every later row of a window reads its mask 30 words a row early, picks a token the grammar does not allow, and the stream ends in the error above.The fix.
maskWordsis the padded vocabulary's words,maskRowtakes rowrat that stride, and a window whose masks are neither empty norrows * wordslong is refused (InvalidInklingMasks) where it was read short.Checks on this head
d536e5d05.backend.zig, new: "a window's masks step by the padded vocabulary's words" (6,282 words; row 2 of three reads the bit set at its own first word and row 1 does not).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 41 kernels: 41 pass gates 1-4, 0 fail, 0 known findings; 41 controls: 41 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). CUDA and HIP are not touched; I did not look at how their Mini backends stride masks.Receipt
verifyFnagainst this head's.inkling2_loopMetal path, requests with a grammar.thinkingmachines/Inkling-2-Mini@ed40e7da625f594fc9c4990f5f66be24873c22d7,libtfgrammarbuilt byzig build grammarfrom xgrammar v0.2.8,--drafter. The served rows are from the whole stack with this commit applied and Metal loader: a checkpoint span of 16 GiB or more loads (each pread capped at 1 GiB) #4435's read cap.Served, one request each, greedy:
response_formatjson_schema(two required strings), "Name the capital of France and its country as JSON."{"city":"Paris","country":"France"}tool_choicerequired, one tool<tool_call>text, see below<tool_call>text, which is not how Mini writes one (a typed block, as server: split Inkling 2 replies into reasoning, text and tool calls #4124 reads them), so the call comes back as content. That is the tool grammar's style for this family and not this change; I mention it so the second row is not read as a working required call.Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (Not touched for requests without a grammar.)--drafter, no slower than without it. (Not touched.)