Skip to content
This repository was archived by the owner on Oct 11, 2024. It is now read-only.

Commit 7b11874

Browse files
njhillRobert Shaw
authored andcommitted
[Core] Add shutdown() method to ExecutorBase (vllm-project#4349)
1 parent 5c7a85d commit 7b11874

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

vllm/engine/llm_engine.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,12 @@ def __reduce__(self):
289289
# the closure used to initialize Ray worker actors
290290
raise RuntimeError("LLMEngine should not be pickled!")
291291

292+
def __del__(self):
293+
# Shutdown model executor when engine is garbage collected
294+
# Use getattr since __init__ can fail before the field is set
295+
if model_executor := getattr(self, "model_executor", None):
296+
model_executor.shutdown()
297+
292298
def get_tokenizer(self) -> "PreTrainedTokenizer":
293299
return self.tokenizer.get_lora_tokenizer(None)
294300

vllm/executor/executor_base.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ def check_health(self) -> None:
9595
exception."""
9696
raise NotImplementedError
9797

98+
def shutdown(self) -> None:
99+
"""Shutdown the executor."""
100+
return
101+
102+
def __del__(self):
103+
self.shutdown()
104+
98105

99106
class ExecutorAsyncBase(ExecutorBase):
100107

0 commit comments

Comments
 (0)