[Model] Integrate AURA into Full-Duplex Runtime (#7633)

This commit is contained in:
NumberWan authored and GitHub committed 2026-09-21 09:26:54 -07:00
1 parent d397a2f547
commit 62b15142bd
77 files changed
+7695 -457

No files matched your search

+92 -2
View File
@@ -55,6 +55,7 @@ def _build(
stages: int = 1,
running_counter: FakeRunningCounter | None = None,
runtime_config: DuplexSessionRuntimeConfig | None = None,
plugin=None,
) -> tuple[DuplexOrchestrator, list[FakeStageClient], asyncio.Queue, asyncio.Queue]:
clients = [FakeStageClient(stage_type="llm", final_output=index == stages - 1) for index in range(stages)]
pools = _build_stage_pools(
@@ -70,7 +71,7 @@ def _build(
rpc_async_queue=rpc_q,
stage_pools=pools,
running_counter=running_counter,
plugin=MiniCPMO45DuplexPlugin(_encode_audio),
plugin=plugin or MiniCPMO45DuplexPlugin(_encode_audio),
duplex_session_config=runtime_config or DuplexSessionRuntimeConfig(reaper_interval_s=0.01),
model_config=None,
)
@@ -197,7 +198,8 @@ async def test_open_preregisters_the_stage0_request_and_close_releases_it() -> N
assert request_state.session_owned is True
assert request_state.session_id == SESSION_ID
assert request_state.fence == DuplexFence(SESSION_ID)
assert request_state.streaming.enabled is True
# Set on submit from submission.resumable, not again at preregister.
assert request_state.streaming.enabled is False
# Preregistration reserves the id; nothing is running until an append submits.
assert counter.value == 0
assert clients[0].add_request_calls == []
@@ -211,6 +213,18 @@ async def test_open_preregisters_the_stage0_request_and_close_releases_it() -> N
assert orchestrator.session_manager.active_count() == 0
@pytest.mark.asyncio
async def test_aura_ephemeral_preregister_disables_streaming() -> None:
from vllm_omni.model_executor.models.aura_omni.duplex.plugin import AuraDuplexPlugin
orchestrator, _, rpc_q, _ = _build(plugin=AuraDuplexPlugin(_encode_audio))
result = await _open(orchestrator, rpc_q)
assert result.ok is True
request_state = next(iter(orchestrator.request_states.values()))
assert request_state.streaming.enabled is False
await orchestrator.session_manager.shutdown()
@pytest.mark.asyncio
async def test_open_failure_rolls_back_session_and_reserved_request() -> None:
orchestrator, _, rpc_q, _ = _build()
@@ -275,6 +289,7 @@ async def test_append_submits_the_resumable_stage0_request_and_counts_it_running
assert submitted.resumable is True
assert submitted.sampling_params.max_tokens == 20
request_state = orchestrator.request_states[request_id]
assert request_state.streaming.enabled is True
assert request_state.stage_fences[0] == DuplexFence(SESSION_ID)
assert 0 in request_state.stage_submit_ts
assert counter.value == 1
@@ -390,6 +405,31 @@ async def test_forward_failure_closes_the_owning_session() -> None:
assert types[-1] == "session.expired"
@pytest.mark.asyncio
async def test_aura_forward_failure_keeps_the_session() -> None:
from vllm_omni.model_executor.models.aura_omni.duplex.plugin import AuraDuplexPlugin
orchestrator, clients, rpc_q, output_q = _build(stages=2, plugin=AuraDuplexPlugin(_encode_audio))
await _open(orchestrator, rpc_q)
request_id = next(iter(orchestrator.request_states))
await _submit(orchestrator, _append_audio())
request_state = orchestrator.request_states[request_id]
session = orchestrator.session_manager.get(SESSION_ID)
assert session is not None
absorbed = await orchestrator._handle_forward_failure(request_id, 1, request_state, ValueError("stale talker"))
await _settle(orchestrator)
assert absorbed is True
assert request_id not in orchestrator.request_states
assert SESSION_ID in orchestrator.session_manager.runners
assert session.state != DuplexSessionState.CLOSED
types = [message.event.type for message in [output_q.get_nowait() for _ in range(output_q.qsize())]]
assert "error" in types
assert "session.expired" not in types
await orchestrator.session_manager.shutdown()
@pytest.mark.asyncio
async def test_request_cleanup_failure_is_deferred_and_retried_by_the_reaper(monkeypatch) -> None:
orchestrator, clients, rpc_q, _ = _build()
@@ -560,3 +600,53 @@ async def test_turn_plugin_processes_multimodal_prompt_before_stage_submission(m
assert not orchestrator.request_states[submitted.request_id].streaming.enabled
finally:
await _close(orchestrator, rpc_q)
@pytest.mark.asyncio
async def test_sentence_partial_does_not_legacy_forward_the_full_stage_output() -> None:
from vllm_omni.engine.duplex.plugin import PartialStageForward
orchestrator, *_ = _build(stages=4)
forwarded: list[object] = []
async def record_forward(req_id, stage_id, output, req_state, **kwargs):
del req_id, stage_id, req_state, kwargs
forwarded.append(output)
async def no_intercept(*args, **kwargs):
del args, kwargs
return False
orchestrator._forward_to_next_stage = record_forward # type: ignore[method-assign]
orchestrator._intercept_stage_output = no_intercept # type: ignore[method-assign]
orchestrator.async_chunk = True
orchestrator._stage_receives_async_chunks = lambda stage_id: False # type: ignore[method-assign]
full = SimpleNamespace(request_id="r", finished=True, text="FULL")
chunk = SimpleNamespace(request_id="r", finished=True, text="CHUNK")
req_state = DuplexOrchestratorRequestState(
request_id="r",
final_stage_id=3,
session_owned=True,
sampling_params_list=[SimpleNamespace() for _ in range(4)],
)
orchestrator.plugin.plan_partial_stage_output = lambda *args, **kwargs: PartialStageForward( # type: ignore[method-assign]
output=chunk, is_final_update=True
)
orchestrator.plugin.partial_stage_followup = lambda *args, **kwargs: None # type: ignore[method-assign]
await orchestrator._route_output(1, 0, full, req_state, None)
assert forwarded == [chunk]
assert req_state.skip_legacy_stage_forward is False
forwarded.clear()
orchestrator.plugin.plan_partial_stage_output = lambda *args, **kwargs: None # type: ignore[method-assign]
await orchestrator._route_output(1, 0, full, req_state, None)
assert forwarded == [full]
def test_default_plugin_declares_no_draining_stages() -> None:
plugin = MiniCPMO45DuplexPlugin(_encode_audio)
assert plugin.draining_stage_ids(stage_count=4) == frozenset()