diff --git a/python/sglang/srt/hardware_backend/npu/attention/ascend_dsv4_backend.py b/python/sglang/srt/hardware_backend/npu/attention/ascend_dsv4_backend.py index 81d80ebecf..2bfb2dc2df 100644 --- a/python/sglang/srt/hardware_backend/npu/attention/ascend_dsv4_backend.py +++ b/python/sglang/srt/hardware_backend/npu/attention/ascend_dsv4_backend.py @@ -1021,6 +1021,18 @@ class DeepseekV4AscendAttnBackend( out_cache_loc=out_cache_loc, block_size=block_size, ) + # The query is padded to an attn_tp multiple (prepare_mlp_sync_batch), + # but seq_lens is not, so pad the tail with -1 ("skip") to match. + num_padded_tokens = out_cache_loc.shape[0] + if ori_sparse_indices.shape[0] < num_padded_tokens: + pad_rows = num_padded_tokens - ori_sparse_indices.shape[0] + pad = torch.full( + (pad_rows, ori_sparse_indices.shape[1]), + -1, + dtype=ori_sparse_indices.dtype, + device=ori_sparse_indices.device, + ) + ori_sparse_indices = torch.cat([ori_sparse_indices, pad], dim=0) ori_sparse_indices = ori_sparse_indices.unsqueeze(1).contiguous() fm.ori_sparse_indices = ori_sparse_indices diff --git a/python/sglang/srt/models/deepseek_v4.py b/python/sglang/srt/models/deepseek_v4.py index 507a1b207c..1899d0dfbe 100644 --- a/python/sglang/srt/models/deepseek_v4.py +++ b/python/sglang/srt/models/deepseek_v4.py @@ -1036,6 +1036,7 @@ class MqaAttentionBase(nn.Module): bias=False, quant_config=quant_config, reduce_results=reduce_results, + use_dp_attention_reduce=is_dp_attention_enabled(), prefix=add_prefix("wo_b", prefix), parallel_group="attn_tp", ) diff --git a/python/sglang/srt/speculative/dspark_components/dspark_worker_v2.py b/python/sglang/srt/speculative/dspark_components/dspark_worker_v2.py index 4c9d524522..2981e2a100 100644 --- a/python/sglang/srt/speculative/dspark_components/dspark_worker_v2.py +++ b/python/sglang/srt/speculative/dspark_components/dspark_worker_v2.py @@ -174,6 +174,7 @@ class DSparkWorkerV2(BaseSpecWorker): ) if ( get_parallel().attn_dp_enabled + and not _is_npu and self._draft_is_moe and get_parallel().attn_tp_size > 1 ):