Signed-off-by: Zhichao Zhang <60429419+smartDream-chao@users.noreply.github.com>
This commit is contained in:
1 parent
a22a7dd68f
commit
27f0e8c1ea
6 files changed
+215
-7
No files matched your search
@@ -1,5 +1,5 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
from collections import defaultdict
|
||||
from types import SimpleNamespace
|
||||
@@ -32,11 +32,15 @@ _FRAME = [1, 2, 3, 4]
|
||||
_Q = len(_FRAME)
|
||||
|
||||
|
||||
def _req(rid, *, finished, initial_codec_chunk_frames=None):
|
||||
ai = None
|
||||
def _req(rid, *, finished, initial_codec_chunk_frames=None, non_streaming_mode=None, full_utterance_decode=None):
|
||||
entries = {}
|
||||
if initial_codec_chunk_frames is not None:
|
||||
entry = SimpleNamespace(list_data=[initial_codec_chunk_frames])
|
||||
ai = SimpleNamespace(entries={"initial_codec_chunk_frames": entry})
|
||||
entries["initial_codec_chunk_frames"] = SimpleNamespace(list_data=[initial_codec_chunk_frames])
|
||||
if non_streaming_mode is not None:
|
||||
entries["non_streaming_mode"] = SimpleNamespace(list_data=[non_streaming_mode])
|
||||
if full_utterance_decode is not None:
|
||||
entries["full_utterance_decode"] = SimpleNamespace(list_data=[full_utterance_decode])
|
||||
ai = SimpleNamespace(entries=entries) if entries else None
|
||||
return SimpleNamespace(
|
||||
external_req_id=rid,
|
||||
is_finished=lambda: finished,
|
||||
@@ -123,6 +127,85 @@ def test_flush_on_finish():
|
||||
assert len(p.codes.audio) == _Q * 24
|
||||
|
||||
|
||||
def test_full_utterance_decode_defers_until_finished():
|
||||
"""full_utterance_decode=True should not emit windowed chunks mid-utterance (#4371)."""
|
||||
tm = _tm()
|
||||
tm.code_prompt_token_ids["r"] = [_FRAME[:] for _ in range(50)]
|
||||
p = talker2code2wav_async_chunk(
|
||||
transfer_manager=tm,
|
||||
multimodal_output=None,
|
||||
request=_req("r", finished=False, full_utterance_decode=True),
|
||||
is_finished=False,
|
||||
)
|
||||
assert p is None
|
||||
|
||||
|
||||
def test_full_utterance_decode_emits_full_utterance_on_finish():
|
||||
tm = _tm()
|
||||
tm.code_prompt_token_ids["r"] = [_FRAME[:] for _ in range(50)]
|
||||
p = talker2code2wav_async_chunk(
|
||||
transfer_manager=tm,
|
||||
multimodal_output=None,
|
||||
request=_req("r", finished=True, full_utterance_decode=True),
|
||||
is_finished=True,
|
||||
)
|
||||
assert p is not None
|
||||
assert p.meta.finished.item() is True
|
||||
assert len(p.codes.audio) == _Q * 50
|
||||
|
||||
|
||||
def test_full_utterance_decode_false_keeps_windowed_emit():
|
||||
# Dynamic IC defers emit at 25 frames (see _CASES); 41 hits the first
|
||||
# steady-state window boundary and proves streaming path is unchanged.
|
||||
tm = _tm()
|
||||
tm.code_prompt_token_ids["r"] = [_FRAME[:] for _ in range(41)]
|
||||
p = talker2code2wav_async_chunk(
|
||||
transfer_manager=tm,
|
||||
multimodal_output={"codes": {"audio": torch.zeros((0,))}},
|
||||
request=_req("r", finished=False, full_utterance_decode=False),
|
||||
is_finished=False,
|
||||
)
|
||||
assert p is not None
|
||||
assert len(p.codes.audio) == _Q * 25
|
||||
|
||||
|
||||
def test_non_streaming_mode_alone_does_not_defer_async_chunk():
|
||||
"""Prompt-mode non_streaming_mode must not gate Code2Wav emits (#6898).
|
||||
|
||||
VoiceDesign serving defaults non_streaming_mode=True even for streaming
|
||||
responses; those requests still need windowed async-chunk audio for TTFA.
|
||||
"""
|
||||
tm = _tm()
|
||||
tm.code_prompt_token_ids["r"] = [_FRAME[:] for _ in range(41)]
|
||||
p = talker2code2wav_async_chunk(
|
||||
transfer_manager=tm,
|
||||
multimodal_output={"codes": {"audio": torch.zeros((0,))}},
|
||||
request=_req("r", finished=False, non_streaming_mode=True),
|
||||
is_finished=False,
|
||||
)
|
||||
assert p is not None
|
||||
assert len(p.codes.audio) == _Q * 25
|
||||
|
||||
|
||||
def test_voicedesign_prompt_mode_with_streaming_keeps_windowed_emit():
|
||||
"""Streaming VoiceDesign-style defaults: prompt-mode True, decode False."""
|
||||
tm = _tm()
|
||||
tm.code_prompt_token_ids["r"] = [_FRAME[:] for _ in range(41)]
|
||||
p = talker2code2wav_async_chunk(
|
||||
transfer_manager=tm,
|
||||
multimodal_output={"codes": {"audio": torch.zeros((0,))}},
|
||||
request=_req(
|
||||
"r",
|
||||
finished=False,
|
||||
non_streaming_mode=True,
|
||||
full_utterance_decode=False,
|
||||
),
|
||||
is_finished=False,
|
||||
)
|
||||
assert p is not None
|
||||
assert len(p.codes.audio) == _Q * 25
|
||||
|
||||
|
||||
_CASES = [
|
||||
# ── IC boundary rule ──────────────────────────────────────────────
|
||||
# initial_codec_chunk_frames only controls the first emitted chunk.
|
||||
|
||||
Reference in new issue
Block a user