Skip to content

feat(xla): add Nemotron-H hybrid KV and recurrent state carry - #3408

Merged
inureyes merged 7 commits into
mainfrom
feature/issue-3344-nemotron-h-hybrid
Nov 24, 2026
Merged

inureyes merged 7 commits into
mainfrom
feature/issue-3344-nemotron-h-hybrid

Conversation

@inureyes

@inureyes inureyes commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Nemotron-H now parses its hybrid schedule and emits NoPE attention, grouped Mamba2, and relu2-only blocks. Prefill, single-sequence decode, and ragged decode carry compact attention-only KV alongside recurrent state; checkpoint validation and weight ordering follow the same schedule. Recurrent configurations retain the f32 default and prompt-cache/APC exclusion.

The synthetic fixture exercises two SSM groups, two KV heads, unequal attention and hidden widths, staggered admission, slot recycling, torn stores, and failed-decode invalidation. MoE E blocks still explicitly require #3345.

Validation: XLA and IREE/test-support runtime checks pass; five hybrid structural tests, all registered byte-exact goldens, 27 recurrent regression tests, and all five synthetic IREE tests pass on both local-task and CUDA (NVIDIA GB10, driver 580.178.04), with the latter run at 93ddebad382478540fdfc987fbca655744be941d. The partial-store test covers failure after K and after both KV plus the first SSM tensor. Modified Rust files pass formatting. Focused XLA-library clippy passes with -D warnings. The complete cargo test --profile test-fast -p mlxcel-xla --lib regression run passes 539 tests with 21 ignored; device gates are recorded separately.

Real Nemotron-H 4B CUDA execution at 93ddebad382478540fdfc987fbca655744be941d matches the independent HF fp32 oracle 40/40. B4 with eight requests also passes against single-sequence references for all 170 generated tokens. These runs use context 256 and the test-fast build profile; batch throughput was 4.974 tok/s versus 6.02 sequential, so no performance improvement is claimed. Raw logs and bilingual technical reports are committed. The later documentation-only commit does not change tested executable code.

The CLI also matches the HF oracle 40/40. Four concurrent HTTP completions match separately captured CLI text and token counts (24 generated tokens each); the API does not expose token IDs, so no HTTP token-ID claim is made. Server settings were B4, --ctx-size 2048, and explicit XLA capacity 256 with prompt caching/APC disabled. CUDA Mamba2 regressions pass (xla_ssm_single_seq: 6; xla_ssm_state_carry: 5), and the new prompt-cache exclusion unit test passes. Logs and reproducible commands are committed.

ROCm gfx1151 acceptance passed independently at executable source 93ddebad382478540fdfc987fbca655744be941d: regenerated HF oracle, IREE-HIP and CLI 40/40, B4/N8, four concurrent streaming HTTP text comparisons, hybrid tests, SSM probes, and Mamba2 synthetic/real-checkpoint regressions. ROCm HTTP IDs and usage counts were not collected. See the acceptance record. Rebase onto current main changes no XLA executable, state, shim, or server source relative to the validated source; the XLA difference is a cache-path unit-test portability correction. The official checkpoint is nvidia/Nemotron-H-4B-Base-8K at faba3b731ad7ea5781b9518ae75fb610a94affcf. Its checkpoint chunk size is preserved. An independent HF fp32 CPU 40-token oracle and provenance are committed under spike/openxla/nemotron_h_reference/; run HF and XLA f32 sequentially.

ROCm validation instructions are in spike/openxla/NEMOTRON_H_VALIDATION.md. Record the exact PR HEAD for every result; later changes to config, graph, weights, or the shim invalidate numerical results from older heads.

Closes #3344

@inureyes inureyes added status:review Under review type:enhancement New features, capabilities, or significant additions priority:high High priority area:architecture Architecture and code structure changes area:inference Generation, sampling, decoding (incl. speculative, DRY) labels Nov 24, 2026
@inureyes

Copy link
Copy Markdown
Member Author

ROCm gfx1151 validation passed at executable HEAD 93ddebad382478540fdfc987fbca655744be941d. Current observed HEAD e145049bd18d18a1bad28ad89b075795421a2e2e differs only in documentation and CUDA evidence, not executable source.

  • Official checkpoint revision faba3b731ad7ea5781b9518ae75fb610a94affcf; native HF CPU fp32 oracle regenerated with torch 2.12.1+cpu / transformers 5.12.1 and matched the committed 40-token reference.
  • IREE-HIP f32 real-model oracle and CLI: 40/40 token IDs match HF. B4/N8: all 170 tokens match per-request single-sequence references.
  • Four concurrent streaming /v1/completions, distinct prompts, max_tokens=40: all rendered outputs match independently captured CLI references. HTTP token IDs and usage counts were not collected, so this is text parity, not HTTP ID parity.
  • Hybrid tests: 5/5 on HIP and 5/5 on local-task. SSM probe: 11 cases pass on each backend. Mamba2 HIP regressions: 6 single-sequence + 5 state-carry tests; real mamba2-130m oracle 40/40 and B4/N8 also pass.
  • XLA library: 539 passed, 21 ignored, including registered goldens. Formatting and focused XLA-library clippy pass.

All builds/device work used scripts/rocm_gpu_guard.sh --hold; oracle and model runs were sequential. Runtime binaries used release with xla-iree,test-utils; no performance claim. The initial server context=1024 setup was rejected before inference; context=2048 passed. Logs confirm prompt cache/APC disabled and IREE device=hip.

ROCm evidence: /home/devops/Development/mlxcel/acceptance/pr3408/93ddebad382478540fdfc987fbca655744be941d/ contains commands, exit codes, oracle IDs, comparisons, and logs. No implementation edits, issue closure, or merge performed. Later emitter/state/shim changes require affected gates to be rerun.

Map attention blocks to compact KV rows while threading Mamba2 state through prefill and both decode engines. Add schedule-aware weights and checkpoint validation, grouped SSM norm, and relu2-only blocks with explicit rejection of the deferred MoE router.

The library and IREE runtime compile locally. Synthetic structural and execution gates are provided; real-model ROCm token, CLI and serve acceptance remains pending.

Refs #3344
Honor the checkpoint's SSD chunk size so the real 4B model retains its HF reduction partition. Make the tiny fixture's five blocks and chunk size explicit, add parser regression coverage, and attach the independent HF fp32 token oracle with reproducible provenance.

Five targeted structural tests pass. The original synthetic integration target passed all five local-task tests; ROCm and real-model XLA parity remain pending.

Refs #3344
The existing failure hook stopped after K on hybrids and never reached the recurrent-state writes. Add a test-only mode that fails after KV and the first SSM tensor, then verify that both partial-store cases invalidate the slot and recover through a fresh admit.

All five synthetic hybrid tests pass on IREE local-task, including both injected failure modes. Production graphs and numerical behavior are unchanged.

Refs #3344
Record the hybrid state-carry design, independent HF fp32 oracle comparison, and B4 eight-request CUDA parity at 93ddeba. Keep CLI/server, Mamba2 hardware regressions, and ROCm acceptance explicitly pending.

Refs #3344
Capture CLI token parity, overlapping HTTP completion parity, Mamba2 and hybrid regressions, and prompt-cache exclusion at source `93ddebad`. Preserve the exact result and provenance artifacts while leaving ROCm acceptance pending.

Validation:

- Captured JSON artifacts match their source files and parse with `jq`
- English, Korean, and validation documents pass body validation

Refs #3344
Distinguish the six-test single-sequence target, five-test Mamba state-carry target, and separate five-test hybrid target. Add the missing single-sequence reproduction command and label each captured result explicitly.

Validation:

- English, Korean, and validation documents pass body validation
- Evidence counts match the captured CUDA logs

Refs #3344
Record the independently reported gfx1151 acceptance at executable source 93ddeba, including HF/CLI token parity, batching, streaming HTTP text parity, and recurrent regressions. Keep the HTTP evidence boundary and cancelled remote CI explicit.

Refs #3344
@inureyes
inureyes force-pushed the feature/issue-3344-nemotron-h-hybrid branch from e145049 to a6ccf54 Compare November 24, 2026 17:04
@inureyes inureyes added status:done Completed and removed status:review Under review labels Nov 24, 2026
@inureyes
inureyes marked this pull request as ready for review November 24, 2026 17:05
@inureyes
inureyes merged commit f874d1f into main Nov 24, 2026
26 of 33 checks passed
@inureyes
inureyes deleted the feature/issue-3344-nemotron-h-hybrid branch November 24, 2026 17:12
inureyes added a commit that referenced this pull request Nov 24, 2026
MLXCEL_FREEZE_NEMOTRON_H (added in #3408) makes a cfg(test) test rewrite the committed Nemotron-H StableHLO goldens. It was neither documented nor allowlisted, so check_env_var_docs.py failed on main and turned the env var docs, python tooling and Windows jobs red. It now sits in the allowlist beside MLXCEL_FREEZE_GOLDENS and MLXCEL_FREEZE_MOE.
@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

area:architecture Architecture and code structure changes area:inference Generation, sampling, decoding (incl. speculative, DRY) priority:high High priority status:done Completed type:enhancement New features, capabilities, or significant additions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(xla): Nemotron-H hybrid with dual KV + recurrent state carry

1 participant