Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,18 @@ def _init_dspark_sparse_metadata(self, forward_batch: ForwardBatch) -> None:
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
Expand Down
1 change: 1 addition & 0 deletions python/sglang/srt/models/deepseek_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,7 @@ def __init__(
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",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ def __init__(
)
if (
get_parallel().attn_dp_enabled
and not _is_npu
and self._draft_is_moe
and get_parallel().attn_tp_size > 1
):
Expand Down
Loading