Skip to content

fix(models): close Raon-1 mini correctness and validation gaps - #3459

Merged
inureyes merged 4 commits into
mainfrom
fix/issue-3457-raon-correctness-followups
Nov 26, 2026
Merged

inureyes merged 4 commits into
mainfrom
fix/issue-3457-raon-correctness-followups

Conversation

@inureyes

@inureyes inureyes commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes the nine correctness and validation gaps the Raon-1 mini PRs (#3441, #3445, #3453, #3455) left open, in one change.

  • 1. presence_penalty (server only). GenerationConfigDefaults reads presence_penalty; resolve_generation_sampling_defaults overlays it when --presence-penalty was not passed (new presence_penalty_was_set), logging the source. A request's own value still wins; mlxcel generate keeps 0.0. Negative or non-numeric values are ignored with a warning. The llama-server manifest entry moves to by_design, like --top-p.
  • 2. Input widths at load. New UnifiedLinear::check_input_width and SwitchLinear::check_input_width (quantized planes through validate_quantized_packing with the loaded layout, dense ones by the last axis), called for every RDA, MLA, dense MLP, routed and shared expert projection and lm_head. Errors name {prefix}.weight and both widths. KimiK3MLAAttention::check_input_widths exists but Kimi K3 does not call it yet.
  • 3. Scales leading axes. check_scales_leading_axes runs in UnifiedLinear::from_weights_with_mode and SwitchLinear::from_stacked_parts before reconciliation, for every quantized family. validate_quantized_packing and Raon's check_scales_match_weight delegate to it.
  • 4. KV estimate. With rda_config, total_bytes adds rda_layers * (H*D*D*4 + (K-1)*3*H*D*2) per sequence (48.8 MB on Raon-1 mini); marginal_bytes_per_token is unchanged and the detail line names the state.
  • 5. Oracle digests. PINNED_CODE_DIGESTS for revision 6691a076 (verified against the local files' HF etags), checked before the checkpoint code is imported; --allow-unpinned-code warns and writes code_pin unpinned into the header.
  • 6. RMSNorm double rounding. rms_norm_round_once added and measured; Raon keeps fast_rms_norm (table below).
  • 7. Bounded gate. compute_g_lower_bounded casts a to f32 before adding dt_bias.
  • 8. Steering on unsupported paths. Startup fails, naming the path and the model, when a reasoning_effort_steering model is served pipeline-parallel (in-process, remote, or as a stage peer), as a disaggregated prefill or decode node, or on XLA. The guard is src/server/reasoning_steering_startup_guard.rs; its tests live next to it rather than in startup_tests.rs, because start_server cannot be unit-tested per path.
  • 9. Bounded echo. The invalid-level error echoes at most 32 characters, Debug-escaped, plus ... (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) and raon-1-nano (1.5, not loadable yet, #3438). The other checkpoints under models/ are unaffected.

Side effect on DFlash2 serving: a nonzero presence penalty makes needs_token_history() true, and sampling_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 0 or 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 RDA o_norm were left as they are. Decode is mlxcel 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).

Arm 4 x 256 decided disagree 4 x 256 ppl delta 871-token decided disagree 871-token ppl delta Decode tok/s (r1 / r2)
fast_rms_norm 0 / 578 +0.186% 1 / 549 +0.337% 33.30 / 33.31
rms_norm_round_once 0 / 578 +0.225% 0 / 549 +0.607% 32.26 / 32.26

Decision: 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-102 do 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_delta and the Raon tiny-model suites on CUDA and ROCm remain to be run.

Test plan

  • New tests fail on main (pre-fix binary): 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_bias passes on Metal before and after.
  • Targeted suites pass: raon, generation_config, kv_arch, reasoning_steering, gated_delta, switch_layers, server startup and cli_input, kimi_k3, core layers and rms_norm.
  • All three Raon checkpoints and two other quantized families load and generate with the new checks.
  • make verify-llama-compat, make verify-python-tooling, and make verify locally.
  • make test-fast-cuda FILTER=gated_delta and the Raon tiny-model suites on CUDA and ROCm (no host available).

Closes #3457

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
@inureyes inureyes added status:review Under review type:bug Bug fixes, error corrections, or issue resolutions priority:medium Medium priority area:models Model architectures, weights, loading, metadata area:core mlxcel-core: MLX FFI, primitives, KV cache, layers modeltype:text Text-only language model labels Nov 26, 2026
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 inureyes added status:done Completed and removed status:review Under review labels Nov 26, 2026
@inureyes
inureyes marked this pull request as ready for review November 26, 2026 16:05
@inureyes
inureyes merged commit d43915f into main Nov 26, 2026
33 checks passed
@inureyes
inureyes deleted the fix/issue-3457-raon-correctness-followups branch November 26, 2026 16:06
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
@inureyes inureyes added this to the 0.9 milestone Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core mlxcel-core: MLX FFI, primitives, KV cache, layers area:models Model architectures, weights, loading, metadata modeltype:text Text-only language model priority:medium Medium priority status:done Completed type:bug Bug fixes, error corrections, or issue resolutions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: Raon-1 mini correctness and validation follow-ups

1 participant