From f7d318de2b95387c29b5b9f25b4b1e79b2540f28 Mon Sep 17 00:00:00 2001 From: Akash kaothalkar <61960177+Akashcodes732@users.noreply.github.com> Date: Thu, 16 Oct 2025 11:06:59 +0530 Subject: [PATCH] [Hardware][CPU][PowerPC]Disable torch.compile() in toptopk sampling (#26987) Signed-off-by: Akash Kaothalkar Co-authored-by: Akash Kaothalkar --- vllm/v1/sample/ops/topk_topp_sampler.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vllm/v1/sample/ops/topk_topp_sampler.py b/vllm/v1/sample/ops/topk_topp_sampler.py index 43a40bce6847d..950cde82fb9d9 100644 --- a/vllm/v1/sample/ops/topk_topp_sampler.py +++ b/vllm/v1/sample/ops/topk_topp_sampler.py @@ -65,7 +65,11 @@ class TopKTopPSampler(nn.Module): ) self.forward = self.forward_native elif current_platform.is_cpu(): - if current_platform.get_cpu_architecture() == CpuArchEnum.RISCV: + arch = current_platform.get_cpu_architecture() + # Fall back to native implementation for POWERPC and RISCV. + # On PowerPC argmax produces incorrect output with torch.compile. + # PR: https://github.com/vllm-project/vllm/pull/26987 + if arch in (CpuArchEnum.RISCV, CpuArchEnum.POWERPC): self.forward = self.forward_native else: self.forward = self.forward_cpu