[Core] Extend the shared multi-stage execution framework for mixed V1/MRv2 pipelines (#8184)
Signed-off-by: Sy03 <1370724210@qq.com>
This commit is contained in:
42 files changed
+1792
-85
No files matched your search
@@ -185,6 +185,7 @@ def _start_save_thread(plane, connector):
|
||||
_send_side_request_payload={},
|
||||
_code_prompt_token_ids=defaultdict(list),
|
||||
_work_available=threading.Event(),
|
||||
_save_work_available=threading.Event(),
|
||||
_stop_event=threading.Event(),
|
||||
_MAX_SEND_RETRIES=0,
|
||||
_can_send=True,
|
||||
@@ -199,7 +200,7 @@ def _start_save_thread(plane, connector):
|
||||
|
||||
def _stop_save_thread(plane):
|
||||
plane._stop_event.set()
|
||||
plane._work_available.set()
|
||||
plane._save_work_available.set()
|
||||
plane._save_thread.join(timeout=2)
|
||||
assert not plane._save_thread.is_alive()
|
||||
|
||||
@@ -551,3 +552,71 @@ def test_abort_before_first_chunk_cleans_receiver_state():
|
||||
assert plane.abort_requests({"r"}) == 0
|
||||
assert plane.abort_requests({"r"}) == 0
|
||||
assert not plane._pending_load_reqs and not plane._request_ids_mapping and not plane._local_stage_payload_cache
|
||||
|
||||
|
||||
def test_ar_receiver_accumulates_rows_and_replaces_chunk_metadata():
|
||||
# A V1 upstream sender stamps scalar flags on every chunk; they describe
|
||||
# the latest chunk and must not be concatenated like decode rows.
|
||||
plane = _bare_plane()
|
||||
plane._send_side_request_payload = {}
|
||||
|
||||
def chunk(rows, finished):
|
||||
return {
|
||||
"embed": {"decode": torch.ones((rows, 2))},
|
||||
"meta": {"finished": torch.tensor(finished), "is_segment_finished": torch.tensor(False)},
|
||||
}
|
||||
|
||||
plane._accumulate_payload("ext", chunk(1, False))
|
||||
merged = plane._accumulate_payload("ext", chunk(2, True))
|
||||
|
||||
assert merged["embed"]["decode"].shape == (3, 2)
|
||||
assert merged["meta"]["finished"].item() is True
|
||||
assert merged["meta"]["is_segment_finished"].ndim == 0
|
||||
|
||||
|
||||
def test_terminal_without_processor_payload_still_sends_finish_marker(raw_plane, monkeypatch):
|
||||
# Qwen3-Omni's Talker processor returns None on the terminal call when the
|
||||
# last frames ended exactly on a chunk boundary; Code2Wav must still learn
|
||||
# that the stream finished, as with the V1 chunk adapter.
|
||||
raw_plane._async_chunk = True
|
||||
raw_plane._omni_connector = object()
|
||||
raw_plane._request_ids_mapping = {}
|
||||
raw_plane._custom_process_func = lambda transfer_manager, multimodal_output, request, is_finished=False: None
|
||||
raw_plane._custom_process_batch_func = None
|
||||
monkeypatch.setattr(raw_plane, "is_data_transfer_rank", lambda: True)
|
||||
enqueued = []
|
||||
|
||||
def enqueue(request, payload, **_kw):
|
||||
enqueued.append((request.request_id, payload))
|
||||
return True, None
|
||||
|
||||
monkeypatch.setattr(raw_plane, "_enqueue_chunk_payload", enqueue)
|
||||
raw_plane.register_request(_new_request())
|
||||
|
||||
_complete(raw_plane, [{"codes": {"audio": torch.ones((1, 16))}}])
|
||||
assert enqueued == [] # a non-terminal None payload sends nothing
|
||||
assert raw_plane.request_terminal({"internal"}) == 1
|
||||
[(req_id, payload)] = enqueued
|
||||
assert req_id == "internal"
|
||||
assert payload["meta"]["finished"].item() is True
|
||||
|
||||
|
||||
def test_payload_builders_see_stage_model_config(monkeypatch):
|
||||
# Producer-side builders (Qwen3-Omni's Thinker reads
|
||||
# hf_config.talker_config.accept_hidden_layer) resolve the stage config
|
||||
# through _get_model_config(), as they do on the V1 runner mixin.
|
||||
from vllm_omni.model_executor.stage_input_processors.qwen3_omni import _get_accept_hidden_layer_index
|
||||
|
||||
def init_connectors(self, *, model_config):
|
||||
self._async_chunk = True
|
||||
self._custom_process_func = None
|
||||
|
||||
monkeypatch.setattr(OmniRunnerDataPlane, "init_omni_connectors", init_connectors)
|
||||
monkeypatch.setattr(OmniRunnerDataPlane, "_start_output_worker", lambda self, **_kw: None)
|
||||
model_config = SimpleNamespace(hf_config=SimpleNamespace(talker_config=SimpleNamespace(accept_hidden_layer=24)))
|
||||
vllm_config = SimpleNamespace(model_config=model_config)
|
||||
|
||||
plane = OmniRunnerDataPlane(vllm_config, model_config)
|
||||
|
||||
assert plane._get_model_config() is model_config
|
||||
assert _get_accept_hidden_layer_index(plane) == 24
|
||||
Reference in new issue
Block a user