[DSv4 Perf] Remove redundant full kernel for dsv4, 1.88x kernel performance improvement (#50298)

Signed-off-by: yewentao256 <zhyanwentao@126.com>
This commit is contained in:
Wentao Ye
2026-07-30 11:39:07 -04:00
committed by GitHub
parent 904fae8be1
commit 837eae6458
3 changed files with 43 additions and 22 deletions
@@ -535,6 +535,7 @@ def combine_topk_swa_indices(
topk: int,
M: int,
N: int,
out: tuple[torch.Tensor, torch.Tensor] | None = None,
) -> tuple[torch.Tensor, torch.Tensor]:
num_tokens = topk_indices.shape[0]
combined_topk = (
@@ -542,15 +543,18 @@ def combine_topk_swa_indices(
// _SPARSE_PREFILL_TOPK_ALIGNMENT
* _SPARSE_PREFILL_TOPK_ALIGNMENT
)
combined_indices = torch.full(
(num_tokens, combined_topk),
fill_value=-1,
dtype=torch.int32,
device=topk_indices.device,
)
combined_lens = torch.empty(
num_tokens, dtype=torch.int32, device=topk_indices.device
)
if out is None:
combined_indices = torch.full(
(num_tokens, combined_topk),
fill_value=-1,
dtype=torch.int32,
device=topk_indices.device,
)
combined_lens = torch.empty(
num_tokens, dtype=torch.int32, device=topk_indices.device
)
else:
combined_indices, combined_lens = out
_COMBINE_TOPK_SWA_INDICES_KERNEL(
combined_indices,