Repository navigation
Description
Problem / Background
Parent epic: #493 (OpenXLA backend architecture-coverage parity with the MLX engine). Scoping design: #502, recorded in spike/openxla/SSM_HYBRID_DESIGN.md.
Window D of #493 covers state-space (Mamba/Mamba2), gated-linear-attention, and recurrent architectures, and the hybrid models that interleave them with attention. The OpenXLA/IREE backend serves only attention-based dense and MoE decoder families today; Config::from_json rejects every recurrent model_type at the unsupported-architecture error (src/lib/mlxcel-xla/src/emitter/config.rs). The MLX engine already implements all of these families (see src/server/prompt_cache/hybrid_ssm.rs, HYBRID_SSM_MODEL_TYPES), so this epic brings the OpenXLA path to parity.
Target set: Mamba / Mamba2, Jamba, Falcon-H1, RWKV7, Qwen3-Next, Plamo2, Nemotron-H, Kimi-Linear, RecurrentGemma.
This work was deferred out of the #502 design issue by an explicit, recorded decision: a first reference architecture needs a new scan graph primitive, a new per-slot state resource in the C shim, a new per-layer mixer dispatch, and a new validation harness, which is comparable in size to the entire Stage 2 continuous-batching effort rather than to the cheap per-family dense work.
Goal
Land recurrent / state-space / hybrid architectures on the OpenXLA/IREE backend, reusing the config-driven emit, the continuous-batching engine, the IREE runtime, and the serve worker unchanged, by adding the two genuinely new pieces:
- A recurrent/state-space mixing graph primitive (selective scan / linear recurrence) that does not fit the shared attention core.
- Explicit per-slot recurrent STATE allocation and carry through the continuous-batching engine, distinct from the KV cache (fixed-size, does not grow with position), coexisting with the KV cache in hybrid models.
New graph primitives and state handling
The design (spike/openxla/SSM_HYBRID_DESIGN.md) reduces the nine target families to three primitive families (selective SSM/SSD, gated linear attention / delta rule, real-gated linear recurrent unit) that all share one abstraction: a per-token linear recurrence over a fixed-size state, with a chunked/parallel prefill form and a one-step decode form. The recurrent state threads through the same functional-graph + shim mechanism the KV cache already uses (kcache_b / vcache_b, xla_ensure_batch_kv in csrc/xla_iree.c), as parallel per-slot buffers with their own fixed shape and lifecycle. Hybrid models carry both a KV region (attention layers) and a state region (recurrent layers) side by side, advanced together in one pump step.
Sub-issues
Phases 1 and 2 are implemented first on the ROCm gfx1151 host; Phases 3 and 4 follow. CUDA (GB10) and Metal units are validation units for those hosts. Phase 1 ends with Mamba2 generating via MLXCEL_BACKEND=xla token-exact vs HF fp32; Phase 2 with Mamba2 served reference-exact and the prefix-sharing guarantee asserted; Phase 3 with Nemotron-H dual KV + state via CLI and server; Phase 4 with the delta-rule and recurrent families via CLI and server.
Phase 1
- feat(xla): SSM scan primitive (conv1d + selective scan) with HF oracle #3337 SSM scan primitive + HF oracle
- feat(xla): Mamba2 config, mixer schedule, weights, state-threaded graphs #3338 Mamba2 config, weights, state-threaded graphs (depends on feat(xla): SSM scan primitive (conv1d + selective scan) with HF oracle #3337)
- feat(xla): single-seq recurrent state in shim; Mamba2 generates on xla #3339 single-seq state in shim; Mamba2 CLI (depends on feat(xla): Mamba2 config, mixer schedule, weights, state-threaded graphs #3338)
Phase 2
- feat(xla): per-slot recurrent state; Mamba2 serves via mlxcel-server #3340 per-slot state carry; Mamba2 serve (depends on feat(xla): single-seq recurrent state in shim; Mamba2 generates on xla #3339)
- test(xla): recurrent models never share prefix-hash caches (XLA + MLX) #3341 no prefix-hash sharing for recurrent models (depends on feat(xla): per-slot recurrent state; Mamba2 serves via mlxcel-server #3340)
- test(xla): validate Mamba2 scan, state carry, CLI/serve on IREE-CUDA #3342 Mamba2 on IREE-CUDA, GB10 (depends on feat(xla): per-slot recurrent state; Mamba2 serves via mlxcel-server #3340)
- test(xla): validate the Mamba2 SSM path on IREE-Metal (macOS) #3343 Mamba2 on IREE-Metal (depends on feat(xla): per-slot recurrent state; Mamba2 serves via mlxcel-server #3340)
Phase 3
- feat(xla): Nemotron-H hybrid with dual KV + recurrent state carry #3344 Nemotron-H hybrid, dual KV + state (depends on feat(xla): per-slot recurrent state; Mamba2 serves via mlxcel-server #3340)
- feat(xla): sigmoid score-correction MoE router and relu2 experts #3345 sigmoid grouped MoE router + relu2 experts (depends on feat(xla): Nemotron-H hybrid with dual KV + recurrent state carry #3344)
- feat(xla): Falcon-H1 (parallel Mamba2 + attention, muP multipliers) #3346 Falcon-H1 (depends on feat(xla): Nemotron-H hybrid with dual KV + recurrent state carry #3344)
- feat(xla): Plamo2 (Mamba2 variant with dt/B/C RMSNorms) hybrid #3347 Plamo2 (depends on feat(xla): Nemotron-H hybrid with dual KV + recurrent state carry #3344)
- feat(xla): Mamba1 selective scan; Mamba and Falcon-Mamba end to end #3348 Mamba1 scan; Mamba and Falcon-Mamba (depends on feat(xla): per-slot recurrent state; Mamba2 serves via mlxcel-server #3340)
- feat(xla): Jamba hybrid (Mamba1 + attention + softmax MoE) #3349 Jamba hybrid (depends on feat(xla): Nemotron-H hybrid with dual KV + recurrent state carry #3344, feat(xla): Mamba1 selective scan; Mamba and Falcon-Mamba end to end #3348)
- test(xla): validate Phase 3 hybrids on IREE-CUDA incl. Nemotron-3-Nano #3350 Phase 3 hybrids on IREE-CUDA (depends on feat(xla): Nemotron-H hybrid with dual KV + recurrent state carry #3344, feat(xla): sigmoid score-correction MoE router and relu2 experts #3345, feat(xla): Falcon-H1 (parallel Mamba2 + attention, muP multipliers) #3346, feat(xla): Plamo2 (Mamba2 variant with dt/B/C RMSNorms) hybrid #3347, feat(xla): Mamba1 selective scan; Mamba and Falcon-Mamba end to end #3348, feat(xla): Jamba hybrid (Mamba1 + attention + softmax MoE) #3349)
- test(xla): validate Phase 3 hybrids on IREE-Metal #3351 Phase 3 hybrids on IREE-Metal (depends on feat(xla): Nemotron-H hybrid with dual KV + recurrent state carry #3344, feat(xla): sigmoid score-correction MoE router and relu2 experts #3345, feat(xla): Falcon-H1 (parallel Mamba2 + attention, muP multipliers) #3346, feat(xla): Plamo2 (Mamba2 variant with dt/B/C RMSNorms) hybrid #3347, feat(xla): Mamba1 selective scan; Mamba and Falcon-Mamba end to end #3348, feat(xla): Jamba hybrid (Mamba1 + attention + softmax MoE) #3349)
Phase 4
- feat(xla): gated delta-rule primitive (chunked prefill + step decode) #3352 gated delta-rule primitive (depends on feat(xla): per-slot recurrent state; Mamba2 serves via mlxcel-server #3340)
- feat(xla): Qwen3-Next and Qwen3.5 text hybrids (GatedDeltaNet) #3353 Qwen3-Next and Qwen3.5 text hybrids (depends on feat(xla): Nemotron-H hybrid with dual KV + recurrent state carry #3344, feat(xla): gated delta-rule primitive (chunked prefill + step decode) #3352)
- feat(xla): Kimi-Linear (KDA delta + MLA attention + sigmoid MoE) #3354 Kimi-Linear (depends on feat(xla): Nemotron-H hybrid with dual KV + recurrent state carry #3344, feat(xla): sigmoid score-correction MoE router and relu2 experts #3345, feat(xla): gated delta-rule primitive (chunked prefill + step decode) #3352)
- feat(xla): RWKV7 (WKV7 generalized delta kernel + token-shift state) #3355 RWKV7 (depends on feat(xla): per-slot recurrent state; Mamba2 serves via mlxcel-server #3340)
- feat(xla): RecurrentGemma (RG-LRU + local sliding attention) #3356 RecurrentGemma (depends on feat(xla): Nemotron-H hybrid with dual KV + recurrent state carry #3344, feat(xla): Mamba1 selective scan; Mamba and Falcon-Mamba end to end #3348)
- test(xla): validate Phase 4 families on IREE-CUDA (GB10) #3357 Phase 4 families on IREE-CUDA (depends on feat(xla): gated delta-rule primitive (chunked prefill + step decode) #3352, feat(xla): Qwen3-Next and Qwen3.5 text hybrids (GatedDeltaNet) #3353, feat(xla): Kimi-Linear (KDA delta + MLA attention + sigmoid MoE) #3354, feat(xla): RWKV7 (WKV7 generalized delta kernel + token-shift state) #3355, feat(xla): RecurrentGemma (RG-LRU + local sliding attention) #3356)
- test(xla): validate Phase 4 families on IREE-Metal (macOS) #3358 Phase 4 families on IREE-Metal (depends on feat(xla): gated delta-rule primitive (chunked prefill + step decode) #3352, feat(xla): Qwen3-Next and Qwen3.5 text hybrids (GatedDeltaNet) #3353, feat(xla): Kimi-Linear (KDA delta + MLA attention + sigmoid MoE) #3354, feat(xla): RWKV7 (WKV7 generalized delta kernel + token-shift state) #3355, feat(xla): RecurrentGemma (RG-LRU + local sliding attention) #3356)
Acceptance Criteria
- The selective-scan primitive and the per-slot state carry are implemented and covered by the reference-equivalence gate.
- Mamba2 loads and generates via the CLI
MLXCEL_BACKEND=xlapath and serves viamlxcel-server, token-exact single-seq vs the HF fp32 oracle and reference-exact serve. - At least one hybrid family (Nemotron-H) validates the dual KV + state carry end to end.
- The OpenXLA recurrent path never participates in prefix-hash sharing (the recurrent state cannot be reconstructed from a token-prefix hash), matching the MLX carve-out in
src/server/prompt_cache/hybrid_ssm.rs.
Technical Considerations
- Parent epic: epic: OpenXLA backend architecture-coverage parity with the MLX engine #493. Scoping design: design: scope the SSM / hybrid / recurrent track (Mamba2, Jamba, RWKV7, Qwen3-Next, and more) #502 (
spike/openxla/SSM_HYBRID_DESIGN.md). - The prefill scan lowering (chunked-SSD or associative) on IREE-CUDA / Metal is the one genuinely new graph problem and must be spike-validated first, exactly as Stage 2a validated the ragged KV write.
- The recurrence may need f32 scan accumulation even on the f16 GPU precision path for numerical stability; the epic's sub-0.01-logit near-tie tolerance applies.
- Sequencing: Mamba2 then Nemotron-H are the foundation; Qwen3-Next, Kimi-Linear, and RWKV7 are recent and each add their own kernel, so they follow the foundation rather than lead it.
Activity
docs: scope the OpenXLA SSM / hybrid / recurrent track (#502) (#565)
docs: scope the OpenXLA SSM / hybrid / recurrent track (lablup#502) (l…
9 remaining items
feat(xla): add SSM scan primitive with HF oracle and prefill decision (…
feat(xla): add Mamba2 config, mixer schedule and state-threaded graphs (
feat(xla): thread recurrent state in the shim; Mamba2 generates on xla (
feat(xla): carry per-slot recurrent state in continuous batching (#3372)
fix(xla): keep recurrent models out of prefix-hash caches (#3379)
inureyes commentedon Nov 24, 2026
Progress: phases 1 and 2 merged (ROCm gfx1151)
Phases 3 and 4 and the CUDA/Metal lowering checks are still open, so this epic stays open.
mlxcel-serverserves Mamba2.HYBRID_SSM_MODEL_TYPESlist widened with falcon_h1, plamo2, qwen3_5 and granitemoehybrid).MLXCEL_XLA_PRECISIONstill overrides this. Cost on the serve gate for mamba2-130m on hip: batched throughput 285.6 → 123.7 tok/s.models/hf/mamba2-130m):validate_arch.shserve gate: reference-exact.xla_batch_bench: passes with cancel, with buckets, and at B=8.mlxcel-serverrequests: each equals its CLI output.inureyes commentedon Dec 1, 2026
Phase 4 implementation complete
Six of the eight nodes that were open at the start of this run are implemented, merged and closed. The two remaining are the Metal validation units, which cannot run on the hosts available to this run.
Implemented this run
69740c50dlocal-taskandhip, both gate modesddff4a32dhipfed36d6cehip3df900ddehip; synthetic Qwen3-Next exactfc4a1a2belocal-taskandhip; KDA probe at production KDA geometry within 5e-5d0ea5e782iree_linalg_ext.scatteracross 2,326 dispatch modulesAlready done before this run and skipped: #3337 through #3350.
Still open
Both need a macOS host. The run had a Linux GB10 (CUDA) and a ROCm gfx1151 host, so neither can be executed here. No attempt was made to fake them.
Contract gates
verify-env-var-docs,verify-used-by,verify-versionsandverify-kernel-dtype-keyspass on the finalmain, and themlxcel-xlalibrary suite is green.mainwas also red on two of those gates for a while during this run, from #3603 and #3610; that was found, verified on a pristine checkout and fixed in #3618.Findings that need follow-up work
models/hf/kimi-linear-tiny, and no hash ties that directory to the committed fixture. fix(ci): regenerate the seeded RWKV7 checkpoint on demand #3611 solved the same problem for RWKV7 by regenerating the seeded checkpoint on demand; the same treatment would close this.Process note
Merging the five Phase 4 families serially cost three full conflict-resolution rounds against the shared registration seams (
config.rs,model_recurrent.rs,recurrent_config.rs,weights.rs,model.rs,check_env_var_docs.py), because each branch was cut before its siblings landed. A staging branch for the wave, or landing the seam registrations once up front, would have removed most of that cost without changing any result.