Skip to content

ray close wait for forward finish #3676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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: 5 additions & 1 deletion lmdeploy/pytorch/engine/executor/base_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def __init__(
logger.setLevel(log_level)
self.out_que: asyncio.Queue = None
self._output_loop: asyncio.Task = None
self._forward_event: asyncio.Event = None

def init_process_group(self, rank: int, master_addr: str = None, master_port: str = None):
"""Initialize process group."""
Expand Down Expand Up @@ -136,7 +137,9 @@ def get_input_processor(self):

def start(self):
"""Start engine loop."""
self.model_agent.start()
self._forward_event = asyncio.Event()
self._forward_event.set() # Set the event to allow forward calls
self.model_agent.start(self._forward_event)
event_loop = asyncio.get_event_loop()
self.out_que = asyncio.Queue()
self._output_loop = event_loop.create_task(self._get_outputs_loop(), name='GetOutputsLoop')
Expand All @@ -148,6 +151,7 @@ def stop(self):
self._output_loop.cancel()

async def stop_async(self):
await self._forward_event.wait() # Ensure forward event is set before stopping
await self.model_agent.stop_async()
if self._output_loop is not None:
self._output_loop.cancel()
Expand Down
Loading