From b0e06359acf94dc7ffb9cd1b8045604ee8a132b5 Mon Sep 17 00:00:00 2001 From: Siyuan Chen <41201609+SYChen123@users.noreply.github.com> Date: Fri, 9 Oct 2026 05:42:16 +0800 Subject: [PATCH] [DSV4.1][PD][5/N] Decode node support DP attention (#40177) --- python/sglang/srt/arg_groups/deepseek_v4_hook.py | 9 ++++----- python/sglang/srt/disaggregation/common/conn.py | 12 ++++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/python/sglang/srt/arg_groups/deepseek_v4_hook.py b/python/sglang/srt/arg_groups/deepseek_v4_hook.py index 280eeaca38..14b9c29553 100644 --- a/python/sglang/srt/arg_groups/deepseek_v4_hook.py +++ b/python/sglang/srt/arg_groups/deepseek_v4_hook.py @@ -17,7 +17,7 @@ from sglang.srt.arg_groups.overrides import ( ) from sglang.srt.environ import envs from sglang.srt.model_executor.cuda_graph_config import Backend, Phase, with_phase -from sglang.srt.runtime_context import attn_dp_enabled_of, get_platform, num_dp_ranks_of +from sglang.srt.runtime_context import attn_dp_enabled_of, get_platform from sglang.srt.utils.common import is_gfx95_supported, is_npu if TYPE_CHECKING: @@ -292,15 +292,14 @@ def validate_deepseek_v41_features(server_args: ServerArgs) -> None: if ( read_ragged_verify_mode() is not RaggedVerifyMode.STATIC or cfg.disaggregation_transfer_backend != "mooncake" - or num_dp_ranks_of(cfg) != 1 - or attn_dp_enabled_of(cfg) + or cfg.enable_prefill_cp or cfg.attn_cp_size != 1 or cfg.dcp_size != 1 ): raise ValueError( "DeepSeek-V4.1 DSpark PD requires static verify, Mooncake, " - "DP=1 and CP=1. Both servers must enable DSpark with the same " - "block size and TP size." + "and CP=1 on both servers. DP attention is supported when " + "both servers use the same block size and target/draft KV layout." ) prefill_graph = cfg.cuda_graph_config.prefill diff --git a/python/sglang/srt/disaggregation/common/conn.py b/python/sglang/srt/disaggregation/common/conn.py index 371bf2d291..e87bc6d963 100644 --- a/python/sglang/srt/disaggregation/common/conn.py +++ b/python/sglang/srt/disaggregation/common/conn.py @@ -1199,9 +1199,17 @@ class CommonKVManager(BaseKVManager): "enable DSpark with the same block size and target/draft KV " "layout. Upgrade both servers together." ) - if info.attn_tp_size != self.attn_tp_size: + if info.attn_cp_size != 1 or self.attn_cp_size != 1: raise RuntimeError( - "DeepSeek-V4.1 DSpark PD requires the same TP size on both servers" + "DeepSeek-V4.1 DP-only DSpark PD requires CP=1 on both servers" + ) + non_cp_mla_layout = info.attn_cp_size == self.attn_cp_size == 1 and ( + self.is_mla_backend or self.is_hybrid_mla_backend + ) + if info.attn_tp_size != self.attn_tp_size and not non_cp_mla_layout: + raise RuntimeError( + "DeepSeek-V4.1 DSpark PD requires matching attention TP " + "unless both servers use CP=1 with an MLA KV layout" ) if self.dcp_size > 1: