Repository navigation
[XPU] Fix NemotronH (hybrid mamba2) launch on --device xpu - #32227
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
| or kimi_linear_config(model_runner.model_config) is not None | ||
| or linear_attn_model_spec(model_runner.model_config) is not None | ||
| ): | ||
| elif mambaish_config(model_runner.model_config) is not None: |
There was a problem hiding this comment.
will it break other models?
There was a problem hiding this comment.
|
ci has failure at |
|
@mingfeima . Thanks for letting me know. I have addressed this and test should be passing now. |
sglang project CIs are kind of tricky as you can see a lot of REDs and you need to identify whether your failures are real or they are just failed on other PRs as well. You can also let AI do the job for you, for example https://github.com/mingfeima/sglang/tree/main/.claude/skills/intel-xpu-cpu-review-pr, this saves me a lot of work. anyway still need to be careful :) |
The mamba extra_buffer radix-cache strategy is gated to CUDA/MUSA/NPU/ROCm by a device assertion, so hybrid-Mamba models (e.g. NVIDIA-Nemotron-3-Nano) launched on --device xpu with the default (auto) strategy hit: AssertionError: extra_buffer needs CUDA/MUSA/NPU/ROCm (FLA). The extra_buffer path is FLA/Triton-backed and Triton has an XPU backend, so add is_xpu() to the guard to let the path run on XPU. This unblocks launch; runtime correctness of the FLA extra-buffer kernels on XPU still needs validation (tracked separately).
TritonAttnBackend.__init__ picks v_head_dim via a hybrid-model branch that only checked hybrid_gdn_config / kimi_linear_config / linear_attn_model_spec. NemotronH (and other mamba2 archs: FalconH1, Lfm2, ...) are detected by mamba2_config, not those three, so they fell through to the else branch which indexes layer 0 as full-attention: ValueError: layer_id=0 not in full attention layers: dict_keys([5, 12, 19, 26, 33, 42]) NemotronH's full-attention layers are [5,12,19,26,33,42], so layer 0 is a mamba layer and get_value_buffer(0) raises. Switch the branch to the umbrella mambaish_config(), which unions mamba2 + hybrid-GDN + kimi-linear + linear-attn, so all hybrid linear models take the get_v_head_dim() path. Surfaced bringing up NVIDIA-Nemotron-3-Nano-30B on --device xpu.
TritonAttnBackend.__init__ routes mambaish (mamba2 / hybrid-GDN / kimi-linear / linear-attn) configs through token_to_kv_pool.get_v_head_dim(), but that method only existed on HybridLinearKVPool. When a mamba2 config is served by a plain MHATokenToKVPool (as in the mamba2 attention unit-test fixture), the call raised: AttributeError: 'MHATokenToKVPool' object has no attribute 'get_v_head_dim' Add get_v_head_dim() to MHATokenToKVPool returning self.v_head_dim (uniform across its all-full-attention layers), mirroring HybridLinearKVPool. Inherited by NoOp/PageMajor/MXFP8/FP4 subclasses. Fixes CI failure in TestTritonMamba2BackendCorrectness.test_layout_robustness_cases.
d88f83f to
90a8f6f
Compare
|
failure on base-c-test-8-gpu-h20 seems flaky, check again. |
|
@arathi-hlab could you please help check xpu ci failure? |
Resolve triton_backend.py import conflict: keep mambaish_config (this branch's umbrella hybrid detector) alongside upstream's new is_kimi_k3 import for the use_verify_mla gate.
|
/rerun-failed-ci |
|
haha at last, xpu ci passed... |
…ct#32227) Co-authored-by: Ma Mingfei <mingfei.ma@intel.com>
…ct#32227) Co-authored-by: Ma Mingfei <mingfei.ma@intel.com>
Motivation
Bringing up NVIDIA-Nemotron-3-Nano-30B-A3B (a hybrid Mamba-2 / attention model,
NemotronHForCausalLM) on--device xpufails during server init with two separate,sequential errors. Both are device/arch-coverage gaps rather than kernel bugs.
Error 1 —
extra_buffermamba radix cache asserts out on XPUWith the default
--mamba-radix-cache-strategy auto, the resolver selectsextra_bufferfor supported hybrid archs (Nemotron qualifies). A device assertionthen rejects XPU:
The
extra_bufferpath is FLA/Triton-backed and Triton has an XPU backend, butis_xpu()was simply missing from the guard, so the strategy could never be usedon XPU even where it works.
Error 2 — Triton backend indexes layer 0 as full-attention for a hybrid model
After clearing Error 1, init crashes selecting
v_head_dim:TritonAttnBackend.__init__has a hybrid-model branch that avoids indexing layer 0(which may be a Mamba layer, not full-attention), but it only tested
hybrid_gdn_config/kimi_linear_config/linear_attn_model_spec. NemotronH isdetected by
mamba2_config, which is not in that set, so it fell through to theelsebranch that assumes layer 0 is full-attention. Nemotron's full-attentionlayers are
[5, 12, 19, 26, 33, 42], soget_value_buffer(0)raises. This affectsother
mamba2_configarchs too (FalconH1, Lfm2, ...), not just XPU.Modifications
server_args.py— addis_xpu()to theextra_bufferdevice guard (and tothe assertion message).
triton_backend.py— replace the three-way hybrid check in thev_head_dimselection with the umbrella
mambaish_config(), which unionsmamba2_config(NemotronH/FalconH1/Lfm2/...) +
hybrid_gdn_config+kimi_linear_config+linear-attn specs, so every hybrid-linear model takes the
get_v_head_dim()pathinstead of indexing layer 0. Unused imports removed.
Fix 2 is device-agnostic (fixes the crash on any backend for these archs); fix 1 is
XPU-specific.
Why the fix is in the Triton backend, not the
intel_xpubackendOn XPU this model runs its full-attention layers through
TritonAttnBackend, not theintel_xpubackend. That is by design of the hybrid path, not an oversight:NemotronHForCausalLMis a hybrid Mamba-2 / attention model, so it is wrapped inHybridLinearAttnBackend, whose full-attention sub-backend is selected by device astrtllm_mha(CUDA SM100) /fa3(CUDA SM≥80) /triton(everything else,including XPU). The
intel_xpuattention backend is not currently wired into thehybrid-linear-attention path, so XPU falls to the Triton full-attn sub-backend (Triton
has an XPU backend, so it executes on-device). Hence the crash — and the fix — live in
TritonAttnBackend. Integratingintel_xpuas a hybrid full-attn sub-backend is aseparate, larger enablement effort and out of scope here.
Accuracy / correctness
Draft: fix 1 removes a launch guard for a path whose FLA extra-buffer kernels are
well-exercised on CUDA/ROCm/NPU but new to XPU — reviewers should weigh whether XPU
needs the same validation bar as the other gated backends before this lands.
Fix 2 changes only which detector gates an existing code path; behavior for the
already-covered archs is unchanged.
Checklist / how to reproduce & validate
Repro (before this PR, either error above depending on stage):
With this PR the server initializes past both errors on XPU.
CI States
Latest PR Test (Base): ❌ Run #31546362673
Latest PR Test (Extra): ❌ Run #31546362268