Skip to content

Commit ff1eb99

Browse files
njhillgemini-code-assist[bot]
authored andcommitted
[BugFix] Ensure appropriate guards in destructors (vllm-project#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> Signed-off-by: xuebwang-amd <xuebwang@amd.com>
1 parent 1204d31 commit ff1eb99

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

vllm/compilation/collective_fusion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,7 @@ def __call__(self, graph: fx.Graph):
11831183
self.end_and_log()
11841184

11851185
def __del__(self):
1186-
if self.disabled:
1186+
if getattr(self, "disabled", True):
11871187
return
11881188
if flashinfer_comm is not None:
11891189
flashinfer_comm.trtllm_destroy_ipc_workspace_for_all_reduce(

vllm/distributed/kv_transfer/kv_connector/v1/nixl_connector.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,9 +569,10 @@ def __init__(self, vllm_config: VllmConfig, engine_id: str):
569569

570570
def __del__(self):
571571
"""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)
575576

576577
@staticmethod
577578
def _nixl_handshake_listener(metadata: NixlAgentMetadata,
@@ -1379,4 +1380,4 @@ def reduce(self) -> dict[str, Union[int, float]]:
13791380
# TODO: reduce stats to a single value, calculate latency/throughput
13801381
return {
13811382
"num_successful_transfers": self.data["num_successful_transfers"]
1382-
}
1383+
}

vllm/executor/executor_base.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,6 @@ def shutdown(self) -> None:
235235
"""Shutdown the executor."""
236236
self.collective_rpc("shutdown")
237237

238-
def __del__(self):
239-
self.shutdown()
240-
241238
async def execute_model_async(
242239
self,
243240
execute_model_req: ExecuteModelRequest) -> List[SamplerOutput]:

vllm/v1/worker/gpu_worker.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,8 @@ def save_tensorized_model(
683683
tensorizer_config=tensorizer_config, )
684684

685685
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()
687688

688689

689690
def init_worker_distributed_environment(

0 commit comments

Comments
 (0)