[Bugfix][V1] Clean up compiled-model bytecode hooks on VllmRunner exit (#45195)
Signed-off-by: Ting Sun <suntcrick@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent
14b438a98b
commit
7b5d60cc37
@@ -154,7 +154,9 @@ class TorchCompileWithNoGuardsWrapper:
|
||||
)
|
||||
|
||||
if envs.VLLM_USE_BYTECODE_HOOK and mode != CompilationMode.STOCK_TORCH_COMPILE:
|
||||
torch._dynamo.convert_frame.register_bytecode_hook(self.bytecode_hook)
|
||||
self._bytecode_hook_handle = (
|
||||
torch._dynamo.convert_frame.register_bytecode_hook(self.bytecode_hook)
|
||||
)
|
||||
self._compiled_bytecode: CodeType | None = None
|
||||
|
||||
def aot_compile(self, *args: Any, **kwargs: Any) -> Any:
|
||||
@@ -261,6 +263,12 @@ class TorchCompileWithNoGuardsWrapper:
|
||||
)
|
||||
raise RuntimeError(msg)
|
||||
|
||||
def cleanup(self) -> None:
|
||||
"""Remove the bytecode hook registered by this instance."""
|
||||
handle = getattr(self, "_bytecode_hook_handle", None)
|
||||
if handle is not None:
|
||||
handle.remove()
|
||||
|
||||
@contextmanager
|
||||
def _dispatch_to_compiled_code(self) -> Generator[None, None, None]:
|
||||
# noqa: E501
|
||||
|
||||
Reference in New Issue
Block a user