[Feature][MiniCPM-o] Support configurable concurrent duplex sessions (#6021)
Signed-off-by: natureofnature <wzliu@connect.hku.hk>
This commit is contained in:
1 parent
710024fa6f
commit
702a409664
15 files changed
+1647
-129
No files matched your search
@@ -1,3 +1,6 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
import asyncio
|
||||
import base64
|
||||
import importlib.util
|
||||
@@ -758,6 +761,34 @@ def test_realtime_duplex_multi_session_rejects_cross_session_response_identity()
|
||||
)
|
||||
|
||||
|
||||
def test_realtime_duplex_multi_session_rejects_overlapping_expected_tokens(monkeypatch, capsys):
|
||||
demo = _load_multi_demo_module()
|
||||
monkeypatch.setattr(
|
||||
demo.sys,
|
||||
"argv",
|
||||
[
|
||||
"multi.py",
|
||||
"--sessions",
|
||||
"2",
|
||||
"--input-wav",
|
||||
"fallback.wav",
|
||||
"--session-input-wav",
|
||||
"a.wav",
|
||||
"--session-input-wav",
|
||||
"b.wav",
|
||||
"--session-expected-token",
|
||||
"cat",
|
||||
"--session-expected-token",
|
||||
"cater",
|
||||
],
|
||||
)
|
||||
|
||||
with pytest.raises(SystemExit):
|
||||
demo.parse_args()
|
||||
|
||||
assert "must not overlap after normalization" in capsys.readouterr().err
|
||||
|
||||
|
||||
def test_realtime_duplex_multi_session_reads_nested_terminal_identity():
|
||||
demo = _load_multi_demo_module()
|
||||
|
||||
@@ -768,6 +799,67 @@ def test_realtime_duplex_multi_session_reads_nested_terminal_identity():
|
||||
)
|
||||
|
||||
|
||||
def test_realtime_duplex_synchronized_start_gate_releases_all_participants():
|
||||
demo = _load_multi_demo_module()
|
||||
|
||||
async def exercise():
|
||||
gate = demo._SynchronizedStartGate(3, timeout_s=0.5)
|
||||
released = []
|
||||
|
||||
async def participant(index):
|
||||
await gate.wait()
|
||||
released.append(index)
|
||||
|
||||
await asyncio.wait_for(
|
||||
asyncio.gather(*(participant(index) for index in range(3))),
|
||||
timeout=1.0,
|
||||
)
|
||||
return released
|
||||
|
||||
assert set(asyncio.run(exercise())) == {0, 1, 2}
|
||||
|
||||
|
||||
def test_realtime_duplex_synchronized_start_gate_aborts_waiters_on_failure(monkeypatch):
|
||||
demo = _load_multi_demo_module()
|
||||
|
||||
async def fake_run_demo(args):
|
||||
if args.fail:
|
||||
raise RuntimeError("session creation failed")
|
||||
await args.start_barrier.wait()
|
||||
return {"ok": True}
|
||||
|
||||
monkeypatch.setattr(demo, "run_demo", fake_run_demo)
|
||||
|
||||
async def exercise():
|
||||
gate = demo._SynchronizedStartGate(2, timeout_s=0.5)
|
||||
return await asyncio.wait_for(
|
||||
asyncio.gather(
|
||||
demo._run_demo_with_start_gate(SimpleNamespace(start_barrier=gate, fail=True)),
|
||||
demo._run_demo_with_start_gate(SimpleNamespace(start_barrier=gate, fail=False)),
|
||||
return_exceptions=True,
|
||||
),
|
||||
timeout=1.0,
|
||||
)
|
||||
|
||||
failed, aborted = asyncio.run(exercise())
|
||||
assert isinstance(failed, RuntimeError)
|
||||
assert str(failed) == "session creation failed"
|
||||
assert isinstance(aborted, RuntimeError)
|
||||
assert "synchronized start aborted" in str(aborted)
|
||||
assert "session creation failed" in str(aborted)
|
||||
|
||||
|
||||
def test_realtime_duplex_synchronized_start_gate_has_bounded_wait():
|
||||
demo = _load_multi_demo_module()
|
||||
|
||||
async def exercise():
|
||||
gate = demo._SynchronizedStartGate(2, timeout_s=0.01)
|
||||
await gate.wait()
|
||||
|
||||
with pytest.raises(TimeoutError, match=r"1/2 sessions ready"):
|
||||
asyncio.run(exercise())
|
||||
|
||||
|
||||
def test_realtime_duplex_demo_resolves_distinct_turn_inputs():
|
||||
demo = _load_demo_module()
|
||||
primary = Path("first.wav")
|
||||
|
||||
Reference in new issue
Block a user