Repository navigation
XPU: Enable GLM5.1 (GlmMoeDsaForCausalLM) DSA Attention - #24959
Conversation
|
Hi @mingfeima Could you please review the PR? Thanks. |
There was a problem hiding this comment.
Code Review
This pull request introduces XPU support to the KV cache mixin by updating the model runner's pool initialization logic. Specifically, it modifies the conditions for selecting the KV pool class and updates assertions to accommodate NSA models on XPU hardware. I have no feedback to provide.
Co-authored-by: Copilot <[email protected]>
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
# Conflicts: # python/sglang/srt/arg_groups/memory_hook.py
|
/rerun-failed-ci |
|
/rerun-failed-ci |
# Conflicts: # python/sglang/srt/layers/rotary_embedding/base.py
# Conflicts: # python/sglang/kernels/ops/attention/dsa/index_buf_accessor.py # python/sglang/srt/layers/attention/dsa/dsa_indexer.py # python/sglang/srt/mem_cache/memory_pool.py
|
/rerun-failed-ci |
|
DeepSeek-OCR receives
|
|
/rerun-failed-ci |
|
/rerun-failed-ci |
Motivation
GLM5.1 uses Dynamic Sparse Attention (DSA/NSA) with an FP8 indexer that scores KV pages before sparse attention. This PR enables the path on XPU.
Modifications
1. server_args.py
When GLM5.1 (or any DSA model) runs on XPU, automatically set:
decode_attention_backend = "dsa"— putsDeepseekSparseAttnBackendas the decode backend insideHybridAttnBackend, so it can manage the DSA index K-cache and FP8 logit scoring.prefill_attention_backend = "dsa"— We use the dense version of prefill MLA for now since no XPU sparse prefill kernel exists yet in sgl-kernel-xpu.SGLANG_OPT_USE_TOPK_V2— the v2 topk uses TileLang/TVM JIT compilation which requires CUDA.2. hybrid_attn_backend.py
In
HybridAttnBackend, when the selected backend is not the decode backend (i.e. during prefill when Triton is selected), also calldecode_backend.init_forward_metadata()andget_indexer_metadata()from the decode backend. This ensures the DSA decode backend (DeepseekSparseAttnBackend) remains responsible for the DSA indexer even during prefill passes.3. dsa_backend.py
Guard
flashmla_metadatacomputation withnot _is_xpu. Theget_mla_metadatafunction is fromsgl_kernel.flash_mlawhich is CUDA-only.4. dsa/dsa_indexer.py
Replace
torch.cuda.get_device_propertiesandtorch.cuda.mem_get_infowith XPU-aware equivalents in_get_mqa_logits_budget_bytes.5. rotary_embedding/base.py
In
forward_xpu, handle 2D input tensors(N, head_size)for the fallbacksgl_kernel.rotary_embeddingkernel which expects 3D(N, num_heads, head_size). The DSA indexer passes a single-headk_ropeas 2D.6. jit_kernel/dsa/init.py
Guard the CuteDSL import (NVIDIA CUDA DSL) on XPU, matching the existing ROCm guard.
Accuracy Tests
N/A since the original model is too big for BMG.
Speed Tests and Profiling
N/A since the original model is too big for BMG.
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): 🚫 Run #33839554583
Latest PR Test (Extra): ❌ Run #33839554508
Latest PR Test (AMD ROCm 7.2): ❌ Run #33839554544