Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [Unreleased]

### Added

- **Ricursive Ripple** (`ricursive`, #3224): `frogggias/Ripple-65B-Preview-MLX-4bit` and `-8bit` run in `mlxcel generate`, `mlxcel-server` and `mlxcel arch` with native batched decode, in the checkpoint's own dtype (no load-time bf16 -> f16 cast). On GB10 the 4-bit checkpoint's greedy output matches mlx-vlm token for token. The ModelOpt NVFP4 export and mixed per-module quantizations are refused by name.

## [v0.9.0] - 2026-11-30

### Added
Expand Down
1 change: 1 addition & 0 deletions docs/supported-models.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/distributed/tensor_parallel/inference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ fn fallback_architecture(model_type: ModelType) -> &'static str {
ModelType::Flint => "flint",
ModelType::Laguna => "laguna",
ModelType::Limite => "limite",
ModelType::Ricursive => "ricursive",
ModelType::MiniCPM | ModelType::MiniCPMOVLM => "minicpm",
ModelType::MiniCPM3 => "minicpm3",
ModelType::StableLM => "stablelm",
Expand Down
1 change: 1 addition & 0 deletions src/execution/memory_estimate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,7 @@ fn inspect_registry_id(model_type: ModelType) -> &'static str {
ModelType::Flint => "flint",
ModelType::Laguna => "laguna",
ModelType::Limite => "limite",
ModelType::Ricursive => "ricursive",
ModelType::Helium => "helium",
ModelType::Lille130m => "lille_130m",
ModelType::K2Horizon => "k2_horizon",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/mlxcel-core/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4539,7 +4539,7 @@ pub fn cache_window(family: &str, window: usize, has_sliding_layer: bool) -> Res
/// Used by: AFMoE, DeepSeek V4, Exaone4, Exaone MoE, Gemma3 (and its backbone
/// and embedding variants), Gemma4 (MTP target and verify rows included),
/// GPT-OSS, IQuestLoopCoder, Kolibri-1, Laguna, Llama4, Mellum, Ministral3, MiMo V2
/// Flash, Muse Glimmer, OpenAI privacy filter, RecurrentGemma, Step3.5
/// Flash, Muse Glimmer, OpenAI privacy filter, RecurrentGemma, Ricursive, Step3.5
pub struct RotatingKVCache {
pub keys: Option<UniquePtr<MlxArray>>,
pub values: Option<UniquePtr<MlxArray>>,
Expand Down
3 changes: 2 additions & 1 deletion src/lib/mlxcel-core/src/cache/attend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,8 @@ pub fn attend_batched(
/// not repeatedly copy growing intermediates as the batch gets wider.
///
/// Used by: [`attend_batched`], `models::gemma3::Attention::forward_batched_decode`,
/// `models::llama4::CxxAttention::forward_batched_decode_rows`.
/// `models::llama4::CxxAttention::forward_batched_decode_rows`,
/// `models::ricursive::RicursiveAttention::forward_batched_decode`.
pub fn attend_batched_rows<C: KvAttention>(
q_batched: &MlxArray,
k_batched: &MlxArray,
Expand Down
6 changes: 4 additions & 2 deletions src/lib/mlxcel-core/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ impl PrefillAttention {
/// Ministral3, Exaone4, ExaoneMoe, Mellum, Step3P5, AFMoE and Gemma3n
/// (#3072); GptOss, FalconOcr and the sink full layers of MiMoV2 (#3098);
/// the NoPE global layers of Limite (#2360); the full layers of OlmoHybrid,
/// Plamo3 (#2374) and Spark-X2.5 (#2372); and Gear's full-attention layers (#2376).
/// Plamo3 (#2374) and Spark-X2.5 (#2372); Gear's full-attention layers (#2376);
/// and the NoPE full layers of Ricursive (#3224).
pub fn prefill_causal_mask(
seq_len: i32,
offset: i32,
Expand Down Expand Up @@ -438,7 +439,8 @@ pub enum SlidingPrefillKeys {
/// ExaoneMoe, Mellum, Step3P5, AFMoE, Gemma3n; GptOss, MiMoV2 and an all-local
/// DeepSeekV4 stack (#3098); Limite, whose window is `sliding_window + 1`
/// (#2360); Spark-X2.5, whose window is `sliding_window`
/// (#2372); and Gear's sliding-attention layers (#2376).
/// (#2372); Gear's sliding-attention layers (#2376); and Ricursive's sliding
/// layers (#3224).
pub fn prefill_sliding_window_mask(
seq_len: i32,
prior: i32,
Expand Down
2 changes: 2 additions & 0 deletions src/loaded_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ pub enum LoadedModel {
Laguna(models::LagunaWrapper),
// Sliding/global caches owned per sequence by the wrapper.
Limite(models::LimiteWrapper),
Ricursive(models::RicursiveWrapper),
MiniCPM(models::MiniCPMModel),
MiniCPM3(models::MiniCPM3Model),
StableLM(models::StableLMModel),
Expand Down Expand Up @@ -460,6 +461,7 @@ macro_rules! delegate_language_model {
LoadedModel::Flint(inner) => LanguageModel::$method(inner, $($arg),*),
LoadedModel::Laguna(inner) => LanguageModel::$method(inner, $($arg),*),
LoadedModel::Limite(inner) => LanguageModel::$method(inner, $($arg),*),
LoadedModel::Ricursive(inner) => LanguageModel::$method(inner, $($arg),*),
LoadedModel::MiniCPM(inner) => LanguageModel::$method(inner, $($arg),*),
LoadedModel::MiniCPM3(inner) => LanguageModel::$method(inner, $($arg),*),
LoadedModel::StableLM(inner) => LanguageModel::$method(inner, $($arg),*),
Expand Down
1 change: 1 addition & 0 deletions src/model_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ macro_rules! for_each_model_registration {
Flint => { kind: Text, directory: ConfigBacked, weight: Some(WeightLoadRoute::ConfigBacked), adapter: None, config_backed: { dir_loader: models::flint::load, args: models::flint::ModelArgs, weight_builder: models::flint::from_weights, wrap: |m| LoadedModel::Flint(models::LagunaWrapper::new(m)) } };
Laguna => { kind: Text, directory: ConfigBacked, weight: Some(WeightLoadRoute::ConfigBacked), adapter: None, config_backed: { dir_loader: models::LagunaModel::load, args: models::laguna::ModelArgs, weight_builder: models::LagunaModel::from_weights, wrap: |m| LoadedModel::Laguna(models::LagunaWrapper::new(m)) } };
Limite => { kind: Text, directory: ConfigBacked, weight: Some(WeightLoadRoute::ConfigBacked), adapter: None, config_backed: { dir_loader: models::LimiteModel::load, args: models::limite::ModelArgs, weight_builder: models::LimiteModel::from_weights, wrap: |m| LoadedModel::Limite(models::LimiteWrapper::new(m)) } };
Ricursive => { kind: Text, directory: ConfigBacked, weight: Some(WeightLoadRoute::ConfigBacked), adapter: None, config_backed: { dir_loader: models::RicursiveModel::load, args: models::ricursive::ModelArgs, weight_builder: models::RicursiveModel::from_weights, wrap: |m| LoadedModel::Ricursive(models::RicursiveWrapper::new(m)) } };
MiniCPM => { kind: Text, directory: ConfigBacked, weight: Some(WeightLoadRoute::ConfigBacked), adapter: None, config_backed: { dir_loader: models::MiniCPMModel::load, args: models::minicpm::ModelArgs, weight_builder: models::MiniCPMModel::from_weights, wrap: LoadedModel::MiniCPM } };
MiniCPM3 => { kind: Text, directory: ConfigBacked, weight: Some(WeightLoadRoute::ConfigBacked), adapter: None, config_backed: { dir_loader: models::MiniCPM3Model::load, args: models::minicpm3::ModelArgs, weight_builder: models::MiniCPM3Model::from_weights, wrap: LoadedModel::MiniCPM3 } };
StableLM => { kind: Text, directory: ConfigBacked, weight: Some(WeightLoadRoute::ConfigBacked), adapter: None, config_backed: { dir_loader: models::StableLMModel::load, args: models::stablelm::ModelArgs, weight_builder: models::StableLMModel::from_weights, wrap: LoadedModel::StableLM } };
Expand Down
1 change: 1 addition & 0 deletions src/models/batched_decode_coverage_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ const EXPECTED_NATIVE: &[&str] = &[
"Qwen3VLMoeModel@src/models/qwen3_vl_moe.rs",
"Qwen3VLMoeModel@src/vision/qwen3_vl_moe.rs",
"Raon1MiniModel@src/models/raon1_mini_lm.rs",
"RicursiveWrapper@src/models/ricursive.rs",
"Rwkv7@src/models/rwkv7.rs",
"SeedOssModel@src/models/seed_oss.rs",
"SmolLM3Model@src/models/smollm3.rs",
Expand Down
52 changes: 46 additions & 6 deletions src/models/deepseek_v4_moe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,12 @@ use super::{ModelArgs, ScoringFunc, get_weight_copy};

/// `silu(min(gate, limit)) * clip(up, -limit, limit)` (`_limited_swiglu`).
/// A non-positive limit disables clamping, as in the reference.
///
/// Used by: DeepSeekV4 (`LimitedSwitchGlu` and `LimitedMlp` here) and
/// DeepSeekV4.1 (`deepseek_v41_moe.rs`). Ricursive takes the same clamp
/// through [`limited_swiglu_f32_silu`].
pub(crate) fn limited_swiglu(gate: &MlxArray, up: &MlxArray, limit: f32) -> UniquePtr<MlxArray> {
if limit > 0.0 {
let dtype = mlxcel_core::array_dtype(gate);
let limit_arr = mlxcel_core::full_f32(&[1], limit, dtype);
let neg_limit = mlxcel_core::full_f32(&[1], -limit, dtype);
let gate = mlxcel_core::minimum(gate, &limit_arr);
let up = mlxcel_core::clip(up, &neg_limit, &limit_arr);
if let Some((gate, up)) = clamp_swiglu_inputs(gate, up, limit) {
let gate = mlxcel_core::utils::silu(&gate);
mlxcel_core::multiply(&gate, &up)
} else {
Expand All @@ -77,6 +76,47 @@ pub(crate) fn limited_swiglu(gate: &MlxArray, up: &MlxArray, limit: f32) -> Uniq
}
}

/// [`limited_swiglu`] with the SiLU computed in FP32 and rounded once to the
/// gate's dtype before the multiplication by `up` (Ricursive's
/// `_clipped_swiglu`). The clamp and its non-positive-limit opt-out are the
/// same.
///
/// Used by: Ricursive.
pub(crate) fn limited_swiglu_f32_silu(
gate: &MlxArray,
up: &MlxArray,
limit: f32,
) -> UniquePtr<MlxArray> {
let silu_rounded = |gate: &MlxArray| {
let silu =
mlxcel_core::utils::silu(&mlxcel_core::astype(gate, mlxcel_core::dtype::FLOAT32));
mlxcel_core::astype(&silu, mlxcel_core::array_dtype(gate))
};
if let Some((gate, up)) = clamp_swiglu_inputs(gate, up, limit) {
mlxcel_core::multiply(&silu_rounded(&gate), &up)
} else {
mlxcel_core::multiply(&silu_rounded(gate), up)
}
}

/// `(min(gate, limit), clip(up, -limit, limit))` in the gate's dtype, or
/// `None` for a non-positive limit (no clamp).
fn clamp_swiglu_inputs(
gate: &MlxArray,
up: &MlxArray,
limit: f32,
) -> Option<(UniquePtr<MlxArray>, UniquePtr<MlxArray>)> {
(limit > 0.0).then(|| {
let dtype = mlxcel_core::array_dtype(gate);
let limit_arr = mlxcel_core::full_f32(&[1], limit, dtype);
let neg_limit = mlxcel_core::full_f32(&[1], -limit, dtype);
(
mlxcel_core::minimum(gate, &limit_arr),
mlxcel_core::clip(up, &neg_limit, &limit_arr),
)
})
}

/// Apply the configured scoring function to f32 logits.
fn score_logits(logits_f32: &MlxArray, func: ScoringFunc) -> UniquePtr<MlxArray> {
match func {
Expand Down
1 change: 1 addition & 0 deletions src/models/detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,7 @@ pub(crate) fn detect_model_type_with_probes<P: ModelDetectionProbes + ?Sized>(
"flint" => Ok(ModelType::Flint),
"laguna" => Ok(ModelType::Laguna),
"limite" => Ok(ModelType::Limite),
"ricursive" => Ok(ModelType::Ricursive),
"minicpm" => Ok(ModelType::MiniCPM),
"minicpm3" => Ok(ModelType::MiniCPM3),
"stablelm" => Ok(ModelType::StableLM),
Expand Down
11 changes: 11 additions & 0 deletions src/models/detection_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,17 @@ fn mellum_model_type_is_detected() {
fs::remove_dir_all(model_dir).unwrap();
}

#[test]
fn ricursive_model_type_is_detected() {
assert_eq!(
detect_config(
"ricursive",
json!({ "model_type": "ricursive", "architectures": ["RicursiveForCausalLM"] })
),
ModelType::Ricursive
);
}

#[test]
fn limite_model_type_is_detected() {
let model_dir = temp_path("limite_text");
Expand Down
9 changes: 9 additions & 0 deletions src/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ pub(crate) mod raon_mhc;
pub(crate) mod raon_rda;
pub mod reasoning_effort_steering;
pub mod recurrent_gemma;
pub mod ricursive;
pub mod rwkv7;
pub mod seed_oss;
pub mod siglip_text;
Expand Down Expand Up @@ -549,6 +550,7 @@ pub use qwen3_vl_moe::Qwen3VLMoeModel;
pub use qwen4_exp::Qwen4ExpModel;
pub use raon1_mini::Raon1MiniModel;
pub use recurrent_gemma::GriffinModel;
pub use ricursive::{RicursiveModel, RicursiveWrapper};
pub use rwkv7::Rwkv7;
pub(crate) use sanitize::{
Gemma4WeightBacking, config_has_quantization_metadata, is_modelopt_nvfp4_text_checkpoint,
Expand Down Expand Up @@ -845,6 +847,7 @@ pub enum ModelType {
Laguna, // Poolside Laguna XS / S (hybrid sliding/full MoE with NVFP4 experts)

Limite, // Paradigma Limite (MUDD dense connections, sliding/NoPE-global, sigmoid-softcapped head)
Ricursive, // Ricursive Ripple (sandwich norms, sliding RoPE / NoPE-global, value residuals)

// Other Transformer models
Lille130m, // Lille 130M (fused-QKV GQA, in-sublayer RMSNorm, traditional RoPE)
Expand Down Expand Up @@ -1150,6 +1153,7 @@ pub const ALL_MODEL_TYPES: &[ModelType] = &[
ModelType::Mellum,
ModelType::Laguna,
ModelType::Limite,
ModelType::Ricursive,
// Other Transformer models
ModelType::Helium,
ModelType::Lille130m,
Expand Down Expand Up @@ -1628,6 +1632,10 @@ impl ModelType {
ModelType::Flint => ("Flint (RecursiveSI hybrid MoE)", "MoE (other)"),
ModelType::Laguna => ("Laguna XS / S (Poolside code, hybrid MoE)", "Specialized"),
ModelType::Limite => ("Paradigma Limite (MUDD, sliding/global)", "Specialized"),
ModelType::Ricursive => (
"Ricursive Ripple (sliding/NoPE-global, value residuals)",
"Specialized",
),
ModelType::StableLM => ("StableLM", "Specialized"),
ModelType::Baichuan => ("Baichuan", "Specialized"),
ModelType::MiniCPM => ("MiniCPM 1", "Specialized"),
Expand Down Expand Up @@ -1946,6 +1954,7 @@ mod metadata_tests {
Flint,
Laguna,
Limite,
Ricursive,
Helium,
Lille130m,
K2Horizon,
Expand Down
11 changes: 7 additions & 4 deletions src/models/model_owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ impl KvCacheLayerModes {
/// called with a scheduler sequence id (ADR 0010).
///
/// Used by: `kolibri1`, `muse_glimmer`, `mimo_v2_flash`, `gpt_oss`,
/// `ministral3`, `exaone4`, `mellum`, `laguna`, `step3p5`, `limite`.
/// `ministral3`, `exaone4`, `mellum`, `laguna`, `step3p5`, `limite`,
/// `ricursive`.
pub(crate) fn refuse_scheduler_owned_sequence_id(family: &str, seq_id: SequenceId) -> ! {
panic!(
"{family} state is scheduler-owned: sequence {seq_id} must be forwarded through \
Expand All @@ -188,7 +189,7 @@ pub(crate) fn refuse_scheduler_owned_sequence_id(family: &str, seq_id: SequenceI
/// batches panic (ADR 0010, #3325).
///
/// Used by: `kolibri1`, `gpt_oss`, `ministral3`, `exaone4`, `mellum`,
/// `laguna`, `step3p5`, `limite`.
/// `laguna`, `step3p5`, `limite`, `ricursive`.
pub(crate) fn forward_scheduler_owned_anonymous_batch<
M: mlxcel_core::generate::LanguageModel + ?Sized,
>(
Expand All @@ -213,7 +214,8 @@ pub(crate) fn forward_scheduler_owned_anonymous_batch<
/// their pool `LayerState` directly (issue #1755, ADR 0010).
///
/// Used by: `kolibri1`, `muse_glimmer`, `mimo_v2_flash`, `gpt_oss`,
/// `ministral3`, `exaone4`, `mellum`, `laguna`, `step3p5`, `limite`.
/// `ministral3`, `exaone4`, `mellum`, `laguna`, `step3p5`, `limite`,
/// `ricursive`.
pub(crate) fn trim_fallback_layer_state(
family: &str,
fallback: &RefCell<Vec<LayerState>>,
Expand Down Expand Up @@ -241,7 +243,8 @@ pub(crate) fn trim_fallback_layer_state(
/// and return the input shape.
///
/// Used by: `kolibri1`, `muse_glimmer`, `mimo_v2_flash`, `gpt_oss`,
/// `ministral3`, `exaone4`, `mellum`, `laguna`, `step3p5`, `limite`.
/// `ministral3`, `exaone4`, `mellum`, `laguna`, `step3p5`, `limite`,
/// `ricursive`.
pub(crate) fn validate_layer_state_forward(
family: &str,
n_layers: usize,
Expand Down
2 changes: 2 additions & 0 deletions src/models/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,7 @@ impl ModelType {
ModelType::Flint => "flint",
ModelType::Laguna => "laguna",
ModelType::Limite => "limite",
ModelType::Ricursive => "ricursive",
ModelType::Helium => "helium",
ModelType::Lille130m => "lille_130m",
ModelType::K2Horizon => "k2_horizon",
Expand Down Expand Up @@ -1307,6 +1308,7 @@ pub(crate) fn model_type_keys(model_type: ModelType) -> &'static [&'static str]
ModelType::Flint => &["flint"],
ModelType::Laguna => &["laguna"],
ModelType::Limite => &["limite"],
ModelType::Ricursive => &["ricursive"],
ModelType::MiniCPM => &["minicpm"],
ModelType::MiniCPM3 => &["minicpm3"],
ModelType::StableLM => &["stablelm"],
Expand Down
Loading