Skip to content

update(inkling2): pick DSpark verify width by measured throughput - #3417

Merged
inureyes merged 3 commits into
mainfrom
update/issue-3410-inkling2-dspark-followups
Nov 24, 2026
Merged

inureyes merged 3 commits into
mainfrom
update/issue-3410-inkling2-dspark-followups

Conversation

@inureyes

Copy link
Copy Markdown
Member

Inkling 2 Small lost 10% on prose with DSpark because an 8-row verify round costs about 130 ms against a 52 ms decode step. #3280 made the Inkling 2 verify block equal decode at every width from 1 to 16, so the round loop can now choose a width per round without changing the text.

Changes

  • Acceptance-aware verify width (mlxcel_core::drafter::dflash::width_policy). Each round takes the width with the most expected tokens per measured millisecond. Expected tokens come from per-position acceptance estimates and cost from per-width round times. Width 1 means classic decode, and drafting is re-tried after 8 classic steps. A width's first round is not used as a cost sample because it includes kernel compilation. The policy applies only to targets that return true from SpeculativeTarget::exact_at_every_verify_width (Inkling 2 today). MLXCEL_DFLASH_ADAPTIVE_WIDTH=0 keeps the fixed width.
  • Classic steps inside the round loop are pipelined like classic decode (classic_steps.rs). Their hidden rows feed the next draft. The CLI DFlash line now reports classic_steps.
  • The grouped expert matvec now also runs in unlooped Small verify forwards. At 8 rows it takes 129 ms instead of 150 ms, with identical argmax digests.
  • Item 2: the server DFlash burst prefills Inkling 2 using the --prefill-chunk-size partition (DFlashTargetModel::prefill_burst calls Inkling2Model::prefill_speculative_planned). The CLI still uses MLXCEL_PREFILL_CHUNK.
  • Item 3: the per-row affine 4-bit attention projections on Mini 4-bit cost at most 4.1 ms (7.7%) per 8-row round, and the block stays exact. I documented this instead of adding a quantized kernel.

Results (M3 Ultra, 256 greedy tokens, --show-reasoning, ABAB)

Small classic before (fixed 8, main) after (adaptive)
prose 19.3 tok/s 0.90x 1.12x
code 19.2 tok/s 1.54x 1.58x
  • Drafter-on text matches classic byte for byte on Small and Mini.
  • On Small with the grouped kernel, the per-visit diagnostic finds 0 differing logits at widths 2, 4 and 8, and also after an 1100-token prompt.
  • Mini shows no regression.
  • Full tables: docs/benchmark_results/inkling2-dspark-followups-m3ultra-2026-11-25.md.

Tests

  • models::inkling2::speculative::tests::round_tests::the_burst_prefill_follows_the_server_chunk_size: a 40-token prompt at chunk 16 produces the same bytes as the classic chunked prefill and differs from the old one-forward prefill.
  • classic_steps_keep_the_text_and_feed_the_drafter_every_row covers classic steps.
  • 10 width-policy unit tests, plus a grouped-gate test.
  • Passing locally: the inkling selector (176), dflash, speculative_burst, coverage_tests, the mlxcel-core drafter::dflash tests, clippy, fmt and the contract scripts.

Closes #3410

Inkling 2 Small lost 10% on prose with DSpark: an 8-row verify round costs about 130 ms against a 52 ms decode step, and prose emits about 2.3 tokens per round. Because the Inkling 2 verify block equals decode at every width from 1 to 16, the round loop may now choose each round's width.

- New `ExpectedThroughputWidth` policy (mlxcel-core `drafter::dflash::width_policy`): per-position acceptance estimates and per-width measured round cost pick the width with the most expected tokens per millisecond, down to classic decode, and re-try drafting after 8 classic steps. The first round at each width is not a cost sample (kernel compilation). Enabled only for targets that declare `exact_at_every_verify_width`; `MLXCEL_DFLASH_ADAPTIVE_WIDTH=0` keeps the fixed width.
- Classic steps run pipelined like classic decode (`classic_steps`), and their hidden rows feed the next draft.
- The grouped expert matvec now serves unlooped Small verify forwards too (8 rows: 129 ms against 150 ms, digests identical).
- The server DFlash burst prefills Inkling 2 in the `--prefill-chunk-size` partition through `DFlashTargetModel::prefill_burst`.
- Mini 4-bit per-row attention projections cost at most 4.1 ms per 8-row round; documented, no new kernel.

Small, 256 greedy tokens, ABAB: prose 1.12x classic (was 0.90x), code 1.58x (was 1.54x), text byte-identical. Per-visit diagnostic on Small with the grouped kernel: 0 differing logits at widths 2, 4, 8 and after 1100 tokens. Numbers in docs/benchmark_results/inkling2-dspark-followups-m3ultra-2026-11-25.md.

Closes #3410
@inureyes inureyes added status:review Under review type:enhancement New features, capabilities, or significant additions labels Nov 24, 2026
@inureyes inureyes added status:done Completed and removed status:review Under review labels Nov 24, 2026
@inureyes
inureyes marked this pull request as ready for review November 24, 2026 23:09
@inureyes
inureyes merged commit 6d275c1 into main Nov 24, 2026
15 checks passed
@inureyes
inureyes deleted the update/issue-3410-inkling2-dspark-followups branch November 24, 2026 23:10
inureyes added a commit that referenced this pull request Nov 25, 2026
## 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 #3405 and #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

- [x] 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
- [x] `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
- [x] Narrow selectors: `models::inkling` (covers `inkling2`), `coverage_tests`, `inkling_mtp`, `speculative_exactness`, `speculative_burst`, mlxcel-core `inkling` and `row_invariant`
- [x] fmt, both clippy gates, and the contract scripts; the broad gate is left to CI

Closes #3280
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:done Completed type:enhancement New features, capabilities, or significant additions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf: Inkling 2 DSpark follow-ups: Small verify cost and server prefill chunk

1 participant