Skip to content

feat(models): apply Raon-1 mini reasoning-effort steering - #3445

Merged
inureyes merged 8 commits into
mainfrom
feature/issue-3435-raon-effort-steering
Nov 26, 2026
Merged

inureyes merged 8 commits into
mainfrom
feature/issue-3435-raon-effort-steering

Conversation

@inureyes

@inureyes inureyes commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Summary

Applies the Raon-1 mini release's reasoning-effort steering. Each layer that reasoning_effort_steering.layers lists (12, 14, 16, 18, 20) adds alpha * c to its MoE output in f32 and rounds once before the mHC mix, as modeling_raon1_mini.py at 6691a076 does. Alpha 0 (max, or a config without the block) skips the add, so max is the #3225 model bit for bit.

Changes

  • src/models/reasoning_effort_steering.rs: parses and validates the block and resolves a level to its alpha. none uses the config's none alpha when it is above 0, else 0.1 (NO_THINKING_ALPHA). An unknown level errors with the accepted set. A default of none, negative alphas or alphas that overflow f32, and out-of-range, duplicate or non-MoE layers are refused at load.
  • Model (raon1_mini*.rs): the vectors are required on listed layers and must be [hidden]. Alpha is per sequence, with a model default for seq_id = None. Each row is steered at its own alpha on prefill, on the native batched decode and on the per-row fallback. Releasing or re-preparing a sequence returns it to the default.
  • LanguageModel::set_sequence_reasoning_effort / sequence_reasoning_effort, which are no-ops for every other model.
  • Server (src/server/reasoning_steering.rs): the level is resolved in this order, and the prompt render follows the same thinking toggles. A level the request names (chat_template_kwargs.reasoning_effort, top-level reasoning_effort, Responses reasoning.effort) wins; then the request's own thinking-off (enable_thinking: false or reasoning: false) selects none; then the server default level (--reasoning-effort or --chat-template-kwargs); then a server-default thinking-off selects none; then the config default. Anything else is a 400 listing the accepted set.
    • The level is folded into the prompt-cache template signature, so a prefix computed at one effort is never reused at another.
    • The scheduler sets the level at admission (an invalid one fails only that request) and carries it across preemption and queued adoption. Queued adoption never selects a Raon sequence today (no paged blocks), so only the preemption carry is tested.
    • Thinking on or off stays a template matter. A portable none renders <think></think>. A none inside chat_template_kwargs changes only the alpha, as the model card documents.
  • CLI: mlxcel generate --reasoning-effort LEVEL sets the model default and is validated against the config before the weights load. examples/logit_trace takes MLXCEL_TRACE_REASONING_EFFORT, and scripts/raon1_mini_oracle_trace.py takes --effort.
  • mlxcel arch display name, docs/supported-models.md, docs/responses-api.md and CHANGELOG.md are updated.

Validation

All runs used KRAFTON/Raon-1-mini (rev 6691a076) on an M3 Ultra. The reference is the checkpoint's modeling_raon1_mini.py (Transformers, bf16, CPU) via scripts/raon1_mini_oracle_trace.py --effort. The short prompt is 22 tokens. The long prompt is 871 tokens with thinking off, so every effort is directly comparable.

Check Result
generate ... --reasoning-effort none 42, 1 token then EOS (thinking-off render)
--reasoning-effort minimal exit 1: reasoning_effort must be one of none, low, medium, high, xhigh, max; got "minimal"
Greedy 64 tokens, short, default / low / none 42 then im_end, identical to the reference
Greedy 64 tokens, long, default (high) text identical to the reference
Greedy 64 tokens, long, low text identical to the reference (differs from max: "LLM/VLM/embedding/...")
Teacher-forced, long, default (913 positions) 0 / 541 disagreements at decided positions (largest gap at a disagreement 0.375)
Teacher-forced, long, low (909 positions) 0 / 542 disagreements at decided positions (largest gap 0.5)
max vs the pre-change binary identical text on both prompts (the bit-for-bit claim is the tiny-model test)
Thinking on, default, short diverges at generated token 4 ("simple math." vs "simple math 17+25"). Teacher-forced over the reference text: 0 / 30 decided disagreements, and the one flip has gap 0.75. mlxcel at max on the same text has twice the logit delta (p50 0.25 vs 0.125). Both answer 42
Server: low and max concurrently, against each alone each equals its solo output
Server: minimal on chat completions and on Responses 400 invalid_request_error with the accepted set
Server: reasoning_effort: "none", short 42
models/raon-1-mini-mlx refused at load with the named vendor-export error (#3437)

The prompt cache never hit for Raon on this server, before or after the change (cached_tokens 0 on identical repeats with the pre-change binary too). So the effort separation in the cache key is covered by the store test (a_prefix_cached_at_one_reasoning_effort_is_not_reused_at_another), not by a real-model hit.

Unit tests:

  • alpha resolution for every level, the none fallbacks, unknown levels and config rules
  • the tiny-model test fails if steering is skipped, and max equals the unsteered model bit for bit
  • different-effort rows on the native batched decode and the per-row fallback match each row alone
  • release and re-prepare return a sequence to the default
  • scheduler admission sets the effort; an unknown level fails only that request; two concurrent efforts decode as each alone
  • every server channel; Responses translation; enable_thinking: false means none, including over a server default level; the server default
  • the effort carries across preemption onto the new sequence id
  • the cache key

Test plan

  • cargo test --profile test-fast --features metal,accelerate --lib -- reasoning steering raon effort (280 passed) and the earlier wider selection (982 passed)
  • clippy -D warnings, cargo fmt --check
  • Full local make verify gate
  • Real-checkpoint CLI and server runs (above)

Follow-up

The server never reuses a prompt-cache prefix for Raon, even on identical repeats (pre-existing; Raon has no model-owned snapshot/restore). Tracked with the epic's follow-ups.

Closes #3435

Each layer listed in the config's reasoning_effort_steering block adds alpha * c to its MoE output in f32 and rounds once before the mHC mix, as the reference modeling_raon1_mini.py does. Alpha 0 (max, or no block) skips the add, so max is the #3225 model bit for bit.

- ReasoningEffortSteering parses and validates the block and resolves a level to its alpha (none falls back to 0.1 when the config's none alpha is 0; unknown levels error with the accepted set).
- The model keeps one alpha per sequence plus a model default, and steers each row at its own alpha on prefill, the native batched decode and the per-row fallback. Releasing or re-preparing a sequence returns it to the default.
- LanguageModel gains set_sequence_reasoning_effort and sequence_reasoning_effort (no-ops for other models).
- The server resolves the level from chat_template_kwargs, the top-level or Responses API reasoning effort, the server default, or enable_thinking false (none), refuses anything else with 400, folds the level into the prompt-cache template signature, and hands it to the scheduler, which sets it at admission and carries it across preemption and queued adoption.
- mlxcel generate --reasoning-effort sets the level on the CLI; logit_trace takes MLXCEL_TRACE_REASONING_EFFORT and the reference script takes --effort.
- docs: supported-models and responses-api describe the levels.

Closes #3435
@inureyes inureyes added status:review Under review type:enhancement New features, capabilities, or significant additions priority:medium Medium priority labels Nov 26, 2026
The flag's help said it has no effect with --no-chat-template, which is true of the template kwarg but not of Raon-1 mini's in-weight steering, which the validation runs used with a pre-rendered prompt.

Refs #3435
@inureyes inureyes added 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
…ggle

With a server default of `enable_thinking: false`, a request sending `reasoning: true` and no level rendered with thinking on (the portable control overrides the server default in `resolve_effective_kwargs`) but was steered at the `none` alpha, because the fallback read only the explicit template kwargs and the server default. The fallback now resolves thinking in the same order the render does: the request's `enable_thinking`, else its portable `reasoning` toggle, else the server default.

Adds a regression case to `thinking_off_alone_selects_none`. reasoning_steering tests, clippy and fmt pass.

Refs #3435
The steering add runs at `alpha as f32`, but validation only checked that the f64 config value was finite. An alpha such as 1e39 passed and became infinity in the forward, turning every steered row into NaN logits instead of failing the load by name. Validation now also requires the float32 cast to be finite, with a test for the overflow case.

Refs #3435
@inureyes

Copy link
Copy Markdown
Member Author

Security and performance review of the reasoning-effort steering changes.

No CRITICAL or HIGH findings.

  • MEDIUM, fixed in 0d425b8: ReasoningEffortSteering::validate accepted an alpha that is finite in f64 but overflows f32 (for example 1e39). The forward casts it to f32, so the load succeeded and steered rows produced NaN logits. Validation now rejects it by name, with a test.
  • LOW, open: the 400 for an unknown level echoes the raw value ({raw:?}), and a non-string kwarg is echoed as its full JSON. Debug escaping keeps it inert and the request body limit bounds it, but truncating the echo would be tidier.

Checked and clean: per-sequence effort is cleared on prepare_sequence_state and release_sequence_state_by_id, set on every admitted id after allocation (dense miss, snapshot, and checkpoint adoption), and carried across preemption and dropped adoption. The server never sets the model-wide default, so a reused id cannot inherit another request's level. The prompt-cache key and the scheduler's effort come from the same resolver, raw prompts keep their own sentinel bucket, and the warm-up steers at its context's level. The disaggregated handoff does not carry the effort, but it is refused for model-owned families like Raon. With every alpha at 0 the decode step allocates no MLX arrays and does no host sync (a B-length Vec and B mutex lookups only). With steering on, each step adds one small host-to-device copy plus four elementwise ops in each of the five steered layers.

Tests: targeted raon/reasoning_effort/steering/effort lib tests (90 passed) and cargo clippy --features metal,accelerate --lib --tests -D warnings clean.

A request with `chat_template_kwargs.enable_thinking: false` (top level or under `extra_body`) rendered with thinking off, but under a server default such as `--reasoning-effort low` its steering still resolved to `low`. The model card documents both controls as giving the same result, so the render and the alpha disagreed.

`resolve_model_reasoning_effort` now checks the request's own `enable_thinking: false` after the per-request levels and before the server default level. A level the request names (portable `reasoning_effort` or the template kwarg) still wins over everything. The module doc lists the new order.

Validation: new unit tests cover thinking-off over a server `low` (template kwarg, `extra_body`, `reasoning: false`), an explicit level over both, and a render at the server level that ends in `<think></think>` with the `none` alpha. Narrow lib tests (reasoning, steering, raon, effort) pass.

Refs #3435
A preempted Raon-1 mini sequence is re-queued under a fresh id and must re-prefill at the level it was admitted at. The new scheduler test prefills a `low` request on the tiny steered model, preempts it, checks the new id carries `low` and the old id is cleared, then runs it to completion.

The dropped-queued-adoption carry is not driven: `drop_queued_adoption` only selects requests holding paged blocks, and Raon's model-owned layout has no paged layout, so the reclaim never picks one of its requests. The test module doc records this.

Refs #3435
`mlxcel generate --reasoning-effort minimal` on Raon-1 mini was refused only after the 28.8B model loaded. The level is now checked against the checkpoint's `reasoning_effort_steering` block from `config.json` right after `-m` resolves; a model without the block still leaves the level to its template.

The CHANGELOG Raon-1 mini entry no longer says steering is unapplied and describes the levels, request channels and the thinking-off rule, and docs/supported-models.md states that a request's thinking-off selects `none` over a server default level.

Validation: a bin unit test covers an accepted level, `minimal` refused with the accepted set, and a model without steering; clippy with `-D warnings` on lib and test targets is clean.

Refs #3435
@inureyes

Copy link
Copy Markdown
Member Author

PR finalization

  • Steering precedence: a per-request enable_thinking: false (template kwarg at top level or under extra_body) now selects none over a server default level; a level the request names still wins (1ebc2ce).
  • Tests: precedence unit tests, a render test at a server low default, and a scheduler test that a preempted sequence keeps its level under the new id (3c5d15d). The dropped-queued-adoption carry is not unit-tested: drop_queued_adoption only selects requests holding paged blocks, and Raon's model-owned layout has none, so the reclaim never picks a Raon request.
  • mlxcel generate --reasoning-effort is validated against config.json before the weights load; CHANGELOG and docs/supported-models.md updated (7c12149).
  • Validation: narrow lib tests (reasoning, steering, raon, effort: 280 passed), the new bin test, clippy -D warnings on lib and test targets, cargo fmt --check, make verify-used-by, make verify-llama-compat. The full gate is still to run.

@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 10:25
@inureyes
inureyes merged commit 3a4d1b3 into main Nov 26, 2026
1 check passed
@inureyes
inureyes deleted the feature/issue-3435-raon-effort-steering branch November 26, 2026 10:25
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 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): support the Raon-1-mini release with reasoning-effort steering

1 participant