From 993859ceb0f4897c423d9fa160fcd80a7a2c890b Mon Sep 17 00:00:00 2001 From: Chaojun Zhang Date: Sat, 18 Apr 2026 10:33:07 +0800 Subject: [PATCH] [XPU] fix all_reduce all-zero accuracy issue under torch.compile (#39844) Signed-off-by: Chaojun Zhang Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- vllm/distributed/device_communicators/xpu_communicator.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vllm/distributed/device_communicators/xpu_communicator.py b/vllm/distributed/device_communicators/xpu_communicator.py index d2e9e89e53..c89c5ddd54 100644 --- a/vllm/distributed/device_communicators/xpu_communicator.py +++ b/vllm/distributed/device_communicators/xpu_communicator.py @@ -47,9 +47,10 @@ class XpuCommunicator(DeviceCommunicatorBase): self.all2all_manager = AgRsAll2AllManager(self.cpu_group) logger.info("Using AgRs manager on XPU device.") - def all_reduce(self, input_) -> torch.Tensor: - dist.all_reduce(input_, group=self.device_group) - return input_ + def all_reduce(self, input_: torch.Tensor) -> torch.Tensor: + output = input_.clone() if torch.compiler.is_compiling() else input_ + dist.all_reduce(output, group=self.device_group) + return output def reduce_scatter(self, input_: torch.Tensor, dim: int = -1): world_size = self.world_size