mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2026-07-26 01:47:13 +08:00
[Core] Add shutdown() method to ExecutorBase (#4349)
This commit is contained in:
parent
b6dcb4d442
commit
15e7c675b0
@ -287,6 +287,12 @@ class LLMEngine:
|
|||||||
# the closure used to initialize Ray worker actors
|
# the closure used to initialize Ray worker actors
|
||||||
raise RuntimeError("LLMEngine should not be pickled!")
|
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":
|
def get_tokenizer(self) -> "PreTrainedTokenizer":
|
||||||
return self.tokenizer.get_lora_tokenizer(None)
|
return self.tokenizer.get_lora_tokenizer(None)
|
||||||
|
|
||||||
|
|||||||
@ -95,6 +95,13 @@ class ExecutorBase(ABC):
|
|||||||
exception."""
|
exception."""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def shutdown(self) -> None:
|
||||||
|
"""Shutdown the executor."""
|
||||||
|
return
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
self.shutdown()
|
||||||
|
|
||||||
|
|
||||||
class ExecutorAsyncBase(ExecutorBase):
|
class ExecutorAsyncBase(ExecutorBase):
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user