[Fix] [NPU] dspark: Fix attn_tp > 1 draft wo_b all_reduce group (#40399)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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",
|
||||
)
|
||||
|
||||
@@ -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
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user