Skip to content

epic: OpenXLA SSM / hybrid / recurrent architecture support (Mamba2, Nemotron-H, Jamba, and more) #564

Open
20 of 22 issues completed

Description

@inureyes

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:

  1. A recurrent/state-space mixing graph primitive (selective scan / linear recurrence) that does not fit the shared attention core.
  2. 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

Phase 2

Phase 3

Phase 4

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=xla path and serves via mlxcel-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

Sub-issues

Sub-issues

20 of 22 Issues completed
Loading 22 sub-issues

Activity

  1. added
    status:ready
    type:enhancement
    priority:low
    area:architecture
    area:inference
    on Jul 1, 2026
  2. self-assigned this
    on Aug 5, 2026
  3. 9 remaining items

  4. inureyes commented on Nov 24, 2026

    @inureyes
    MemberAuthor

    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.

  5. added
    status:in-progress
    and removed
    status:ready
    on Nov 24, 2026
  6. inureyes commented on Dec 1, 2026

    @inureyes
    MemberAuthor

    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

    Issue PR Merge commit Result
    #3352 gated delta-rule primitive #3607 69740c50d probe 11/11 cases within 5e-5 on local-task and hip, both gate modes
    #3355 RWKV7 #3609 ddff4a32d real 0.1B checkpoint token-exact (40/40) and serve reference-exact on hip
    #3356 RecurrentGemma #3606 fed36d6ce real 2B checkpoint token-exact and serve reference-exact on hip
    #3353 Qwen3-Next / Qwen3.5 #3614 3df900dde Qwen3.5-0.8B token-exact against HF fp32 (40/40), serve and 8/8 server exactness on hip; synthetic Qwen3-Next exact
    #3354 Kimi-Linear #3612 fc4a1a2be synthetic checkpoint token-exact and reference-exact on local-task and hip; KDA probe at production KDA geometry within 5e-5
    #3357 Phase 4 on IREE-CUDA #3622 d0ea5e782 all five families token-exact and serve reference-exact on GB10 CUDA, delta probe 11/11 at worst 7.75e-7, zero iree_linalg_ext.scatter across 2,326 dispatch modules

    Already 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-versions and verify-kernel-dtype-keys pass on the final main, and the mlxcel-xla library suite is green. main was 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

    1. The delta primitive has no chunk knob, so per-channel mode cannot scale. At the 48B Kimi-Linear KDA geometry one per-channel prefill plans 798.1 MiB at capacity 256 and 12,739.5 MiB at 4096, which cannot sit beside the weights on a 31 GiB unified host. Chunk reduction (32/16/8, roughly 6.2/3.1/1.5 GiB) or Dk blocking is the fix. It was deliberately not implemented because a non-64 chunk would ship unvalidated, and the primitive has no knob to vary it.
    2. The Kimi-Linear evidence is not reproducible from the repository. Its hip gates loaded 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.
    3. RecurrentGemma's hip unit skipped the real-checkpoint gates on licence grounds, while the CUDA unit ran them. The family's real-checkpoint evidence therefore rests on one host, not two.

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:architecturearea:inferencepriority:lowstatus:in-progresstype:enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions