Skip to content

Conversation

@oandreeva-nv
Copy link
Contributor

It seems like we need to be careful, when using asyncio with multi-threading. The non-graceful shutdown was happening due to "RuntimeError: Non-thread-safe operation invoked on an event loop other than the current one\n\nA" (I started asyncio.run with debug=True). Thus I'm replacing asyncio with threading.

Tests: https://gitlab-master.nvidia.com/dl/dgx/tritonserver/-/jobs/129814805
tests ran for branch oandreeva_metrics_refactor, but the change is the same. I suggest to merge this commit to the current perf PR and merge perf PR to main, i.e. not wait for metrics follow up.

@oandreeva-nv oandreeva-nv requested a review from kthui December 20, 2024 18:44
@kthui
Copy link
Contributor

kthui commented Dec 20, 2024

Can you give this a quick try?

def finalize(self):
    ...
    self._event_loop.call_soon_threadsafe(self._llm_engine_shutdown_event.set)
    ...

It lets the asyncio event to be set in the same loop that the event is blocked on, so we don't need a "busy" timeout loop for checking the shutdown event.

@oandreeva-nv oandreeva-nv changed the title Replacing asyncio event with threading event Setting shutdown asyncio event in a thread-safe manner Dec 20, 2024
@oandreeva-nv oandreeva-nv merged commit 7348662 into jacky-vllm-0.6.3.post1 Dec 20, 2024
3 checks passed
@oandreeva-nv oandreeva-nv deleted the oandreeva_asyncio_fix branch December 20, 2024 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants