Repository navigation
update(inkling2): pick DSpark verify width by measured throughput - #3417
Merged
Merged
Conversation
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
…ling2-dspark-followups
inureyes
marked this pull request as ready for review
November 24, 2026 23:09
This was referenced Nov 24, 2026
Closed
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
This was referenced Nov 25, 2026
inureyes
added a commit
that referenced
this pull request
Nov 25, 2026
…#3432) * fix: keep pipelined classic steps overlapped in MTP and DFlash rounds The pipelined classic steps of the MTP fallback (#3425) and the DFlash round loop (#3417) read each token through materialize_argmax_i32_vec, which called array_to_raw_bytes. Its contiguous() copy and the event the read waits on were queued behind the next step, already scheduled on the same stream, so every read waited for the whole next forward and the steps ran as synchronous decode (41.6 tok/s on Inkling-Small against 46.3 for engine classic decode). The helper now reads through array_evaluated_bytes, which waits on the array's own event and enqueues nothing (a non-contiguous array still takes the copy), and the DFlash classic steps pass the token instead of a fresh reshape. A Metal test requires a token read to leave work queued after it running; it fails with the old read and passes now. On an M3 Ultra, pure classic inside the MTP session reaches 0.97x to 0.99x engine classic decode, the default MTP width goes from 0.81x to 0.87x classic and width 2 from 0.89x to 0.95x, with output identical to classic decode. Closes #3430 * docs: add technical report for PR #3432
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.
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
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 fromSpeculativeTarget::exact_at_every_verify_width(Inkling 2 today).MLXCEL_DFLASH_ADAPTIVE_WIDTH=0keeps the fixed width.classic_steps.rs). Their hidden rows feed the next draft. The CLI DFlash line now reportsclassic_steps.--prefill-chunk-sizepartition (DFlashTargetModel::prefill_burstcallsInkling2Model::prefill_speculative_planned). The CLI still usesMLXCEL_PREFILL_CHUNK.Results (M3 Ultra, 256 greedy tokens,
--show-reasoning, ABAB)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_rowcovers classic steps.inklingselector (176),dflash,speculative_burst,coverage_tests, the mlxcel-coredrafter::dflashtests, clippy, fmt and the contract scripts.Closes #3410