Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions vllm/v1/engine/llm_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,6 @@ def apply_model(self, func: Callable[[nn.Module], _R]) -> list[_R]:
return self.collective_rpc("apply_model", args=(func,))

def __del__(self):
if (
dp_group := getattr(self, "dp_group", None)
and not self.external_launcher_dp
):
dp_group = getattr(self, "dp_group", None)
if dp_group is not None and not self.external_launcher_dp:
stateless_destroy_torch_distributed_process_group(dp_group)
Comment on lines 411 to 414
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

While this change correctly fixes the immediate bug, relying on __del__ for critical resource cleanup like destroying a process group is unreliable. The __del__ method is not guaranteed to be called in all circumstances, for example, if the object is part of a reference cycle. This can lead to resource leaks, which can be particularly problematic in a distributed environment. A more robust approach would be to implement an explicit close() or shutdown() method that handles this cleanup. Ideally, LLMEngine could be made a context manager (by implementing __enter__ and __exit__) to ensure deterministic cleanup using a with statement.

Loading