Skip to content

fix(xla): use plain RoPE for Falcon-H1 - #3452

Merged
inureyes merged 2 commits into
mainfrom
fix/falcon-h1-plain-rope
Nov 26, 2026
Merged

inureyes merged 2 commits into
mainfrom
fix/falcon-h1-plain-rope

Conversation

@inureyes

Copy link
Copy Markdown
Member

Post-merge correction for the Falcon-H1 OpenXLA path from #3414.

The Falcon-H1 config parser spreads Config::llama_3_2_1b() and never set rope, so it inherited Llama3 scaling (factor 32, original context 8192). HF Falcon-H1 uses plain RoPE. Llama3 scaling only changes bands with wavelengths above 2048 tokens, and Tiny90M (rope_theta = 1e11, head width 64) has 24 of 32 frequency pairs there. The 40-token oracle compares tokens only, and the logit gate ran only on the tiny fixtures, where the scaling is a numeric no-op.

  • Falcon-H1 now uses RopeScaling::Plain, with a unit test.
  • A non-default legacy rope_scaling block is now rejected. HF folds it into rope_parameters, but the loader ignored it.
  • falcon_h1_oracle.py --long-model writes native HF fp32 CPU logits for prefixes of 32, 512, 2048, and 3584 tokens. The ignored falcon_h1_original_checkpoint_long_positions test compares them through ragged prefill and decode (max abs below 1e-3, matching argmax).
Prefix Before (origin/main) After
32 5.02e-1 1.16e-4
512 4.41 6.87e-5
2048 4.69 8.96e-5
3584 4.74 1.20e-4

Before the fix, 8 of 16 argmaxes differed. After it, all 16 match. Logs and provenance are in spike/openxla/falcon_h1_reference/ (cpu-long-*.log, long-position-provenance.json).

Audit: the other ..Config::llama_3_2_1b() spreads (Mamba1, Mamba2, Nemotron-H) set rope, rope_theta, tie_word_embeddings, dims, vocab, and layer_mixers explicitly. The remaining base fields are neutral defaults. The dense from_json_str path builds a full literal and maps absent rope_scaling to plain RoPE. Every other use is in test code.

Test plan

  • cargo test -p mlxcel-xla --lib (567 passed), fmt, cargo clippy -p mlxcel-xla --all-targets -- -D warnings
  • tests/xla_falcon_h1.rs on local-task: synthetic parity, 40-token oracle, and the new long-position test
  • Both freeze paths leave all goldens byte-identical
  • check_used_by.py, check_env_var_docs.py
  • CUDA and HIP not rerun

Refs #3346

The Falcon-H1 config parser spreads Config::llama_3_2_1b() and never set rope, so it inherited Llama3 scaling (factor 32, original context 8192). HF Falcon-H1 uses plain RoPE. The scaling only bends bands with wavelengths above 2048 tokens. The 40-token oracle compares tokens only (logits were already 0.50 off at position 31 with every argmax intact), and the logit gate ran only on the tiny fixtures (head width 4, theta 1e4), where the scaling is a numeric no-op. The Tiny90M checkpoint (theta 1e11) diverged by up to 4.7 in logits and flipped 8 of 16 argmaxes at prefixes of 512 to 3584 tokens; after the fix the worst error is 1.2e-4 with all argmaxes matching.

The parser now sets RopeScaling::Plain and also rejects a non-default legacy rope_scaling block, which HF folds into rope_parameters and the loader previously ignored. falcon_h1_oracle.py gains a --long-model mode, and an ignored integration test compares long-position logits against it. Goldens are byte-identical. Evidence and the before/after logs are in spike/openxla/falcon_h1_reference/.

Refs #3346
@inureyes inureyes added type:bug Bug fixes, error corrections, or issue resolutions status:review Under review priority:medium Medium priority labels Nov 26, 2026
On GB10 CUDA the synthetic parity, 40-token oracle and long-position tests pass 3/3; worst long-position logit error is about 6e-5 with every argmax matching up to position 3586.
@inureyes

Copy link
Copy Markdown
Member Author

ROCm gfx1151 validation at 6a7d3968

Head 6a7d3968455bfc030f68b9ae9e75fb2b8a2ee666. Radeon 8060S (gfx1151), IREE 3.12.0rc20260721 @ dc9601f, oracle venv torch 2.12.1+cpu / transformers 5.12.1. Checkpoint tiiuae/Falcon-H1-Tiny-90M-Instruct@e6389502. Fixtures and the long-position oracle came from $MLXCEL_ORACLE_PYTHON spike/openxla/falcon_h1_oracle.py --out <dir> --long-model <checkpoint> (exit 0). The tests ran with MLXCEL_XLA_DEVICE=hip MLXCEL_XLA_ROCM_TARGET=gfx1151 MLXCEL_XLA_PRECISION=f32, the committed falcon_h1_reference/hf-f32-oracle.json, and scripts/rocm_gpu_guard.sh --hold -- cargo test --profile test-fast --features xla-iree,test-utils --test xla_falcon_h1 -- --ignored --nocapture --test-threads=1.

Result: 3 passed, 0 failed.

test result
falcon_h1_hf_synthetic_parity ok
falcon_h1_original_checkpoint_oracle_tokens 40 oracle tokens match on hip
falcon_h1_original_checkpoint_long_positions every prefix and step within 1e-3 with matching argmax (table below)
prefix max abs logit delta over steps 0 to 3 argmax
32 4.58e-5 4/4 match
512 3.24e-5 4/4 match
2048 5.91e-5 4/4 match
3584 8.39e-5 4/4 match

Logs, commands and the generated fixtures are in acceptance/pr3452/6a7d3968455bfc030f68b9ae9e75fb2b8a2ee666/ on the ROCm host. Nothing was pushed or merged.

@inureyes
inureyes merged commit ed85150 into main Nov 26, 2026
27 of 33 checks passed
@inureyes
inureyes deleted the fix/falcon-h1-plain-rope branch November 26, 2026 11:40
@inureyes inureyes added status:done Completed and removed status:review Under review labels Nov 26, 2026
inureyes added a commit that referenced this pull request Nov 26, 2026
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
@inureyes inureyes mentioned this pull request Nov 26, 2026
6 of 7 tasks
inureyes added a commit that referenced this pull request Nov 26, 2026
* feat(xla): add Jamba hybrid Mamba1, attention, and MoE support

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

* fix(xla): compile softmax MoE decodes without aggressive fusion

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

* update(xla): record Jamba CUDA and CPU acceptance evidence

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

* update(xla): test the softmax-MoE decode fusion choice without IREE

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

* docs(xla): add Jamba findings and technical reports

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.

* update(xla): record Jamba acceptance after the Plamo2 rebase

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
@inureyes inureyes added this to the 0.9 milestone Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:medium Medium priority status:done Completed type:bug Bug fixes, error corrections, or issue resolutions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant