feat(models): add Ripple-65B (ricursive) support
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 12/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- rust
- Ambito
- ai, machine-learning
Direzione di ricerca
Start by reading the Architecture and Current mlxcel state sections, then the closest existing code: src/models/muse_glimmer_layers.rs (MuseGlimmerDecoderLayer) and src/models/deepseek_v4_moe.rs (limited_swiglu). The new family goes in src/models/ricursive.rs with tests in src/models/ricursive_tests.rs. Done means the unit tests pass, the 4-bit checkpoint generates correctly, and logits match mlx-vlm at decided positions.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
Add Ricursive Ripple-65B-Preview (model_type: ricursive, RicursiveForCausalLM), a dense 65B text decoder: 80 layers in a 4:1 pattern of RoPE sliding-window (1024) layers and NoPE global layers, four RMS norms per block (sandwich norms), per-head QK RMSNorm, an elementwise sigmoid attention output gate, clipped SwiGLU, scaled input embeddings, and value residuals that blend every layer's value input with the scaled input embedding. mlxcel has no ricursive support.
Upstream reference
- Blaizzy/mlx-vlm#2697 (commit
c0980db2, 2026-11-10), https://github.com/Blaizzy/mlx-vlm/tree/main/mlx_vlm/models/ricursive (config.py,language.py,ricursive.py,cache.py,speculative_verifier.py). It follows the checkpoint's ownmodeling_ricursive.py(https://huggingface.co/ricursiveAI/Ripple-65B-Preview/blob/da94cc013a8fda04a502f0a185083c7099ea06c1/modeling_ricursive.py). There is no mlx-lm port. - The mlx-vlm
cache.pyandspeculative_verifier.pyexist for the DFlash2 drafter; they are out of scope here.
Architecture (from upstream code and the published config)
Config of ricursiveAI/Ripple-65B-Preview (d58dbcf4): hidden_size 5120, num_hidden_layers 80, num_attention_heads 80, num_key_value_heads 8, head_dim 128, intermediate_size 40960, vocab_size 100352, rms_norm_eps 1e-6, rope_theta 10000, sliding_window 1024, layer_types with full_attention at layers 4, 9, 14, ..., 79 (every fifth, 16 layers) and sliding_attention elsewhere (the same as hybrid_layer_pattern, where 0 marks global), use_gated_attention true, gate_full_precision true, use_valres true, ffn_clamp_threshold 20.0, embed_scale 71.55417527999327 (= sqrt(5120)), max_position_embeddings 2097152, tie_word_embeddings false, bos 100257, eos [100265, 100257], pad 100277, hidden_act silu.
- Embedding:
h0 = (embed_tokens(ids).f32 * embed_scale).astype(dtype)whenembed_scaleis set (a checkpoint may instead fold the scale into the table and set it to null).h0is also the value residual. - Block:
a = attn(input_layernorm(x), value_residual=h0);x = x + post_attention_layernorm(a);x = x + post_feedforward_layernorm(mlp(pre_feedforward_layernorm(x))). Finalnormthenlm_head. - RMSNorm numerics: computed in f32 (
x * rsqrt(mean(x^2) + eps)), rounded to the activation dtype, then multiplied by the weight in that dtype. This is notfast_rms_normwith a weight, which multiplies before rounding; use the round-then-scale order everywhere (all four block norms,q_norm,k_norm, final norm). - Attention:
q_proj(5120 to 80128),k_projandv_proj(5120 to 8128),o_proj, all bias-free.q_norm/k_normper head. Values:v = v_proj(lerp(h0, x_normed, sigmoid(value_res_lambda)))wherevalue_res_lambdais a learned[1]scalar per layer andx_normedis the block's attention input; the lerp is computed in f32 liketorch.lerp(seed + b * (end - seed)forb < 0.5,end + (b - 1) * (end - seed)otherwise) and rounded once. Withuse_valres false,v = v_proj(x_normed). - RoPE: only on sliding layers; full layers are NoPE. Rotate-half (non-traditional) over the full
head_dim,inv_freq = 1 / base^(i/d), positions offset by the cache offset; cos and sin are computed in f32, rounded to the activation dtype, then the rotation is done in f32 and rounded (upstream_apply_rotary). Plainfast_ropediffers in that intermediate rounding; decide with the logit-trace gate below whetherfast_ropeis acceptable, and if it disagrees at decided positions, implement the upstream order. - SDPA: scale
head_dim ** -0.5, GQA 80:8, no sinks. Sliding layers use a windowed causal mask of 1024; full layers a plain causal mask. - Output gate:
out = attn_out * sigmoid(g_proj(x_normed))whereg_projis 5120 to 80*128 (elementwise, not per head); withgate_full_precisionthe sigmoid input is cast to f32 first. Theno_proj. - MLP:
down_proj(silu(min(gate, 20)) * clip(up, -20, 20))withgate_proj/up_proj5120 to 40960; SiLU is computed in f32 and rounded once before the multiply. No clamp whenffn_clamp_thresholdis null. - Caches: sliding layers
RotatingKVCache(max_size=1024, keep=0); full layers growingKVCache. A nullsliding_windowmakes every layer a growing cache. - Config validation (load errors):
layer_typeslength equalsnum_hidden_layers, only the two known layer types,hidden_act == silu,num_attention_heads % num_key_value_heads == 0,sliding_window >= 1when set. Whenlayer_typesis absent, default to full oni % 5 == 4(upstream default).
Weight layout and sanitize
HF keys: model.embed_tokens.weight, model.layers.N.{input_layernorm,post_attention_layernorm,pre_feedforward_layernorm,post_feedforward_layernorm}.weight, model.layers.N.self_attn.{q,k,v,o,g}_proj.weight, self_attn.{q,k}_norm.weight, self_attn.value_res_lambda ([1]), model.layers.N.mlp.{gate,up,down}_proj.weight, model.norm.weight, lm_head.weight. No transforms are needed beyond stripping a language_model. prefix (mlx-vlm conversions) and dropping lm_head.weight when tie_word_embeddings. value_res_lambda must stay f32 or bf16 and unquantized; error by name if it is missing while use_valres is true.
Checkpoints and hosts
| Checkpoint | Revision | Format | Size |
|---|---|---|---|
ricursiveAI/Ripple-65B-Preview |
d58dbcf4 |
BF16 | 129.6 GB |
frogggias/Ripple-65B-Preview-MLX-4bit |
4a33b33f |
affine 4-bit gs64 | 36.4 GB |
frogggias/Ripple-65B-Preview-MLX-8bit |
dd672246 |
affine 8-bit gs64 | 68.8 GB |
araysuter/Ripple-65B-Preview-MLX-mixed-2bit |
d92b6536 |
mixed affine | 29.6 GB |
ricursiveAI/Ripple-65B-Preview-NVFP4 |
b4b4e36d |
ModelOpt NVFP4 | 57.2 GB |
The frogggias 4-bit and 8-bit conversions declare model_type: ricursive with the same config, keep the HF key names above (plus .scales / .biases; embed_tokens and lm_head are quantized too, value_res_lambda and the norms stay bf16), and fit a 128 GB host (8-bit with other jobs serialized); they are the validation targets. Their ricursive.py is a remote-code model file for mlx_lm --trust-remote-code; mlxcel ignores it, and embed_scale is applied after the quantized embedding lookup. BF16 (129.6 GB) exceeds a 128 GB host and is out of scope for validation. The ModelOpt NVFP4 export is a stretch goal: load it only if the existing ModelOpt NVFP4 path in src/models/sanitize.rs handles its dense (non-expert) layout without new code; otherwise reject it with a named error and leave it for a follow-up.
Current mlxcel state and reuse
- No
ricursivearm insrc/models/detection.rs,src/models/mod.rs,src/model_metadata.rsorsrc/models/registry.rs. - Closest families: Gemma 3 and Muse Glimmer for the four-norm sandwich block and the sliding/full mix (
src/models/muse_glimmer_layers.rs:305-335MuseGlimmerDecoderLayer, NoPE full layers viarope_theta: None, gated attention viagate_proj), GPT-OSS / Laguna forRotatingKVCacheplus growing caches with model-owned per-sequence state and windowed prefill masks (src/models/gpt_oss.rs:905-975). - Clipped SwiGLU: reuse
limited_swiglu(src/models/deepseek_v4_moe.rs:65; a non-positive limit disables clamping, which matches a null threshold) and add a// Used by: DeepSeekV4, Ricursivecomment, which the function currently lacks. If the f32 SiLU rounding order matters (check with the trace), add the f32 variant next to it instead of a Ripple-local copy. - Value residual: no mlxcel model has one yet; implement it in
src/models/ricursive.rsas a smallvalue_residual_lerp(h0, x, lambda)helper with a unit test. - The new family touches no shared hotspot other than the
// Used by:line onlimited_swiglu.
Implementation plan
src/models/ricursive.rs:ModelArgswith the validation above,RicursiveRmsNorm(round-then-scale),RicursiveAttention,RicursiveMlp,RicursiveDecoderLayer,RicursiveModel(carriesh0through the layer loop),RicursiveWrapperimplementingLanguageModelwithlast_row_logits, the mixed rotating/full batched decode path, andSequenceId-keyed caches.src/models/ricursive_tests.rs: tests below pluslast_row_case!.- Registration:
src/models/mod.rs(ModelType::Ricursive),src/models/detection.rs("ricursive"),src/model_metadata.rs(ConfigBackedtext entry like Laguna's atsrc/model_metadata.rs:244),src/loaded_model.rs,src/models/registry.rs, and the per-family tables insrc/execution/memory_estimate.rsandsrc/distributed/tensor_parallel/inference.rs(TP unsupported, named error). docs/supported-models.md: an entry under "Text and hybrid model families" covering the block, value residuals, the window, the checkpoints validated, and unsupported paths (TP, DFlash2).- Chat template: the checkpoint's Jinja template is rendered as-is;
<|im_end|>(100265) and<|endoftext|>(100257) both stop generation (fromeos_token_id).
Acceptance criteria
-
mlxcel archlistsricursive. -
mlxcel generate -m models/Ripple-65B-Preview-MLX-4bit -p "Write a Python function that merges overlapping intervals." -n 256 --temp 0produces a correct function and stops on an EOS id. - Greedy 64-token output matches
mlx_vlm.generate --temp 0on the same 4-bit checkpoint for a short prompt and for a prompt longer than 1500 tokens (crosses the 1024 window). Report a teacher-forced logit trace (examples/logit_trace.rs,scripts/compare_logit_traces.py,docs/benchmarks.md) against mlx-vlm on the 8-bit checkpoint with zero disagreement at decided positions; if the RoPE or SwiGLU rounding order is changed from the upstream order, include the arm with the upstream order and show it is not worse. -
mlxcel-server -m models/Ripple-65B-Preview-MLX-4bitserves streaming chat with the checkpoint template. - Unit tests: (1) value residual lerp matches a hand computation for lambda giving blend below and above 0.5, and a test fails if
h0is taken after the first norm instead of before; (2) RMSNorm round-then-scale differs from scale-then-round on a constructed bf16 input and the implementation matches the former; (3) RoPE is applied on sliding layers only; (4) clipped SwiGLU at the threshold and with a null threshold; (5)embed_scalenull versus set; (6) full prefill equals chunked prefill plus decode across the window on a tiny random model; (7) config validation errors; (8)last_row_case!. - Integrated into
mlxcel generate,mlxcel-serverandmlxcel arch;docs/supported-models.mdupdated.
Verification
cargo build --release --features metal,accelerate
cargo test --profile test-fast --features metal,accelerate ricursive_tests:: deepseek_v4_tests::
make verify-test
cargo clippy --workspace --all-targets -- -D warnings
cargo fmt --check
python3 scripts/ci/check_cross_repo_refs.py
./target/release/mlxcel download frogggias/Ripple-65B-Preview-MLX-4bit
./target/release/mlxcel generate -m models/Ripple-65B-Preview-MLX-4bit -p "Write a Python function that merges overlapping intervals." -n 256 --temp 0
Related
- Out of scope, follow-up once this lands: the official DFlash2 drafter
ricursiveAI/Ripple-65B-Preview-DFlash2(upstreamspeculative_verifier.pyand the transactional rotating cache incache.py), and tensor parallel.
- Lingua principale
- Rust
- Stelle
- 505
- Fork
- 81
- Merge medio
- 14h 2m
- PR unite (30g)
- 448
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di lablup/mlxcel
-
area:core priority:high status:ready type:security
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
priority:medium status:ready type:security
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
I maintainer di solito rispondono entro 1 giorno
-
area:models modeltype:text priority:medium status:in-progress type:bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 57/100
I maintainer di solito rispondono entro 1 giorno
-
area:models priority:low status:ready type:test
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 1 giorno
-
area:models modeltype:omni priority:medium status:ready type:bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di lablup/mlxcel
Issue simili
-
area:ui effort:medium enhancement P7 source:agent
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
marketing
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
machine rename accepts a label already used by another machine, making --machine <label> ambiguousApertamaintainer-needed p2 remote triaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
bug help wanted ui
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
userFRM/egui-charts#4605 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno