[CPU][Perf] Add vectorized Sampler Kernel (#53913)

Signed-off-by: Rehan Khan <Rehan.Khan7@ibm.com>
Co-authored-by: Li, Jiang <jiang1.li@intel.com>
This commit is contained in:
Rehan Khan
2026-09-30 15:16:28 +08:00
committed by GitHub
co-authored by Li, Jiang <jiang1.li@intel.com>
parent 77e8b02c8d
commit 583637f126
7 changed files with 528 additions and 11 deletions
+3
View File
@@ -6,6 +6,7 @@ import torch
import torch.nn as nn
from vllm.config.model import LogprobsMode
from vllm.platforms import current_platform
from vllm.utils.gpu_sync_debug import gpu_sync_allowed
from vllm.utils.torch_utils import PIN_MEMORY
from vllm.v1.outputs import LogprobsTensors, SamplerOutput
@@ -239,6 +240,8 @@ class Sampler(nn.Module):
@staticmethod
def greedy_sample(logits: torch.Tensor) -> torch.Tensor:
if current_platform.is_cpu():
return torch.ops._C.greedy_argmax(logits)
return logits.argmax(dim=-1).view(-1)
def sample(