[XPU] Fix UVA weight offloading (non-pinned-tensor views and static Triton launcher) (#51770)

Signed-off-by: Chaojun Zhang <chaojun.zhang@intel.com>
This commit is contained in:
Chaojun Zhang
2026-08-11 21:48:44 +08:00
committed by GitHub
parent 78e7fdd1ab
commit f863387250
2 changed files with 33 additions and 1 deletions
+9 -1
View File
@@ -887,7 +887,15 @@ def get_accelerator_view_from_cpu_tensor(cpu_tensor: torch.Tensor) -> torch.Tens
from vllm.platforms import current_platform
if current_platform.is_xpu():
assert cpu_tensor.is_pinned(), "CPU tensor must be pinned"
# Remove once the vllm-xpu-kernels fix for empty and non-pinned inputs
# (vllm-project/vllm-xpu-kernels#513) is in a released package.
if cpu_tensor.numel() == 0:
return torch.empty(cpu_tensor.shape, dtype=cpu_tensor.dtype, device="xpu")
if not cpu_tensor.is_pinned():
contiguous_cpu = cpu_tensor.contiguous()
pinned = torch.empty_like(contiguous_cpu, pin_memory=True)
pinned.copy_(contiguous_cpu)
cpu_tensor = pinned
return torch.ops._C.get_xpu_view_from_cpu_tensor(cpu_tensor)
elif current_platform.is_cuda_alike():
return torch.ops._C.get_cuda_view_from_cpu_tensor(cpu_tensor)