Skip to content

Commit

Permalink
[Core] Add shutdown() method to ExecutorBase (#4349)
Browse files Browse the repository at this point in the history
  • Loading branch information
njhill authored Apr 25, 2024
1 parent b6dcb4d commit 15e7c67
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions vllm/engine/llm_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,12 @@ def __reduce__(self):
# the closure used to initialize Ray worker actors
raise RuntimeError("LLMEngine should not be pickled!")

def __del__(self):
# Shutdown model executor when engine is garbage collected
# Use getattr since __init__ can fail before the field is set
if model_executor := getattr(self, "model_executor", None):
model_executor.shutdown()

def get_tokenizer(self) -> "PreTrainedTokenizer":
return self.tokenizer.get_lora_tokenizer(None)

Expand Down
7 changes: 7 additions & 0 deletions vllm/executor/executor_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ def check_health(self) -> None:
exception."""
raise NotImplementedError

def shutdown(self) -> None:
"""Shutdown the executor."""
return

def __del__(self):
self.shutdown()


class ExecutorAsyncBase(ExecutorBase):

Expand Down

0 comments on commit 15e7c67

Please sign in to comment.