Repository navigation
feat(xla): add sigmoid grouped MoE routing - #3411
Conversation
|
ROCm validation preflight at HEAD Reproducer: The first failure is Hardware acceptance is NOT RUN: Logs and command files: |
e145049 to
a6ccf54
Compare
Add configurable softmax or sigmoid routing and SwiGLU or relu2 expert schemas to the OpenXLA MoE primitive. Parse Nemotron-H E blocks into an exact layer mask, load correction-bias and relu2/shared tensors, and preserve existing softmax graph schemas. Validated with the mlxcel-xla library compile check and targeted test-fast MoE suite. Refs #3345
Match Transformers normalization semantics, reject impossible grouped routing and unsupported latent shapes, and exercise the E block through local-task and ROCm-capable oracles. Add a tokenizer-backed tiny full-model fixture for external HIP acceptance without claiming 30B memory or throughput validation. Refs #3345
e2334fb to
c6ecdab
Compare
|
UPDATED HANDOFF: the E-checkpoint loader and production-fusion compiler failures reported at Local runtime evidence at executable-code parent Set the HIP device before every build/test so the integration target cannot silently use local-task: test "$(git rev-parse HEAD)" = bf8188d20177cde215ca1b54c6444b86396bd8bd
eval "$(scripts/iree/setup-rocm.sh --env)"
export MLXCEL_XLA_DEVICE=hip MLXCEL_XLA_ROCM_TARGET=gfx1151 MLXCEL_XLA_PRECISION=f32
export OPENSSL_INCLUDE_DIR=/usr/include OPENSSL_LIB_DIR=/usr/lib/x86_64-linux-gnu CARGO_BUILD_JOBS=6
export MLXCEL_ORACLE_PYTHON=spike/openxla/.venv/bin/python
scripts/rocm_gpu_guard.sh --hold -- cargo build --release --features xla-iree --bin mlxcel --example xla_oracle_check --example xla_batch_benchRun the primitive HIP oracle and the corrected E-bearing scripts/rocm_gpu_guard.sh --hold -- "$MLXCEL_ORACLE_PYTHON" spike/openxla/moe_oracle.py --device hip --rocm-target gfx1151
"$MLXCEL_ORACLE_PYTHON" spike/openxla/nemotron_h_moe_fixture.py --out /tmp/nemotron-h-moe-tiny
scripts/rocm_gpu_guard.sh --hold -- cargo test --release --features xla-iree,test-utils --test xla_hybrid_nemotron_h -- --ignored --test-threads=1
scripts/rocm_gpu_guard.sh --hold -- target/release/examples/xla_oracle_check --model /tmp/nemotron-h-moe-tiny/mlx --oracle /tmp/nemotron-h-moe-tiny/hf-f32-oracle.json --device hip
scripts/rocm_gpu_guard.sh --hold -- target/release/examples/xla_batch_bench --model /tmp/nemotron-h-moe-tiny/mlx --prompts /tmp/nemotron-h-moe-tiny/hf-f32-oracle.json --device hip --batch 4 --requests 8 --maxcap 12
scripts/rocm_gpu_guard.sh --hold -- env MLXCEL_BACKEND=xla MLXCEL_PRINT_TOKEN_IDS=1 target/release/mlxcel generate -m /tmp/nemotron-h-moe-tiny/mlx -p 'tok4 tok17 tok5 tok29 tok11 tok8' -n 12 --temp 0 --no-chat-templateRequire the primitive max-absolute differences to stay below Because the corrected SHA changes the emitter, rerun the #3344 real Nemotron-H-4B and Mamba2 gates from scripts/rocm_gpu_guard.sh --hold -- target/release/examples/xla_oracle_check --model models/hf/nemotron-h-4b --oracle spike/openxla/nemotron_h_reference/hf-f32-oracle.json --device hip
scripts/rocm_gpu_guard.sh --hold -- target/release/examples/xla_batch_bench --model models/hf/nemotron-h-4b --prompts spike/openxla/nemotron_h_reference/hf-f32-oracle.json --device hip --batch 4 --requests 8 --maxcap 24
scripts/rocm_gpu_guard.sh --hold -- env MLXCEL_BACKEND=xla MLXCEL_PRINT_TOKEN_IDS=1 MLXCEL_XLA_CONTEXT_CAPACITY=256 target/release/mlxcel generate -m models/hf/nemotron-h-4b -p 'The capital of France is' -n 40 --temp 0 --no-chat-template
scripts/rocm_gpu_guard.sh --hold -- cargo test --release --features xla-iree,test-utils --test xla_hybrid_nemotron_h -- --ignored --test-threads=1
scripts/rocm_gpu_guard.sh --hold -- cargo test --release --features xla-iree,test-utils --test xla_ssm_single_seq -- --ignored --test-threads=1
scripts/rocm_gpu_guard.sh --hold -- cargo test --release --features xla-iree,test-utils --test xla_ssm_state_carry -- --ignored --test-threads=1Require the real-model oracle and CLI to match all 40 committed independent HF IDs, B4/N8 to remain reference-exact, and all hybrid/Mamba2 cases to pass. Please report counts and token IDs separately from source-only checks. The prior ROCm investigation and artifact location remain recorded in #3411 (comment). |
Reserve EOS at a unique token ID and fail fixture generation if the fixed reference emits it, so the CLI and oracle share the same max-token stop policy. Validate the tokenizer ID bijection and require the manual eager oracle to match Transformers native greedy generation. Refs #3345
|
ROCm validation at exact HEAD BLOCKER: whole-model loading rejects the new E-block fixture with Cause: Reproducer after generating Environment note: direct MoE script invocation initially stopped at missing IREE Python modules. The successful oracle runs use a validation-only adapter |
Validate Nemotron-H E blocks against their routed and shared expert schema instead of dense MLP names, including affine-packed companion tensors. Lower grouped sigmoid routing argmax through compiler-compatible single-result reductions while preserving NaN and lower-index tie semantics. Keep the end-to-end acceptance fixture's independent output head and cover checkpoint loading with a complete synthetic model directory. Refs #3345
|
Follow-up to the ROCm blocker report in #3411 (comment): the E-checkpoint loader and grouped-router compiler failures are fixed in At the executable-code parent, the host library suite is 543 passed / 21 ignored, the seven local-task MoE oracle cases pass, guarded CUDA hybrid runtime is 5/5, and the tokenizer-backed CLI matches all 12 independent HF fp32 IDs. At the PR head, the environment-variable guard and its 15 focused Python tests pass. The corrected exact-head ROCm commands, including the required #3344 real-4B and Mamba2 reruns, are in the updated handoff: #3411 (comment). The earlier c6 HIP results remain useful diagnosis but are not acceptance for the changed emitter. HIP validation remains pending, and the PR stays draft. |
Classify the opt-in Nemotron-H golden rewrite switch with the existing fixture-authoring environment variables so the documentation guard does not treat it as an operator setting. Refs #3345
|
ROCm rerun PASS at exact HEAD Library 543 passed / 21 ignored, goldens, fmt and focused clippy pass. All seven primitive oracle cases pass on CPU and HIP. Hybrid integration is 5/5 on each device. The E-bearing fixture matches HF and parsed CLI IDs 12/12: The initial server comparison was a harness false failure: re-decoding CLI IDs omitted Evidence: |
## Summary - add an f32 diagonal selective scan and Mamba1 mixer for prefill and batched decode - keep prefill chunk-bounded and compile-efficient with a log-depth affine prefix scan inside each 128-row chunk - parse and validate Mamba and Falcon-Mamba configs, legacy bias aliases, checkpoint tensors, weight names, and threaded `[L,D,N]` state - extend the independent Transformers oracle and whole-model IREE harness, including synthetic Falcon-Mamba B/C/dt RMS normalization - register a compact whole-model Mamba decode golden and add English and Korean technical reports ## Correctness and integration fixes - honor the original `bias` / `conv_bias` aliases while giving canonical `use_bias` / `use_conv_bias` keys precedence - reject unsupported `rms_norm = false` configs and require every active block or mixer epsilon to be finite and positive - replace the row-by-row prefill unroll with a chunk-local, log-depth associative affine scan - construct `log_a` and `bx` inside the mixer chunk loop, so capacity 4096 never creates a full `[4096,D,N]` producer - preserve the merged Nemotron-H compact KV indexing, grouped normalization, hybrid state carry, MoE paths, and registered Mamba2/Nemotron-H golden bytes - document `MLXCEL_FREEZE_MAMBA1` and remove the duplicate Nemotron-H allowlist entry that caused the hosted environment-variable documentation jobs to fail ## Integrated validation The executable source for the final integrated checks is `abd1520fd669624cb668bd558b98e332d0955093`, based on merged PR #3411. The final branch adds only the bilingual reports after that source commit. - `cargo fmt --all -- --check` - `cargo clippy -p mlxcel-xla --lib -- -D warnings` - `cargo test -p mlxcel-xla --lib -- --test-threads=4` (555 passed, 21 ignored) - `cargo test -p mlxcel-xla --lib validation::tests::registered_fixtures_are_byte_exact -- --exact --test-threads=1` (Mamba1, Mamba2, and Nemotron-H registered goldens byte-exact) - `python3 scripts/ci/check_env_var_docs.py` (396 discovered, 265 documented, 131 allowlisted) - `python3 -m unittest discover -s tests -p 'test_check_env_var_docs.py' -v` (15 passed) - official `state-spaces/mamba-130m-hf@1e76775f628fbf1350fbe4dbb3d971ba64af25a1` on IREE local-task: whole prefill, split prefill, and decode match the independent Transformers 5.12.1 CPU fp32 reference; worst max-abs `1.488e-4`, same argmax - seeded synthetic `FalconMambaForCausalLM` on IREE local-task: whole prefill, split prefill, and decode match the independent reference; worst max-abs `3.725e-7`, same argmax - capacity 4096, `D=1536`, `N=16`: no `[4096,D,N]` tensor; 3,116-line / 320-KiB StableHLO; direct CPU compile 10.64 s at 228.2 MiB peak RSS; run 0.862 s ## Exact integrated CUDA acceptance On NVIDIA GB10, source `abd1520fd669624cb668bd558b98e332d0955093` passed the capacity-4096 CUDA probe under `gpu-lock`: - compile 5.03 s, run 0.319 s - process peak RSS 203200 KiB - independent oracle max-abs: output `3.651e-7`, recurrent state `1.141e-8`, convolution state `1.371e-6` - timing log: `/tmp/epic564-plan/3348-cuda-cap4096-integrated-abd1520f-time.log` - result bundle: `/tmp/issue3348-cap4096-integrated-abd1520f` This establishes correctness and compile footprint, not a throughput claim. ## ROCm acceptance and source boundary External ROCm gfx1151 acceptance passed at exact source `3a1688f7daaf9bae8bea09997b804e6509357c25`: - library tests, formatting, clippy, and registered goldens - 12 local-task and HIP mixer-probe cases, including capacity 4096 - real Mamba and synthetic Falcon reference and CLI parity (40/40 tokens) - B4/N8 batching, cancellation, slot recycling, and four concurrent server requests - five hybrid tests, Mamba2 synthetic and real regressions, and real Nemotron-H 4B integration checks All ROCm device/build work used the ROCm guard. Server checks compare rendered text because the HTTP API does not expose token IDs. Optimized `test-fast` binaries make no performance claim. Full commands and provenance are in the [ROCm acceptance record](#3413 (comment)). The later rebase onto PR #3411 did not change the blobs for the Mamba1 scan, parser, recurrent emitter, or Python oracle. It added disjoint Nemotron-H MoE integration and the CI allowlist correction. Full library, golden, lint, environment-variable, and CUDA gates were rerun on the integrated source; ROCm was not rerun after this source-neutral integration, so the exact-SHA evidence boundary is retained here. ## Reports - `TECHNICAL_REPORTS/3413-mamba1-falcon-mamba-selective-scan-20261125.en.md` - `TECHNICAL_REPORTS/3413-mamba1-falcon-mamba-selective-scan-20261125.ko.md` Closes #3348
Add original-HF Falcon-H1 execution with parallel attention/Mamba2 followed by a separately normalized MLP. Preserve HF muP placement, optional SSM normalization, independent head widths/biases, and dual KV/recurrent state across prefill, single decode, and ragged decode. Integration retains #3411 MoE and #3413 Mamba1 behavior. Fix plain CLI completion display losing trailing whitespace: an explicit flush mode preserves raw text while default chat and structured reasoning/tool/Harmony/Muse cleanup remain unchanged. The portable replay compares actual stdout with concurrent non-streaming HTTP and SSE responses; earlier CUDA HTTP evidence compared raw token decoding, not displayed stdout. Validation at integrated runtime source `8c7b4412d37b91807f8d688ba2f3febbc7a7e41f` (base `2e46fc09`): - Full XLA crate: 560 passed / 22 ignored; byte-exact goldens, every-family layouts, fmt, and narrow clippy pass. Environment-docs checker + 15 Python tests pass after classifying two test-only controls. - All 7 display tests and 146 filter tests pass; all 5 CUDA hybrid tests and all 6 Mamba2 tests pass. - CPU/CUDA synthetic norm/ragged/recycle gates and real HF40/40 pass; CUDA CLI40/40 passes. - Strict displayed stdout: 4/4 nonstream + 4/4 SSE text/count matches, including Germany's exact trailing whitespace; overlapping requests and server cleanup verified. External HIP acceptance at `852129eb` passed numerical, real 40-token CLI, batching/recycling, regression, and release architecture gates. Strict displayed CLI/SSE parity was 3/4 because Germany ended in `" \n"`; all four raw token decodes matched. That evidence predates this fix and merged shared recurrent plumbing. Request a final-head ROCm replay with explicit `hip`, `gfx1151`, and `f32` under the ROCm guard; no new HIP run is claimed. Oracle, provenance, logs, portable replay, and instructions are in `spike/openxla/falcon_h1_reference` and `FINDINGS_falcon_h1.md`; bilingual reports document the exact evidence boundaries. HTTP exposes text/counts, not output IDs. Hosted CI is canceled under the local-validation policy. Refs #3346
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
* 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
Add grouped sigmoid routing, correction-bias selection, relu2 routed/shared experts, and validated Nemotron-H E-block checkpoint loading. Compiler-compatible single-result reductions preserve first-NaN and lower-index tie semantics. Existing softmax MoE goldens remain byte-identical.
Runtime source 8466cab passed 543 library tests (21 ignored), seven local-task oracle cases, CUDA hybrid 5/5, and independent HF/CLI 12/12. Head bf8188d adds only a test-switch allowlist correction, with guard and 15 Python tests passing.
ROCm acceptance at bf8188d passes CPU/HIP primitive and hybrid gates, HF/CLI 12/12, B4/N8, cancellation/recycling, and concurrent HTTP rendered-text comparisons. Real Nemotron-H-4B HF/CLI 40/40 and batch plus Mamba2 synthetic/real-model regressions pass. HTTP token IDs were not exposed. Evidence: #3411 (comment).
Hosted CI was intentionally canceled; merge relies on local and reported hardware validation. The final documentation commit changes no executable source. Whole-f32 uploads, dense all-expert execution, real 30B capacity and throughput remain #3350 concerns.
Closes #3345