[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
|
||||
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)
|
||||
|
||||
|
||||
@ -95,6 +95,13 @@ class ExecutorBase(ABC):
|
||||
exception."""
|
||||
raise NotImplementedError
|
||||
|
||||
def shutdown(self) -> None:
|
||||
"""Shutdown the executor."""
|
||||
return
|
||||
|
||||
def __del__(self):
|
||||
self.shutdown()
|
||||
|
||||
|
||||
class ExecutorAsyncBase(ExecutorBase):
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user