-
Notifications
You must be signed in to change notification settings - Fork 843
[Enhancement] Patch AsyncOmniEngine try_get_output[_async] hanging issues #2153
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| """Tests for AsyncOmniEngine.try_get_output and try_get_output_async. | ||
|
|
||
| Focuses on the critical behavior: when the orchestrator thread dies, | ||
| subsequent attempts to collect output raise RuntimeError. | ||
| """ | ||
|
|
||
| import queue | ||
| from unittest.mock import MagicMock | ||
|
|
||
| import pytest | ||
|
|
||
| from vllm_omni.engine.async_omni_engine import AsyncOmniEngine | ||
|
|
||
| pytestmark = [pytest.mark.core_model, pytest.mark.cpu] | ||
|
|
||
|
|
||
| def _make_engine(output_queue, *, thread_alive: bool = True) -> AsyncOmniEngine: | ||
| """Create an AsyncOmniEngine bypassing __init__.""" | ||
| engine = object.__new__(AsyncOmniEngine) | ||
| engine.output_queue = output_queue | ||
| engine.orchestrator_thread = MagicMock( | ||
| is_alive=MagicMock(return_value=thread_alive), | ||
| ) | ||
| return engine | ||
|
|
||
|
|
||
| def test_try_get_output_raises_after_orchestrator_dies(): | ||
| """Draining remaining results then hitting an empty queue with a dead | ||
| orchestrator must raise RuntimeError so callers know the pipeline is gone.""" | ||
| mock_queue = MagicMock() | ||
| # First call succeeds; second call finds the queue empty. | ||
| mock_queue.sync_q.get.side_effect = [ | ||
| {"type": "output", "request_id": "r1"}, | ||
| queue.Empty, | ||
| ] | ||
|
|
||
| engine = _make_engine(mock_queue, thread_alive=True) | ||
|
|
||
| # Collect the one buffered result. | ||
| assert engine.try_get_output()["request_id"] == "r1" | ||
|
|
||
| # Orchestrator thread crashes between polls. | ||
| engine.orchestrator_thread.is_alive.return_value = False | ||
|
|
||
| with pytest.raises(RuntimeError, match="Orchestrator died unexpectedly"): | ||
| engine.try_get_output() | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_try_get_output_async_raises_after_orchestrator_dies(): | ||
| """Same scenario as above but for the async variant.""" | ||
| mock_queue = MagicMock() | ||
| mock_queue.sync_q.get_nowait.side_effect = [ | ||
| {"type": "output", "request_id": "r1"}, | ||
| queue.Empty, | ||
| ] | ||
|
|
||
| engine = _make_engine(mock_queue, thread_alive=True) | ||
|
|
||
| assert (await engine.try_get_output_async())["request_id"] == "r1" | ||
|
|
||
| engine.orchestrator_thread.is_alive.return_value = False | ||
|
|
||
| with pytest.raises(RuntimeError, match="Orchestrator died unexpectedly"): | ||
| await engine.try_get_output_async() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -987,6 +987,8 @@ def try_get_output(self, timeout: float = 0.001) -> dict[str, Any] | None: | |
| try: | ||
| return self.output_queue.sync_q.get(timeout=timeout) | ||
| except queue.Empty: | ||
| if not self.is_alive(): | ||
| raise RuntimeError("Orchestrator died unexpectedly. See logs above.") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What message would you suggest instead? There is no meaningful way currently to obtain the specific error thrown by the Orchestrator thread. This is meant to be the catch-all worst-case scenario when orchestrator aborts ungracefully or forcefully that was not caught by the standard paths of sending to the output queue. |
||
| return None | ||
|
|
||
| async def try_get_output_async(self) -> dict[str, Any] | None: | ||
|
|
@@ -996,6 +998,8 @@ async def try_get_output_async(self) -> dict[str, Any] | None: | |
| try: | ||
| return self.output_queue.sync_q.get_nowait() | ||
| except queue.Empty: | ||
| if not self.is_alive(): | ||
| raise RuntimeError("Orchestrator died unexpectedly. See logs above.") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess the error messages might be asynchronously printed in stdout. Is the error message really shown above? |
||
| return None | ||
|
|
||
| def get_stage_metadata(self, stage_id: int) -> dict[str, Any]: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's not that necessary to add tests for the log info, since the logic is straightforward
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was requested by @david6666666 in #1346, but I can remove it if the consensus is that it is not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's necessary to add test to corer handle out-of-memory (OOM) errors in a manner consistent with vLLM.