Repository navigation
Conversation
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
This branch has not been deployed
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.
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 calledarray_to_raw_bytes. That builds and evaluatescontiguous(token), so the op and the event the read waits on sit behind stepi + 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_vecreads througharray_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.reshape, which queued an op the same way.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:
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.mdanddocs/supported-models.md.