Skip to content

update(inkling): make Inkling-Small MTP exact at every width - #3419

Merged
inureyes merged 2 commits into
mainfrom
update/issue-3280-inkling-small-mtp-exactness
Nov 25, 2026
Merged

inureyes merged 2 commits into
mainfrom
update/issue-3280-inkling-small-mtp-exactness

Conversation

@inureyes

Copy link
Copy Markdown
Member

Summary

  • Inkling-Small MTP verify is now byte-identical to classic decode at every width the gate admits. The probe on inkling-small-mlx-4bit passed at widths 2 to 8 but declined at 10 (the MTP default) from layer 0: past 8 queries MLX's fused SDPA leaves the per-query kernel a decode step runs. A verify block now attends in groups of at most 8 queries. The probe passes at widths 2, 3, 4, 8, 10 and 16, after short, 600- and 2100-token prompts.
  • A partial accept keeps the verify block's own state (KV tail trim, convolution states from the block's recorded input windows) instead of restoring a snapshot and replaying the kept prefix. The replay ran outside the verify scope, so it did not rebuild classic decode's state (the old width-3 prose stream left classic), and it was a second target forward per round. The snapshot/replay path remains for blocks outside the row-invariant scope.
  • The Inkling 2 half of the issue was finished by fix(inkling2): make speculative verify blocks byte-identical to decode #3405 and update(inkling2): pick DSpark verify width by measured throughput #3417; Inkling 2 code is untouched.

Measured (M3 Ultra, 128 greedy tokens, ABAB)

Mode Prose before Prose after Code before Code after
classic 45.1 44.4
width 2 25.9 39.7 27.0 41.6
width 3 23.6 (differs) 34.6 24.4 34.9
width 10 (adaptive) 10.4 (override, differs) 12.7 10.6 (override, differs) 12.7

Mean accepted length is 1.43 to 1.63, nearly all from the first draft. The drafter matches mlx-vlm 466069f5 in chain indexing, hidden-state source and logit path (upstream: 1.59). An experiment starting post-seed drafts at block 1 left acceptance unchanged. No width beats classic, so MTP stays opt-in (--draft-model). The #3417 adaptive width belongs to the DFlash loop and does not apply to the MTP loop. Details: docs/benchmark_results/inkling-small-mtp-m3ultra-2026-11-25.md.

Test plan

  • New mtp_partial_accept_keeps_the_single_token_chain_state_on_metal and widths 10, 16 in the_verify_block_matches_the_chain_on_metal: both fail on the previous code, pass now
  • survey_block_vs_chain on inkling-small-mlx-4bit, widths 2, 3, 4, 8, 10, 16; ignored real-checkpoint probe test (now with width 10) on the bf16 0.6B and the 4-bit Small checkpoints
  • Narrow selectors: models::inkling (covers inkling2), coverage_tests, inkling_mtp, speculative_exactness, speculative_burst, mlxcel-core inkling and row_invariant
  • fmt, both clippy gates, and the contract scripts; the broad gate is left to CI

Closes #3280

On Inkling-Small-mlx-4bit the block-versus-chain probe passed at widths 2 to 8 but declined at 10, the MTP default, from layer 0 on: past 8 queries MLX's fused SDPA leaves the per-query kernel a decode step runs. Inside a verify block the attention now runs in groups of at most 8 queries; the probe passes at widths 2, 3, 4, 8, 10 and 16, also after 600 and 2100 tokens.

A partial accept no longer restores a snapshot and replays the kept prefix. That replay ran outside the verify scope (conv1d and batched experts), so it did not rebuild the state classic decode holds, and it cost a second target forward per round. The verify block now records each short convolution's input window; finalize trims the KV tail and takes the convolution states from those windows. The replay path remains for blocks outside the row-invariant scope. InklingShortConv moves to its own module.

Measured on M3 Ultra (128 greedy tokens, ABAB): width 2 goes from 25.9 to 39.7 tok/s (prose) and 27.0 to 41.6 (code), output now equals classic at widths 2, 3 and 10, but classic decode (45.1, 44.4) is still faster at every width. MTP stays opt-in; docs record the result.

Tests: the tiny-model probe covers widths 10 and 16, and a new test checks that a partial accept leaves the single-token chain state; both fail on the previous code.

Refs #3280
@inureyes inureyes added status:review Under review type:performance Performance improvements priority:low Low priority area:models Model architectures, weights, loading, metadata area:inference Generation, sampling, decoding (incl. speculative, DRY) platform:macos macOS (Apple Silicon) specific labels Nov 25, 2026
@inureyes inureyes added status:done Completed and removed status:review Under review labels Nov 25, 2026
@inureyes
inureyes marked this pull request as ready for review November 25, 2026 00:57
@inureyes
inureyes merged commit d5b565a into main Nov 25, 2026
33 checks passed
@inureyes
inureyes deleted the update/issue-3280-inkling-small-mtp-exactness branch November 25, 2026 00:58
inureyes added a commit that referenced this pull request Nov 25, 2026
…3423)

## Summary

First-generation Inkling now takes prompt-lookup verify rounds (`mlxcel generate --prompt-lookup`, the server's `--draft-kind prompt-lookup`, and the full-model drafter), reusing the exact rewind PR #3419 built for MTP.

- A token-only speculative append of 2 to 16 rows enters the MTP verify scope in `forward_with_sequence_id`, so it is row-invariant and records each convolution's input window in `block_tails`.
- `supports_speculative_verify_rewind` returns the row-kernel setting (`MLXCEL_INKLING_ROW_INVARIANT`, on by default). With it off the gate still refuses.
- `rewind_decode_appends` goes through the new `inkling_layer::drop_newest_verify_rows`. It derives the block length from the windows (window rows minus state rows), accepts `kept == 0` (a failed round, or the width warm-up), and checks every layer before it changes any. A layer with no windows, layers that disagree, or `n` past the block are all refused.
- A speculative append wider than 16 rows also records its windows, so `--prompt-lookup-max-draft` above 15 still rewinds. Those rows are not byte-identical to the chain.
- `supports_padded_prefill` stays `false`, and `trim_state` behavior is unchanged. Its comment and line 66 of the #3419 reports (en, ko) now say it serves padded prefill only.
- The Inkling VL wrapper delegates both hooks. The survey's engine probe now runs on this family; Inkling 2 is still excluded, so its verdicts do not change.
- Docs: the Inkling row in `docs/supported-models.md`, a paragraph in `docs/speculative-acceptance.md`, and the `MLXCEL_INKLING_ROW_INVARIANT` entry.

## Results (M3 Ultra)

- `survey_block_vs_chain`, engine path: equal in every cell. That is widths 2/4/8 × prompts 8/600/2100 on `inkling-0.6b-a0.6b`, and widths 2/4/8/16 on `inkling-small-mlx-4bit`. Before this change the engine path reported `NotRun`.
- `--prompt-lookup` text at temperature 0 equals classic decode on every run on both checkpoints (copy, prose and repeat prompts).
- ABAB, 4 cycles, on copy-heavy replies. Inkling-Small: 42.12 tok/s classic against 48.00 with prompt lookup (1.14x, 2.26 tokens per forward). 0.6B: 235.52 against 500.41 (2.12x). On replies that give it nothing to draft, prompt lookup runs at 0.81x (0.6B) and 0.87x (Small, one run). Full tables are in `docs/benchmark_results/inkling-prompt-lookup-m3ultra-2026-11-25.md`.

## Test plan

- [x] `models::inkling` and `inkling` lib tests under the GPU lock (182 passed; `models::inkling` rerun after the gate test was shortened, 86 passed). These include the new gate test in `tiny_tests.rs`, and `prompt_lookup_tests.rs`: byte equality against the single-token chain after a rewind at every reject position for widths 4 and 10 (full reject included), refusal without mutation, and a width-20 tolerance check.
- [x] `--lib coverage_tests` and `prompt_lookup` filters.
- [x] fmt, both clippy invocations, the used-by, kernel-dtype, env-var, crate-version, kernel-port, binary-asset and license checks.
- [ ] The broad `cargo test --release --lib inkling` gate is left to the orchestrator. The server path shares `Engine::verify_rounds_unsupported` and `verify_round` with the CLI but was not exercised end to end.

Closes #3422
@inureyes inureyes added this to the 0.9 milestone Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:inference Generation, sampling, decoding (incl. speculative, DRY) area:models Model architectures, weights, loading, metadata platform:macos macOS (Apple Silicon) specific priority:low Low priority status:done Completed type:performance Performance improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(inkling): MTP is declined by the exactness gate and gives no speedup on Inkling-Small

1 participant