@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / a25ade5d47
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 14, 05:30 UTC

[BugFix] Ensure appropriate guards in destructors (#25284)

Signed-off-by: Nick Hill <nhill@redhat.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

Nick Hill committed Sep 19, 2025 at 18:06 UTC a25ade5d473fc00107bd3950141d8211331d3377
4 files changed +8 -9
vllm/compilation/collective_fusion.py
+1 -1
@@ -1183,7 +1183,7 @@ class AllReduceFusionPass(VllmInductorPass):
1183 self.end_and_log()
1184
1185 def __del__(self):
1186 - if self.disabled:
1186 + if getattr(self, "disabled", True):
1187 return
1188 if flashinfer_comm is not None:
1189 flashinfer_comm.trtllm_destroy_ipc_workspace_for_all_reduce(
vllm/distributed/kv_transfer/kv_connector/v1/nixl_connector.py
+5 -4
@@ -569,9 +569,10 @@ class NixlConnectorWorker:
569
570 def __del__(self):
571 """Cleanup background threads on destruction."""
572 - self._handshake_initiation_executor.shutdown(wait=False)
573 - if self._nixl_handshake_listener_t:
574 - self._nixl_handshake_listener_t.join(timeout=0)
572 + if executor := getattr(self, "_handshake_initiation_executor", None):
573 + executor.shutdown(wait=False)
574 + if listener_t := getattr(self, "_nixl_handshake_listener_t", None):
575 + listener_t.join(timeout=0)
576
577 @staticmethod
578 def _nixl_handshake_listener(metadata: NixlAgentMetadata,
@@ -1379,4 +1380,4 @@ class NixlKVConnectorStats(KVConnectorStats):
1380 # TODO: reduce stats to a single value, calculate latency/throughput
1381 return {
1382 "num_successful_transfers": self.data["num_successful_transfers"]
1382 - }
\ No newline at end of file
1383 + }
vllm/executor/executor_base.py
-3
@@ -235,9 +235,6 @@ class ExecutorBase(ABC):
235 """Shutdown the executor."""
236 self.collective_rpc("shutdown")
237
238 - def __del__(self):
239 - self.shutdown()
240 -
238 async def execute_model_async(
239 self,
240 execute_model_req: ExecuteModelRequest) -> List[SamplerOutput]:
vllm/v1/worker/gpu_worker.py
+2 -1
@@ -683,7 +683,8 @@ class Worker(WorkerBase):
683 tensorizer_config=tensorizer_config, )
684
685 def shutdown(self) -> None:
686 - self.model_runner.ensure_kv_transfer_shutdown()
686 + if runner := getattr(self, "model_runner", None):
687 + runner.ensure_kv_transfer_shutdown()
688
689
690 def init_worker_distributed_environment(