Repository navigation
Description
Summary
Add support for Kyutai's Helium text model (model_type: helium) to the mlxcel Rust inference runtime, ported from mlx-lm. Helium is a Llama-style dense decoder, so this is a small port that mostly reuses the existing Llama/Mistral decoder path.
Upstream reference
- mlx-lm implementation: https://github.com/ml-explore/mlx-lm/blob/main/mlx_lm/models/helium.py
Public checkpoint
kyutai/helium-1-preview-2b. Confirm an mlx-community 4-bit conversion exists (for example anmlx-community/helium-*SafeTensors export); if none is published, convert the base checkpoint with the standard mlx tooling for validation. Direct MLX SafeTensors from mlx-community load without a conversion step.
Architecture notes
Helium is essentially a Llama-style dense decoder:
- RMSNorm for attention/MLP norms and the final norm.
- Traditional RoPE:
nn.RoPE(head_dim, traditional=True, base=rope_theta). This is the one deviation from the common Llama path, which usestraditional=False. - GQA (
num_attention_heads>=num_key_value_heads). - SwiGLU MLP with SiLU activation (gate/up/down projections).
- No QK-norm, no MoE, no sliding window. Very close to Llama and Mistral dense decoders.
Implementation plan
This is nearly a Llama clone. The existing dense decoder path does almost all the work:
- Reuse the decoder block, attention, and SwiGLU MLP from
src/models/llama3.rs(orsrc/models/mistral4.rsfor the plain dense shape). No new attention or MLP kernels are needed. - The distinctive work is the traditional-RoPE flag. In
src/models/llama3.rsthe RoPE call ismlxcel_core::fast_rope(&q, self.rope_dims, false, self.rope_base, 1.0, offset), where the third argument istraditional. Helium must passtrue. Thread atraditionalbool from the config through block construction to everyfast_rope/fast_rope_batchedcall in the Helium attention path. Note added after implementation (verified againstsrc/lib/mlxcel-core/cpp/mlx_cxx_bridge.cppand the mergedsrc/models/helium.rs/src/models/llama3.rs, PR feat(models): add Kyutai Helium (helium) text model support #930,1f21b1f4c): threading the flag through thefast_ropecalls is necessary but not sufficient, and this sentence should not be read as implying that every RoPE path can carry it. The two fused quantized launchers,fused_qkv_project_split_ropeandfused_causal_prefill_attention, hardcodetraditional = falsein their C++ bodies and take no flag, so there is no way to ask them for the interleaved rotation. Routing a traditional-RoPE model through either one applies the wrong rotation to correctly shaped tensors, which nothing throws on. The shipped port therefore bypasses them rather than extending them: both fast paths are gated on!rope_traditional, so a traditional-RoPE model always takes the graph fallback, which does receive the flag. Neither fast path is enabled by default, so the gate costs nothing today. - Add a Helium
ModelArgs/config struct (RMSNorm eps,rope_theta, head counts,head_dim, hidden/intermediate sizes, vocab,tie_word_embeddings) with serde defaults matching the upstreamModelArgs. - Handle tied embeddings in
sanitizeif the checkpoint omitslm_head.weight.
Touchpoints & acceptance criteria
Delivered and closed. Implemented by PR #930, merged as 1f21b1f4c; mlxcel arch now reports the family. Test coverage: 27 unit tests in src/models/helium_tests.rs. Real-checkpoint validation: 40 greedy tokens from the 4-bit models/helium-1-preview-2b-4bit reproduce the mlx-lm reference exactly. The checkpoint being quantized is what makes this meaningful, since traditional RoPE was at risk precisely on the quantized path. The unticked boxes below are the original pre-implementation plan and were not maintained during the work; treat the merged PR and its review thread as the record of what shipped.
Follow docs/adding-models.md. Integration is complete only when the model loads and generates from a real checkpoint.
- Config struct with serde parse matching the upstream
helium.pyModelArgs(including the traditional-RoPE flag andrope_theta). -
from_weightsbuilds the model (reusing the Llama/Mistral dense decoder path). -
sanitizehandles tiedlm_headand any weight-key normalization. - Traditional RoPE wired through:
fast_rope/fast_rope_batchedcalled withtraditional = truein the Helium attention path. - Detection arm for
"helium"added insrc/models/detection.rs. - Registration in
src/model_metadata.rsviafor_each_model_registration!. - TP/distributed arch-string wired if the dense path supports it.
-
_tests.rsunit tests (config parse, from_weights shape, a forward smoke). -
docs/supported-models.mdupdated with the Helium entry. - Real-checkpoint validation:
mlxcel archreports the architecture and./target/release/mlxcel generate -m models/<helium> -p "..."produces coherent output.
Correction: the real-checkpoint validation step above originally read mlxcel list, which lists downloaded checkpoints in the local model store. The architecture registry is mlxcel arch, and that is what confirms the binary knows the family.
Effort
LOW. Nearly a Llama clone; the only genuinely new behavior is the traditional-RoPE flag plus config and registration wiring.
Activity
docs(models): record llama3 attention users and anchor the RoPE gap test
fix(models): validate the quantized input axis and the bias sets in t…
feat(models): add Kyutai Helium (helium) text model support (#930)
feat(models): add Kyutai Helium (helium) text model support (lablup#930)