Repository navigation
feat(perf): speed up Raon-1 mini decode, load and prompt reuse - #3461
Merged
Merged
Conversation
Raon-1 mini served correctly but slowly in three places (#3458): the server never reused a prompt prefix, a decode step took 30 ms, and the ModelOpt NVFP4 export took over a minute to load. - Prompt cache: the model donates and restores exact-prefix snapshots (RDA conv window, float32 state and offset; MLA latent pair). A state that does not hold exactly the keyed tokens donates nothing, so a DFlash2 burst, which runs on its own caches, stores no snapshot. The burst's prefill now follows the classic partition, which splits at snapshot boundaries, so drafted text still equals plain text. - Decode: profiling put a third of the step in one product per mHC site. A one-row selector product ran MLX's transposed gemv kernel (about 255 us against 35 us row-major, at 50 sites per token), so one-row products (decode steps and verify rows) take the row-major form; multi-row products are unchanged. The small ops of a single-position site run as two compiled graphs, bit-identical to the eager ops. `MLXCEL_RAON_DECODE_FUSION` selects either or neither. - ModelOpt NVFP4 load: a canonical triplet is reinterpreted on the device (E4M3 scale bytes passed through, packed weight viewed as uint32) instead of copied to host and re-encoded. Shared by every ModelOpt NVFP4 family that reads through MLX's safetensors loader. Measured and not kept: fusing the seven RDA input projections (under 1 percent, not bit-identical at the real width), one host read per sampled verify block (slower, because the rows past the first mismatch are sampled for nothing), and a batched DFlash2 burst (an exact verify block costs more per row than a batched decode step). Numbers are in the benchmark document added next. Refs #3458
Brings in the Raon-1 mini correctness follow-ups (#3459) and the Jamba XLA support (#3448). Both branches appended tests to `raon1_mini_tests.rs`; main's file is kept as is and this branch's snapshot test moves to `raon1_mini_snapshot_tests.rs`, next to the module it covers, which also keeps the file under the size limit.
Adds `docs/benchmark_results/raon-perf-m3ultra-2026-11-26.md` with the measurements behind #3458: decode by fast path, the selector product microbenchmark and its accuracy, prefill and decode traces against Transformers, TTFT with the prompt cache, DFlash2 on all three checkpoints, the ModelOpt load profile, and the three options that were measured and not kept. The DFlash2 default verify width moves from 5 to 3. With an 18 ms decode step a verify block costs about 2.4 decode steps at width 5 and 1.9 at width 3, so width 5 fell to 0.97x plain decode on low-acceptance prose while width 3 stays at or above it on the original checkpoint and averages 1.18x against 1.11x over the nine prompt and checkpoint pairs measured. An explicit `--draft-block-size` is unaffected. Refs #3458
Member
Author
Implementation Review SummaryIntent
Findings AddressedNo CRITICAL or HIGH findings, so no fixes were pushed. Remaining Items
Verification
|
Member
Author
Security and performance reviewScope: snapshot isolation and memory, the new mHC bridge functions, the NVFP4 device transcode, and regressions outside the targeted paths. The implementation review already covered correctness. No CRITICAL or HIGH findings, so nothing was pushed. Checked and fine
MEDIUM
LOW
Focused tests rerun locally under the GPU lock: |
…e checks The device NVFP4 transcode test also passed when the route was silently off, so a regression to the 63 to 70 s host path went unnoticed. nvfp4_device_transcode is now visible to the tests, which assert Some for a canonical uint8 scale triplet and None for f16 scales. DecodeFusion::parse now logs one warning naming an unrecognized MLXCEL_RAON_DECODE_FUSION value before falling back to all fast paths; the fallback is stated in docs/environment-variables.md and the parse test covers malformed values. The Raon-1 mini RDA restore checks the conv and recurrent state ranks, batch agreement and offset, and a snapshot that lacks an RDA or MLA layer is refused, so the scheduler prefills cold. The benchmark doc states the presence_penalty setting of each measurement and its effect on batched DFlash2 windows, and the doc, supported-models page and CHANGELOG disclose the cold-prefill split at the history boundary. Validation: cargo test --lib for the touched tests and the raon filters (52 passed), cargo fmt --check, cargo clippy --lib --tests -D warnings, scripts/ci/check_env_var_docs.py. Refs #3458
This was referenced Nov 27, 2026
inureyes
marked this pull request as ready for review
November 27, 2026 01:28
This was referenced Nov 27, 2026
This was referenced Nov 27, 2026
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.
Summary
Six Raon-1 mini performance follow-ups, measured on an M3 Ultra against
mainat477564e2e(docs/benchmark_results/raon-perf-m3ultra-2026-11-26.md). Three are kept, one is a validation, two were measured and not kept.supports_batchedstaysfalseand no B > 1 code was added. Since fix(models): close Raon-1 mini correctness and validation gaps #3459 the served defaultpresence_penaltyof 1.5 also keeps default-setting requests out of batched speculative windows.Behavior changes to review
MLXCEL_RAON_DECODE_FUSION=mhckeeps the earlier bytes at 34.5 tok/s; an unrecognized value logs a warning and keeps all fast paths.mlxcel generateat a near tie. A cache miss costs 1.14 s against 1.00 s.Correctness
0xFF(a NaN) is no longer rewritten to0x7F.Test plan
make verifylocally after mergingmainatd43915faf; the issue'stest-fastfilters, fmt and clippy again after mergingmainatdb3a23141.Closes #3458