|
@@ -239,6 +239,12 @@ class AphroditeEngine:
|
|
|
# the closure used to initialize Ray worker actors
|
|
|
raise RuntimeError("AphroditeEngine should not be pickled!")
|
|
|
|
|
|
+ def __del__(self):
|
|
|
+ # Shutdown the 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)
|
|
|
|