Skip to content

fix: keep pipelined classic steps overlapped in MTP and DFlash rounds - #3432

Draft
inureyes wants to merge 2 commits into
mainfrom
fix/issue-3430-pipelined-token-read
Draft

inureyes wants to merge 2 commits into
mainfrom
fix/issue-3430-pipelined-token-read

Conversation

@inureyes

Copy link
Copy Markdown
Member

Closes #3430

Cause

The pipelined classic steps of the MTP fallback (#3425) and of the DFlash round loop (#3417) read each token through dflash::materialize_argmax_i32_vec, which called array_to_raw_bytes. That builds and evaluates contiguous(token), so the op and the event the read waits on sit behind step i + 1, which is already queued on the same stream. Every read waited for the whole next forward, and the steps ran as synchronous decode: 41.6 tok/s on Inkling-Small, the same as the engine forced synchronous, against 46.3 for engine classic decode.

Change

  • materialize_argmax_i32_vec reads through array_evaluated_bytes, the engine's perf(server): port lookahead async_eval pipelining into BatchScheduler decode #632 read: it waits on the array's own event and enqueues nothing, and a non-contiguous array still takes the copy. Every caller benefits; for an unscheduled argmax the read is the same eval minus a copy.
  • The DFlash classic steps pass their token directly instead of a fresh reshape, which queued an op the same way.
  • A Metal test queues about 76 ms of matmuls behind a token and requires the read to leave them running. With the old read it fails 3 of 3 (read 76 ms, rest under 1 us); with the fix it passes 3 of 3.

Measurements (M3 Ultra, ABAB in one locked block, greedy, --show-reasoning)

Pure classic inside the MTP session (drafting disabled by a scratch switch) goes from 40.4 to 41.8 tok/s to 44.5 to 45.4 at 128 and 256 tokens on the prose and code prompts, against 45.3 to 46.5 for engine classic decode. Output is byte-identical to classic decode in every arm. MTP at 128 tokens, before and after:

Prompt Classic Width 10 (default) Width 2
prose 46.1 37.0, 37.7 -> 40.3, 40.4 41.0 -> 44.0, 44.1
code 45.8 37.1, 37.3 -> 39.7, 39.8 41.0, 41.2 -> 43.8, 43.9

Inkling 2 Mini DSpark with MLXCEL_DFLASH_ADAPTIVE_WIDTH=1 (one build, the old read behind a scratch switch) goes from 51.7 to 52.8 (prose; the first old run, 38.9, was excluded as warm-up) and from 49.8, 50.0 to 51.8 (code), identical output.

Validation: the contract checks in the brief, clippy on the workspace lib and mlxcel-core, coverage_tests, and the new test pass. Docs: docs/benchmark_results/inkling-small-mtp-m3ultra-2026-11-25.md and docs/supported-models.md.

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
@inureyes inureyes added status:in-progress Currently being worked on type:performance Performance improvements priority:medium Medium 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:in-progress Currently being worked on labels Nov 25, 2026

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf: keep pipelined classic steps overlapped in MTP and DFlash rounds

1 participant