[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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user