Repository navigation
feat(xla): add Jamba hybrid support - #3448
Conversation
Jamba interleaves Mamba1 and attention blocks and ends every block in a dense or softmax-routed MoE FFN. The emitter rejected model_type jamba, and every recurrent layer was assumed to be a pure SSM block without an FFN. - jamba_config parses the HF JambaConfig: attention and expert schedules from their period/offset, Mamba1 with learned dt/B/C RMSNorms, no RoPE, and HF routing (softmax over all experts, top-k, no renormalization). num_experts = 1 keeps every FFN dense. - SsmKind::Mamba1 now carries a BcdtNorm (None, Weightless, Weighted). Falcon-Mamba stays Weightless and emits the same ops; Jamba takes dt_layernorm, b_layernorm and c_layernorm after D. - A recurrent layer with an FFN goes through the general layer path (mixer weights last, pre_ff_layernorm as the post-mixer norm). Pure SSM layers keep the short list, so existing goldens are byte-identical. - The WeightScheme::Jamba names reuse Falcon-H1's outer names, read the MoE router as feed_forward.router, and the checkpoint cross-check validates mixer norms, dense FFNs and stacked experts. - A seeded four-block MoE fixture generator, registered goldens, emitter tests, an ignored device parity test, and a prompt-cache guard test for Jamba. Refs #3349
The decode compile adds --iree-dispatch-creation-enable-aggressive-fusion for every dense config (#3043). With a softmax MoE router it fuses the softmax with the tuple-reduction top-k argmax into one dispatch that llvm-cpu and CUDA cannot lower ('vector.store' op write affecting operations on global resources are restricted to workgroup distributed contexts, IREE 3.12.0rc20260721). The Jamba MoE ragged decode failed this way on local-task, and the committed Qwen2-MoE and OLMoE ragged goldens fail the same way with the flag and compile without it. A config with a softmax-routed MoE now keeps the compiler defaults for its decode, like Gemma3n. Sigmoid routing (#3411) already uses a single-result argmax and keeps the flag, and no emitted graph changes. Refs #3349
Logs from runtime source 76a3dc4 on NVIDIA GB10 (IREE 3.12.0rc20260721, f32): validate_arch.sh batch 4 / requests 8 on the real AI21-Jamba-Reasoning-3B checkpoint (registered goldens, 40/40 HF oracle tokens, 170 reference-exact batched tokens), the 40-token engine test, CLI 40/40 plus four concurrent non-streaming and SSE completions equal to CLI stdout, and the seeded MoE fixture on local-task and CUDA (ragged logits within 3e-4 of HF, CLI 12/12, oracle check and batch bench exact). provenance.json lists every command, binary hash, and what was not verified. Refs #3349
The decode-flag unit test lives in an iree-gated module whose test binary cannot link on its own (the runtime archives are linked by the root crate), so it was only type-checked. The softmax-router predicate moves to Config::has_softmax_moe, which the default lib tests now exercise for Jamba MoE, dense Jamba, Qwen2-MoE, OLMoE, Llama, and sigmoid-routed Nemotron-H. Behaviour is unchanged. Also records that the raw per-expert HF MoE layout is refused at load with a missing switch_mlp tensor error. Refs #3349
Record the weighted dt/B/C norm design, HF routing choice, the softmax-MoE decode fusion exemption (Qwen2-MoE and OLMoE ragged decode goldens also fail to compile with aggressive fusion on main), the synthetic MoE fixture, CUDA and CPU acceptance results, and the ROCm handoff.
4dc7da5 to
b9b5545
Compare
The branch was rebased onto main 01e6516 (Falcon-H1 plain RoPE #3452, Plamo2 #3449). The integrated-* logs come from runtime source b9b5545 on NVIDIA GB10: every registered golden byte-exact, clippy --all-targets clean, the Jamba 3B validate_arch gate, the 40-token engine test, CLI 40/40 and 8/8 concurrent server parity, and the Jamba synthetic MoE parity on CUDA and local-task. The Plamo2, Falcon-H1, Mamba SSM and Nemotron-H CUDA suites pass too. The provenance and the report validation sections name the new head. Refs #3349
ROCm gfx1151 validation at
|
| item | result |
|---|---|
(1) validate_arch.sh --model models/hf/jamba-3b --device hip --batch 4 --requests 8 --maxcap 24 --oracle spike/openxla/jamba_reference/hf-f32-oracle.json |
exit 0: structural PASS, 40/40 token-exact, serve reference-exact (8 requests, 170 tokens) |
(2) jamba_moe_fixture.py then jamba_moe_hf_synthetic_parity |
pass: 4 cases x 8 steps match HF on hip, max abs 2.98e-6; generator controls: norm-weight 0.222, renorm 0.020 |
(3) falcon_h1_cli_server_check.py --device hip --model models/hf/jamba-3b --oracle ... --checkpoint-revision 75243704... |
CLI 40/40 token-exact; 4 HTTP and 4 SSE concurrent completions equal the displayed CLI text and token count (8/8) |
(4) xla_plamo2 --ignored (fixtures from the #3449 run) |
3/3, same numbers as at 68e4c47a (synthetic 1.01e-5, window probe worst 5.5e-6, 40/40 tokens) |
(4) xla_falcon_h1 --ignored (fixtures from the #3452 run) |
3/3, same numbers as at 6a7d3968 (long positions worst 8.39e-5, argmax all match, 40 tokens) |
(5) Softmax-routed MoE decode without aggressive fusion
There is no real Qwen2-MoE or OLMoE checkpoint on this host, so I checked it two ways:
- Committed goldens, compiled for gfx1151 with
--iree-input-type=stablehlo --iree-hal-target-device=hip --iree-rocm-target=gfx1151.decode.mliranddecode_ragged_logits_b4.mlirforqwen2-moe-tinyandolmoe-tinyall compile without the fusion flag. As a control, with--iree-dispatch-creation-enable-aggressive-fusionadded, bothdecode.mlirstill compile but both ragged b4 goldens fail on ROCm too ('vector.transfer_write' op write affecting operations on global resources are restricted to workgroup distributed contexts). - End-to-end on hip. I built tiny random checkpoints (seed 3448) from the two asset configs: an HF directory for the HF fp32 oracle (prompt
w1 w2 w3 w4 w5, 40 tokens, minimum top-2 gap 3.8e-3 and 5.8e-3) and the same weights restacked into theswitch_mlplayout for the XLA loader.validate_arch.sh --device hip --batch 4 --requests 8 --maxcap 24 --oracle <that oracle>exits 0 for both: 40/40 token-exact single-sequence, serve reference-exact across 8 requests through the ragged b4 decode.
Binaries for (3) were the test-fast build at the head (mlxcel f7286bd6…, mlxcel-server 28f6db81…). Commands, logs, the tiny-checkpoint builder and oracles are in acceptance/pr3448/a3bd4e828d166f7d70c444dd557c59ea9af7d423/ on the ROCm host. Nothing was pushed or merged.
Summary
Adds Jamba (
model_type: jamba) to the OpenXLA/IREE backend: Mamba1 blocks with learned dt/B/C RMSNorms, attention blocks without RoPE, and a dense or softmax-routed MoE FFN after every block.SsmKind::Mamba1carriesBcdtNorm(None,Weightless,Weighted). Falcon-Mamba stays weightless with an unchanged op sequence; Jamba readsdt_layernorm,b_layernormandc_layernorm.pre_ff_layernormas the post-mixer norm). Pure SSM layers keep their short list, so every existing golden is byte-identical.JambaSparseMoeBlock: softmax over all experts, top-k, no renormalization. The MLX reference (src/models/jamba.rs) renormalizes the selected weights; that path is not changed here.switch_mlplayout withfeed_forward.router. Raw per-expert HF checkpoints are refused at load with a missingswitch_mlptensor error (the real 3B checkpoint is dense).Config::has_softmax_moe): with it, IREE 3.12.0rc20260721 cannot lower the fused router softmax and top-k argmax on llvm-cpu or CUDA. This changes the decode compile flags for every softmax-routed MoE family, not only Jamba: the committed Qwen2-MoE and OLMoE ragged goldens fail to compile with the flag and compile without it. No real Qwen2-MoE or OLMoE checkpoint was re-run here, and their decode throughput without the flag is unmeasured.Test plan
Rebased onto main
01e6516b(Falcon-H1 plain RoPE #3452, Plamo2 #3449). Integrated runtime sourceb9b5545a, with fresh release binaries, re-passed on GB10 CUDA: every registered golden byte-exact (PLAMO2, FALCON_H1, JAMBA included),clippy -p mlxcel-xla --all-targets -D warnings, guard tests 9/9, Jamba 3Bvalidate_arch.shb4 n8, the 40-token engine test, CLI 40/40, server 8/8, and Jamba synthetic parity on CUDA and local-task. The Plamo2, Falcon-H1, Mamba SSM single-seq/state-carry and Nemotron-H--ignoredsuites also passed on CUDA. Logs:spike/openxla/jamba_reference/integrated-*. The rows below are from the first run at76a3dc4c.Device runs used release binaries built at
76a3dc4c; later commits only move the softmax-MoE predicate ontoConfig(same behaviour, local-task parity rerun) and add evidence on NVIDIA GB10, IREE 3.12.0rc20260721, f32. Logs, commands and binary hashes are inspike/openxla/jamba_reference/.cargo test -p mlxcel-xla --lib(573 passed, every previous golden byte-identical), fmt, clippy-D warnings;check_env_var_docs.py(plus 15 pytest cases) andcheck_used_by.pyan_emitter_loadable_jamba_gets_no_prompt_cache_or_apc(8/8 guard tests)validate_arch.sh --device cuda --batch 4 --requests 8 --maxcap 24exits 0 (goldens, 40/40 HF oracle tokens, 170 reference-exact batched tokens); engine test 40/40xla_oracle_checktoken-exact,xla_batch_benchreference-exact (B=4, N=8)softmax_moe_selects_the_unfused_decode_compileruns in the default lib tests. The iree-gatedsoftmax_moe_decode_drops_aggressive_fusionis type-checked only, since that test binary cannot link without the root crate.--features iree,test-supportreports four pre-existingprivate_interfaceserrors inIreeRaggedLlamaprefill methods that this branch does not touch.Closes #3349