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
Phase 1: Foundation
Phase 2: Reference architecture
Phase 3: Hybrid coexistence
Phase 4: Linear-attention / delta and recurrent families
Acceptance Criteria
Technical Considerations
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_jsonrejects every recurrentmodel_typeat the unsupported-architecture error (src/lib/mlxcel-xla/src/emitter/config.rs). The MLX engine already implements all of these families (seesrc/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:
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_kvincsrc/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 onepumpstep.Sub-issues
Phase 1: Foundation
conv1d, plus their IREE-CUDA (GB10 / sm_121) and IREE-Metal lowering, with a token-exact single-layer probe vs an HF reference (mirrors Stage 2a spike-first).emitter/ssm.rs: theconv1d+selective_scangraph primitives, anSsmConfig, and the per-layerlayer_mixersschedule soemit_transformer_layerdispatches attention vs recurrent per layer;weight_specsfor the SSM tensors.sscache/sscache_b+xla_ensure_batch_state, state-threaded prefill-slot and ragged-decode graphs, and the device-side per-slot state seed on admit.Phase 2: Reference architecture
MLXCEL_BACKEND=xla, serves viamlxcel-server, token-exact single-seq vs the HF fp32 oracle, and reference-exact serve (the Stage 2a reference-equivalence gate extended to prove the state carry).Phase 3: Hybrid coexistence
Phase 4: Linear-attention / delta and recurrent families
Acceptance Criteria
MLXCEL_BACKEND=xlapath and serves viamlxcel-server, token-exact single-seq vs the HF fp32 oracle and reference-exact serve.src/server/prompt_cache/hybrid_ssm.rs.Technical Considerations
spike/openxla/SSM_HYBRID_DESIGN.md).