Skip to content

feat(models): add Raon-1 mini (raon1_mini) hybrid architecture - #3441

Merged
inureyes merged 10 commits into
mainfrom
feature/issue-3225-raon1-mini
Nov 26, 2026
Merged

inureyes merged 10 commits into
mainfrom
feature/issue-3225-raon1-mini

Conversation

@inureyes

@inureyes inureyes commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds the KRAFTON Raon-1 mini architecture (raon1_mini, KRAFTON/Raon-1-mini at 6691a076), run from the original bf16 + MXFP8 checkpoint in mlxcel generate, mlxcel-server and mlxcel arch. Rounding follows modeling_raon1_mini.py wherever the issue body and the reference disagree.

  • Raon_mHC four-stream residual on the Helmert chart (raon_mhc.rs): route, aggregate, mix and the stream-mean final norm each rounded where the reference rounds.
  • RDA gated-delta layers (raon_rda.rs): f32 short convs, L2 norm at eps 1e-6, write ratio, bf16 beta, lower-bounded decay (and the reference form when the bound is null), f32 head norm with a sigmoid gate. The recurrence runs through a new gated_delta_ops_precise, which keeps the decay and recurrent state in f32; the standard Metal kernel rounds both to bf16, which compounded over long prompts (a 0.998 decay becomes 0.996). Other families keep the standard kernel.
  • Gated NoPE MLA reused from Kimi K3 through NopeMlaSpec (KimiK3MLAAttention::from_spec); Kimi K3 behavior is unchanged. Only the seven MLA layers hold KV, as a latent pair, and kv_arch / the MLA latent-family list size it that way (the generic path overestimated it about 80x). An int8 latent request resolves to fp16 until an int8 trace is run.
  • SiTU MLP and a sigmoid top-6 MoE whose MXFP8 experts are reinterpreted byte for byte as MLX's native mxfp8 layout; the routed sum is rounded before the shared expert is added. Steering vectors are loaded in f32 and not applied (alpha 0; feat(models): support the Raon-1-mini release with reasoning-effort steering #3435).
  • Batched server decode is native: RDA states are stacked per step and MLA rows read their own latent caches. Multi-token steps, masks and mixed fresh/started rows run one row at a time.
  • Load-time validation refuses malformed configs and checkpoints by name instead of panicking or aborting (oversized or zero geometry, shape products above i32, ragged experts, fewer than two mHC streams). The vendor MLX export and the NVFP4 exports are refused by name (feat(models): load the Raon-1 mini MLX and ModelOpt NVFP4 exports #3437).
  • scripts/raon1_mini_oracle_trace.py is the Transformers reference arm (generate and trace modes, presence penalty forced to 0).

Validation (M3 Ultra)

  • mlxcel arch lists Raon-1 mini. The issue's generate command answers 42; with the template's enable_thinking=false rendering through --no-chat-template it emits 42<|im_end|>, the same ids as the reference.
  • Greedy against the Transformers reference (bf16, CPU, transformers 5.16.1, set_reasoning_effort("max")): identical on the short prompt and on the 871-token prompt (43 tokens). An earlier flip came from the oracle leaving generation_config.json's presence penalty 1.5 active; fixed in the script.
  • Teacher-forced traces (compare_logit_traces.py --decided 1): 4 x 256 tokens, 0 of 578 decided positions disagree, perplexity +0.19%. Long prompt plus continuation: p99 / max logit delta 0.75 / 2.0, perplexity +0.34%, and 1 of 549 decided positions disagrees (row 866, the token after <|im_start|>assistant). That row is reference-side bf16 noise: the reference flips its own top-1 there when run in f32 (f32 picks \n like mlxcel, gap 0.48), and its bf16 variants (prompt-only, cached prefill, longer context) all agree with each other. Treated as exempt from the zero-disagreement criterion.
  • mlxcel-server streaming: thinking on puts the reasoning in reasoning_content and 42 in content; chat_template_kwargs.enable_thinking=false gives 42 with no reasoning.
  • Aggregate decode with 1 / 2 / 4 concurrent requests: 29.9 / 75.0 / 127.0 tok/s (per-row baseline 29.8 / 30.7 / 29.8). Single stream decodes at 32.9 tok/s. Load peak memory equals active memory (32.8 GB). Two of four concurrent greedy prompts matched solo exactly; the other two diverged late, the usual batch-shape bf16 effect.
  • Raon unit tests (mHC, RDA, MoE router, config validation, batched decode against per-sequence decode, MXFP8 native matmul against dequantize-then-matmul, f32 decay over 64 steps), clippy, fmt, the verify-* contract targets and the full local make verify gate pass.

Known gaps (follow-up)

  • presence_penalty from generation_config.json is not read yet; the default stays 0.0 for all families.
  • Single-stream decode is dispatch-bound (about 30 ms per token against a roughly 8 ms weight floor): mHC small ops and nine separate RDA projections.
  • Projection input widths are not checked at load (same gap as Kimi K3). Fast RMSNorm rounds twice where the reference rounds once (all families).

Tensor parallel, DFlash2 (#3436), NVFP4 (#3437) and nano (#3438) are out of scope.

Closes #3225

KRAFTON/Raon-1-mini (revision 6691a076) runs from its original bf16 + MXFP8 checkpoint. The port follows the checkpoint's Transformers code at every rounding point: four-stream Raon_mHC residuals on the Helmert chart (raon_mhc.rs), RDA gated-delta layers with f32 short convs, the write ratio and the lower-bounded decay (raon_rda.rs), the gated NoPE MLA shared with Kimi K3 through a new NopeMlaSpec, SiTU MLPs, and a sigmoid-routed MoE whose MXFP8 experts are reinterpreted as MLX's native mxfp8 layout without changing a byte.

The reasoning-effort steering vectors are loaded in f32 and not applied (alpha 0, the reference at max effort; #3435). The vendor MLX export and other quantized exports are refused at load by name (#3437). Prefill runs in one pass and batched decode is per row, as for the other recurrent hybrids.

scripts/raon1_mini_oracle_trace.py runs the checkpoint's own modeling code for greedy and teacher-forced comparison. Unit tests cover the Helmert basis, doubly stochastic residuals, aggregate and mix, the layer partition, SiTU, the RDA ratio and decay, NoPE MLA order invariance, sanitize, MXFP8 against dequantize-then-matmul, and prefill against chunked prefill and decode with a left-padded row.

Refs #3225
@inureyes inureyes added status:review Under review type:enhancement New features, capabilities, or significant additions priority:medium Medium priority area:models Model architectures, weights, loading, metadata modelsize:medium 4-bit checkpoint 10-50GB; comfortable on a 128GB dev box modeltype:text Text-only language model arch:hybrid Hybrid attention stack (linear/sliding/full or attention+SSM interleave) labels Nov 26, 2026
The standard Metal gated-delta kernel casts the float32 decay `g` and the incoming state to the activation dtype and stores the outgoing state in it. In bf16 a decay just below 1 has a step of 2^-8 (0.998 becomes 0.996), so long-memory RDA heads drift once per token. The checkpoint's reference keeps the log decay and the recurrent state in fp32. With bit-identical bf16 q, k, v and beta at layer 0, the core output was 0.045 relative error against an fp32 reference forward, against 0.0022 for the reference's own bf16 forward.

RDA now calls the existing precise kernel path through a new `gated_delta_ops_precise` (no casts, f32 state). Other gated-delta families are unchanged.

On the 871-token chat prompt plus continuation, the teacher-forced trace against Transformers goes from p99/max logit delta 1.125/10.25 to 0.75/2.0 and perplexity from +0.475% to +0.337%. The 4x256 corpus stays at 0 of 578 decided disagreements. A new unit test checks that a 0.998 decay survives 64 steps with a float32 state; it fails on the standard kernel.

Refs #3225
The KV estimator did not know raon1_mini: its config has kv_lora_rank, so it fell to the DeepSeek V2 decompressed branch and sized all 25 layers at 40 heads x 320 elements per token, about 80 times the real cache (7 MLA layers x 576 latent elements). Server context sizing and prompt-cache snapshot budgets read that estimate.

- raon1_mini joins MLA_LATENT_CACHE_FAMILIES (not QUANTIZED_LATENT_FAMILIES, so an int8 request resolves to fp16 until an int8 latent trace is run), and kv_arch counts the MLA layers from rda_config.rda_layers as it does from Kimi's kda_layers.
- RDA decay with a null gate_lower_bound now follows the reference, exp(-softplus(exp(A_log) * (a + dt_bias))). It went through compute_g, which puts exp(A_log) outside the softplus. Both published Raon-1 configs set -5.0, so their output is unchanged; the reusable block was wrong for a null bound.

Tests: a 25-layer Raon config sizes 7 x (512 + 64) per token; the decay test checks the null-bound form by hand. Raon, latent-family and mlxcel-core MLA tests and clippy pass.

Refs #3225
`presence_penalty=None` does not turn the penalty off: `Raon1MiniForCausalLM.generate` only overrides the generation config when the argument is not None, so the loaded `generation_config.json` value of 1.5 stayed and `_get_logits_processor` applied it to every greedy step. The oracle therefore was not plain greedy.

That explains the one flip on the 871-token prompt ("Linux and Windows" against mlxcel's "Linux/Windows"): `/` had already been generated in "Linux/CUDA", the penalty took 1.5 off it, and its 1.125 lead over " and" went away. Passing 0.0 skips the processor. Rerun on the same prompt, the reference now emits the same 43 tokens as mlxcel, ending in "Linux/Windows as secondary targets.<|im_end|>".

Refs #3225
@inureyes

Copy link
Copy Markdown
Member Author

Implementation Review Summary

Intent

Run raon1_mini from the original bf16 + MXFP8 checkpoint in generate, server and arch, at steering alpha 0, matching modeling_raon1_mini.py at 6691a076.

Findings Addressed

  • KV estimate fell to the DeepSeek V2 decompressed branch (25 layers x 40 heads x 320 elements per token, about 80 times the real 7 x 576 latent). raon1_mini is now a latent-pair family (fp16 by default) and kv_arch counts MLA layers from rda_config.rda_layers (HIGH, 45dee53)
  • The greedy oracle passed presence_penalty=None, which keeps generation_config.json's 1.5. That penalty caused the 871-token flip, not the reference's cached path. With 0.0 the reference emits the same 43 tokens as mlxcel (HIGH, f7c94ab)
  • RDA decay with a null gate_lower_bound used compute_g (exp(A_log) outside the softplus). It now uses the reference's -softplus(exp(A_log) * (a + dt_bias)). Both published configs use -5.0, so their output does not change (MEDIUM, 45dee53)

Remaining Items

  • presence_penalty from generation_config.json is not read. GenerationConfigDefaults has no field for it, and the server default stays 0.0. The issue's plan asks for it. The change affects every family that sets it, Xing4.0 included (MEDIUM)
  • RMSNorm goes through MLX fast rms_norm, which rounds x * inv to bf16 before the gamma multiply. The reference rounds once. The same holds for every family (MEDIUM)
  • The docs entry names --reasoning off, which exists on mlxcel serve only. mlxcel generate has no template-kwarg flag (LOW)
  • compute_g_lower_bounded adds a bf16 a to the f32 dt_bias before casting, and the CUDA overlay rounds that sum to bf16. It is shared with Kimi K3. Metal is exact (LOW)

Verification

  • All stated requirements implemented (except the presence-penalty default above)
  • No placeholder/mock code remaining
  • Integrated into project code flow
  • Project conventions followed
  • Existing modules reused where applicable
  • No unintended structural changes
  • Tests pass (Raon, latent-family, kv_arch and mlxcel-core MLA selectors; clippy, fmt, verify-used-by)

config.json and the checkpoint are untrusted input, and several Raon-1 mini load paths turned a malformed value into a panic or a process abort instead of a named load error.

- validate_layer_partition sized a bitmap from num_hidden_layers, so a count of usize::MAX overflowed and a large one allocated from the config alone. It now uses a set sized by the listed entries and scans at most listed + 1 layers.
- Raon1MiniConfig::validate now refuses zero widths (an RDA head_dim of 0 made the query scale inf), raon_mhc_streams above 64, and any dimension or shape product that does not fit MLX's i32, which `as i32` casts would otherwise truncate into a match with a crafted tensor.
- stack_mxfp8_experts checks every expert against expert 0 before stacking: MLX stack throws on mismatched shapes, and a throw across the cxx bridge aborts.
- RaonMhc::from_weights returns an error for fewer than 2 streams instead of underflowing (n - 1).

New unit tests cover each case; cargo test --lib raon and clippy -D warnings pass.

Refs #3225
Raon-1 mini declared BatchedDecodeKind::PerRowFallback, so the server ran one full forward per active sequence every step and read every weight (the experts, the 260K-row head) once per row. Aggregate decode stayed flat as concurrency grew: about 30 tok/s at 1, 2 and 4 concurrent requests on M3 Ultra.

Batched decode is now native, following Kimi Linear and Kimi K3. The RDA conv and recurrent states of the rows are stacked into one [B, ...] state for the step and split back, and the MLA layers go through KimiK3MLAAttention::forward_batched_decode against each row's own latent cache, so rows of different lengths share the step. A multi-token step, a mask, or rows whose recurrent state is not uniform (a fresh row next to a started one) still run one row at a time. The decoder layer's two mHC sites and FFN are shared between both paths through forward_with_mixer.

The model-owned batched decode harness (multistep, paged lengths, fresh and mixed rows, B=1 transitions) passes against per-sequence decode at 1e-5. On models/raon-1-mini (M3 Ultra, release server, 128 tokens per request) aggregate decode goes from 29.8 / 30.7 / 29.8 tok/s at 1 / 2 / 4 concurrent requests to 29.9 / 75.0 / 127.0 tok/s. Greedy output of four prompts run concurrently matched the solo runs for two prompts and diverged late (after about 280 characters) for the other two, the usual bf16 batch-shape effect of batched matmuls.

Refs #3225
@inureyes

Copy link
Copy Markdown
Member Author

Security and performance review

Fixed on this branch:

  • HIGH, untrusted config and checkpoint input (999aa99). validate_layer_partition sized a bitmap from num_hidden_layers (usize::MAX overflowed, large values allocated from the config alone); the config accepted zero widths (RDA head_dim 0 gives an inf query scale), unbounded raon_mhc_streams, and dimensions above i32 that as i32 casts truncate; stack_mxfp8_experts stacked experts of different shapes, which throws inside MLX and aborts across the cxx bridge. All now fail by name, with tests.
  • HIGH, batched decode did not scale (48a4664). PerRowFallback ran one full forward per sequence, so aggregate decode stayed at 29.8 / 30.7 / 29.8 tok/s for 1 / 2 / 4 concurrent requests. Native batched decode (stacked RDA states, per-row MLA latent caches via KimiK3MLAAttention::forward_batched_decode) gives 29.9 / 75.0 / 127.0 tok/s (M3 Ultra, release server, 128 tokens per request). The model-owned batched harness passes at 1e-5. The PR body line "batched decode runs per row" is now stale.

Checked, no change needed:

  • Load memory: peak_bytes == active_bytes (32.8 GB) after eager materialization, so the 128-expert stacking keeps no duplicate copy.
  • Vendor export rejection runs on the raw JSON before deserialization and again in validate() on the flattened extras, so the config-backed weight route is covered too.
  • The f32 RDA state of gated_delta_ops_precise adds about 47 MB of state traffic per token over bf16 (18 layers x 40 x 128 x 128 x 4 bytes, read and written), which is well under 1 ms at this bandwidth. No extra evals or host syncs per token; the only item reads are the mHC scalars at load.

Remaining (not fixed here):

  • MEDIUM: single-stream decode is 32.9 tok/s against a bandwidth floor of about 8 ms per token (about 6.5 GB of weights read per token). The step looks dispatch-bound: each of the 50 mHC sites issues about 30 small ops per token, and each RDA layer runs 9 separate projections. Candidates: compile-fuse mHC route / aggregate / mix, and fuse q/k/v (and b_proj / rda_w_proj) into one matmul at load.
  • MEDIUM: projection input widths (RDA and MLA linears, expert down_proj) are only checked on their output rows, so a malformed checkpoint can still abort in the first forward's matmul instead of failing at load. Kimi K3 behaves the same way.
  • LOW: the KV estimate counts only the MLA latent (7 x 576 per token, correct). It does not count the fixed RDA state of about 47 MB per sequence, which is the estimator's convention for recurrent layers.
  • LOW: scripts/raon1_mini_oracle_trace.py imports the checkpoint's Python files (the same pattern as the Laguna oracle). It records their digests but does not pin them.

…sals

The MoE router had no direct test: a new hand computation checks that selection uses sigmoid scores plus e_score_correction_bias (the bias lifts a third expert over the unbiased runner-up) while the weights come from the unbiased scores, renormalized with 1e-20 and scaled by routed_scaling_factor, and that both are float32. Detection of model_type raon1_mini is now tested, including a vendor MLX export config, which must still reach Raon1MiniConfig so it is refused by name. The config refusal cases now cover all four vendor export keys and the MLX `quantization` block.

Validation: cargo test --profile test-fast --features metal,accelerate --lib raon (20 passed); clippy --lib --tests with -D warnings and cargo fmt --check are clean.

Refs #3225
docs/supported-models.md told users to pass `--reasoning off`, which only the server binaries accept. It now says the template gates thinking only on enable_thinking, that `mlxcel generate` always renders the template default (thinking on), and that `mlxcel serve` and `mlxcel-server` take a per-request chat_template_kwargs.enable_thinking, a --chat-template-kwargs default, or --reasoning off. The CHANGELOG entry now records the float32 RDA decay and state, the latent KV sized for the seven MLA layers only, native batched decode, and the server thinking switch.

Validation: make verify-versions verify-used-by verify-env-var-docs verify-kernel-dtype-keys verify-kernel-port-dispatch verify-llama-compat and scripts/ci/check_cross_repo_refs.py pass.

Refs #3225
@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 07:50
@inureyes
inureyes merged commit c5afefb into main Nov 26, 2026
33 checks passed
@inureyes
inureyes deleted the feature/issue-3225-raon1-mini branch November 26, 2026 07:50
inureyes added a commit that referenced this pull request Nov 26, 2026
## 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

- [x] 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.
- [x] 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.
- [x] All three Raon checkpoints and two other quantized families load and generate with the new checks.
- [x] `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
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

arch:hybrid Hybrid attention stack (linear/sliding/full or attention+SSM interleave) area:models Model architectures, weights, loading, metadata modelsize:medium 4-bit checkpoint 10-50GB; comfortable on a 128GB dev box modeltype:text Text-only language model priority:medium Medium priority status:done Completed type:enhancement New features, capabilities, or significant additions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(models): add Raon-1-mini (raon1_mini) support

1 participant