Repository navigation
fix(models): close Raon-1 mini correctness and validation gaps - #3459
Merged
Merged
Conversation
The four Raon-1 mini PRs under epic #3439 left nine correctness and validation gaps on the model, loader and server-request surface. This closes them in one change. - Server: generation_config.json presence_penalty becomes the default when --presence-penalty is absent (mlxcel generate keeps 0.0); recorded by_design in the llama-server manifest. - Load: every Raon RDA, MLA, MLP, expert and lm_head projection is checked on its input axis through new UnifiedLinear / SwitchLinear check_input_width helpers, so a wrong width is a named error instead of an abort in the first matmul. - Load: check_scales_leading_axes refuses scales with a short row or expert axis in UnifiedLinear and SwitchLinear for every quantized family; Raon's check delegates to it. - KV estimate: Raon's 48.8 MB per-sequence RDA state is added to total_bytes. - compute_g_lower_bounded upcasts the bf16 input before adding dt_bias (bit-identical on Metal). - Startup refuses pipeline-parallel, disaggregated and XLA serving for a reasoning-effort steering model; the invalid-level 400 echoes at most 32 characters. - The oracle pins its checkpoint-code digests to revision 6691a076. - rms_norm_round_once documents fast_rms_norm's double rounding; measured on Raon, it removes one decided disagreement but slows decode 3.1%, so Raon keeps fast_rms_norm. New tests fail on main where the issue says so. Targeted suites, real-checkpoint loads of all three Raon exports and make verify pass locally. Closes #3457
The doc comment for `steering_vector` had been separated from it by the new `check_input_widths` in the Raon-1 mini MoE layer; restore it and give `check_input_widths` its own comment. The server default presence_penalty of 1.5 from Raon's generation_config.json keeps default requests out of batched DFlash2 windows. Note in llama-server-compat.md and supported-models.md that `--presence-penalty 0` or a per-request value restores batching. The repo has no Korean copies of these docs. Validation: cargo fmt --check, cargo clippy --lib --tests -D warnings, make test-fast FILTER=raon1_mini all pass. Refs #3457
inureyes
marked this pull request as ready for review
November 26, 2026 16:05
11 of 15 tasks
This was referenced Nov 26, 2026
inureyes
added a commit
that referenced
this pull request
Nov 27, 2026
## Summary Six Raon-1 mini performance follow-ups, measured on an M3 Ultra against `main` at `477564e2e` (`docs/benchmark_results/raon-perf-m3ultra-2026-11-26.md`). Three are kept, one is a validation, two were measured and not kept. - **1. Prompt cache, kept.** Raon donates and restores exact-prefix snapshots (RDA conv window, f32 state and offset; MLA latent pair). TTFT of a repeated 2132-token chat turn: 1.00 s to 0.04 s; follow-up turns 1.04 s to 0.08 to 0.17 s; replies identical. A restore refuses another family, a snapshot that lacks a layer, and RDA state whose rank, batch or offset does not match, so the request prefills cold instead. A DFlash2 burst stores no snapshot, and its prefill now follows the classic split so drafted text still equals plain text. - **2. Decode, kept in part.** 33.5 to 54.2 tok/s (target 38). Profiling found the step bound by one product, not by dispatch count: a one-row mHC selector product ran MLX's transposed gemv kernel (255 us against 35 us row-major, 50 sites per token). One-row products now take the row-major form (51.5 tok/s alone); compiled mHC site graphs add the rest and are bit-identical. Fused RDA projections were dropped: +0.6 to +0.8%, and not bit-identical at the real width. - **3. Batched DFlash2, not enabled.** A probe measured an exact verify block at 42 to 59% more for two rows than for one, against 9% for a batched decode step. The ceiling on batched drafting is 13 to 22% below classic batched decode at four rows and within a few percent of it at two, before the draft cost and the uniform accept. `supports_batched` stays `false` and no B > 1 code was added. Since #3459 the served default `presence_penalty` of 1.5 also keeps default-setting requests out of batched speculative windows. - **4. DFlash2 on the NVFP4 exports, validated.** The gate allows widths 3, 5 and 7 on both exports and drafted text equals plain text in 36 of 36 runs. - **5. ModelOpt NVFP4 load, kept.** 63 to 70 s to 2.2 s; resident memory and decode unchanged. The base profile was 50 s of host weight copy, 10 s of scale decode and 3 s of re-encode; canonical triplets are now reinterpreted on the device, and a loader that already decoded the scales keeps the host path. - **6. One host read per sampled verify block, not kept.** It was slower (49.5 against 48.7 ms per verify round): the rows past the first mismatch are sampled for nothing. The per-row loop is unchanged, so seeded sampled drafted runs keep their behavior. ## Behavior changes to review - Plain greedy text can differ from earlier builds at a near tie, because a decode step's selector product sums in another order. It did on both NVFP4 exports and not on the original for the essay prompt. `MLXCEL_RAON_DECODE_FUSION=mhc` keeps the earlier bytes at 34.5 tok/s; an unrecognized value logs a warning and keeps all fast paths. - Cold Raon chat on the server now splits its prefill at the history boundary, so cold server text can differ from earlier builds and from `mlxcel generate` at a near tie. A cache miss costs 1.14 s against 1.00 s. - The second identical request still misses: the scheduler's warm-up supersedes the boundary entry, as for every snapshot family. The third request hits. - The DFlash2 default width moves from 5 to 3, which the issue did not ask for. With the faster decode step width 5 fell to 0.97x plain decode on prose; width 3 averages 1.18x over nine prompt and checkpoint pairs against 1.11x. ## Correctness - Transformers trace on the #3441 4 x 256 corpus: 0 of 578 decided positions differ on the prefill path and on the decode path. - Greedy drafted text equals plain text in 54 of 54 CLI runs across the three checkpoints and in the server check (36 texts: plain cold, cache hit and drafted). NVFP4 planes are byte-identical to the host transcode, except that scale byte `0xFF` (a NaN) is no longer rewritten to `0x7F`. - A snapshot is never reused across reasoning efforts (scheduler test). ## Test plan - [x] New tests cover snapshot round trip and refusal, the scheduler cache hit and effort miss, compiled against eager mHC, the NVFP4 gate and planned burst prefill, and the device transcode route. - [x] `make verify` locally after merging `main` at `d43915faf`; the issue's `test-fast` filters, fmt and clippy again after merging `main` at `db3a23141`. - [ ] CUDA and ROCm were not run. Closes #3458
7 tasks
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
Closes the nine correctness and validation gaps the Raon-1 mini PRs (#3441, #3445, #3453, #3455) left open, in one change.
GenerationConfigDefaultsreadspresence_penalty;resolve_generation_sampling_defaultsoverlays it when--presence-penaltywas not passed (newpresence_penalty_was_set), logging the source. A request's own value still wins;mlxcel generatekeeps 0.0. Negative or non-numeric values are ignored with a warning. The llama-server manifest entry moves toby_design, like--top-p.UnifiedLinear::check_input_widthandSwitchLinear::check_input_width(quantized planes throughvalidate_quantized_packingwith the loaded layout, dense ones by the last axis), called for every RDA, MLA, dense MLP, routed and shared expert projection andlm_head. Errors name{prefix}.weightand both widths.KimiK3MLAAttention::check_input_widthsexists but Kimi K3 does not call it yet.check_scales_leading_axesruns inUnifiedLinear::from_weights_with_modeandSwitchLinear::from_stacked_partsbefore reconciliation, for every quantized family.validate_quantized_packingand Raon'scheck_scales_match_weightdelegate to it.rda_config,total_bytesaddsrda_layers * (H*D*D*4 + (K-1)*3*H*D*2)per sequence (48.8 MB on Raon-1 mini);marginal_bytes_per_tokenis unchanged and the detail line names the state.PINNED_CODE_DIGESTSfor revision6691a076(verified against the local files' HF etags), checked before the checkpoint code is imported;--allow-unpinned-codewarns and writescode_pin unpinnedinto the header.rms_norm_round_onceadded and measured; Raon keepsfast_rms_norm(table below).compute_g_lower_boundedcastsato f32 before addingdt_bias.reasoning_effort_steeringmodel is served pipeline-parallel (in-process, remote, or as a stage peer), as a disaggregated prefill or decode node, or on XLA. The guard issrc/server/reasoning_steering_startup_guard.rs; its tests live next to it rather than instartup_tests.rs, becausestart_servercannot be unit-tested per path.... (N bytes).Item 1: affected families under
models/Only Raon checkpoints set
presence_penalty:raon-1-mini,raon-1-mini-mlx,raon-1-mini-nvfp4(1.5) andraon-1-nano(1.5, not loadable yet, #3438). The other checkpoints undermodels/are unaffected.Side effect on DFlash2 serving: a nonzero presence penalty makes
needs_token_history()true, andsampling_config_eq(src/server/batch/speculative_burst.rs) keeps such requests out of batched speculative windows. Concurrent Raon requests that name no penalty therefore draft as single-request bursts under the new 1.5 default (output unchanged);--presence-penalty 0or a per-request value restores batching. Lifting this needs per-row token history in the batched window, a separate follow-up. The docs note this next to the presence_penalty default.Item 6: measurement and decision
Teacher-forced traces against the existing Transformers reference (bf16, CPU,
--effort max),compare_logit_traces.py --decided 1. Arms differ only in Raon's decoder and final norms (input, post-attention, final); the MLA latent norms and the f32 RDAo_normwere left as they are. Decode ismlxcel generate, 256 tokens, temp 0, ABAB in one lock hold on M3 Ultra (load average 13.7 to 8.3, the sibling unit was building).fast_rms_normrms_norm_round_onceDecision: keep
fast_rms_norm. Round-once removes the one decided disagreement (row 866, which #3441 traced to reference-side bf16 noise) but slows single-stream decode 3.1%, above the 2% bar, and raises perplexity delta on the long prompt. No family's norm changes in this PR.Item 7: CUDA and ROCm coverage
No CUDA or ROCm host was reachable from this run (no local GPU tools,
spark-101/spark-102do not resolve, no SSH keys). The fix and its test ran on Metal only, where the test passes before and after as designed.make test-fast-cuda FILTER=gated_deltaand the Raon tiny-model suites on CUDA and ROCm remain to be run.Test plan
a_projection_with_the_wrong_input_width_fails_the_load_by_name,unified_linear_refuses_scales_with_fewer_rows_than_the_weight,stacked_switch_linear_refuses_scales_with_fewer_rows_than_the_weight,raon1_mini_counts_its_rda_state_once_per_sequence,an_oversized_level_is_echoed_truncated, and the digest tests against main's oracle script. Items 1 and 8 add new API, so their tests do not compile on main.bounded_gate_upcasts_a_bf16_input_before_adding_dt_biaspasses on Metal before and after.make verify-llama-compat,make verify-python-tooling, andmake verifylocally.make test-fast-cuda FILTER=gated_deltaand the Raon tiny-model suites on CUDA and ROCm (no host available).Closes #3457