[XPU] Optimize XPU worker shutdown logic to prevent resource leak (#46433)

Signed-off-by: Chaojun Zhang <chaojun.zhang@intel.com>
This commit is contained in:
Chaojun Zhang
2026-06-30 15:27:21 +08:00
committed by GitHub
parent ba22cb6765
commit 8cc242335d
7 changed files with 41 additions and 5 deletions
+10
View File
@@ -243,6 +243,16 @@ class XPUPlatform(Platform):
if "VLLM_WORKER_MULTIPROC_METHOD" not in os.environ:
os.environ["VLLM_WORKER_MULTIPROC_METHOD"] = "spawn"
# XPU requires graceful shutdown to allow oneCCL/Level Zero resources
# to be properly released. Without this, subsequent server startups on
# the same devices may hang during CCL initialization.
if vllm_config.shutdown_timeout == 0:
vllm_config.shutdown_timeout = 5
logger.info(
"XPU platform: set server shutdown_timeout=%d.",
vllm_config.shutdown_timeout,
)
@classmethod
def update_block_size_for_backend(cls, vllm_config: "VllmConfig") -> None:
super().update_block_size_for_backend(vllm_config)
+1 -1
View File
@@ -6385,7 +6385,7 @@ class GPUModelRunner(
_ROPE_DICT.clear()
reset_workspace_manager()
if current_platform.is_rocm():
if current_platform.is_rocm() or current_platform.is_xpu():
gc.collect()
torch.accelerator.empty_cache()
torch.accelerator.synchronize()
+4 -3
View File
@@ -1294,10 +1294,11 @@ class Worker(WorkerBase):
# Release kept-alive cumem pools while the pluggable allocator wrappers
# and callbacks are still alive, so MemPool teardown is not deferred to
# interpreter finalization (pytorch/pytorch#145168).
from vllm.device_allocator.cumem import CuMemAllocator
if current_platform.is_cuda_alike():
from vllm.device_allocator.cumem import CuMemAllocator
if CuMemAllocator.instance is not None:
CuMemAllocator.instance.release_pools()
if CuMemAllocator.instance is not None:
CuMemAllocator.instance.release_pools()
def elastic_ep_execute(self, execute_method: str, *args, **kwargs):
return self.elastic_ep_executor.execute(execute_method, *args, **kwargs)
+17
View File
@@ -162,3 +162,20 @@ class XPUWorker(Worker):
logger.debug("Starting torch profiler with trace name: %s", trace_name)
super().profile(is_start=is_start, profile_prefix=profile_prefix)
def shutdown(self) -> None:
logger.info(
"XPUWorker shutdown: cleaning up (rank=%d, local_rank=%d)",
self.rank,
self.local_rank,
)
super().shutdown()
from vllm.device_allocator.xpumem import XpuMemAllocator
if XpuMemAllocator.instance is not None:
XpuMemAllocator.instance.release_pools()
logger.info(
"XPUWorker shutdown: done (rank=%d, local_rank=%d)",
self.rank,
self.local_rank,
)