[3/5][core]refactor communication layer: PR 3 of 5, all other models in non async mode (#3719)

Signed-off-by: natureofnature <wzliu@connect.hku.hk>
This commit is contained in:
NATURE authored and GitHub committed 2026-05-28 14:06:41 +08:00
1 parent 0f3264a9c0
commit 3a347b10b0
38 files changed
+3021 -275

No files matched your search

+42 -8
View File
@@ -400,16 +400,23 @@ def _make_full_payload_accumulation_runner(
model_arch="Qwen3OmniMoeForConditionalGeneration",
model_stage="talker",
async_chunk=False,
final_output=False,
custom_process_next_stage_input_func="module.full_payload",
):
runner = object.__new__(OmniConnectorModelRunnerMixin)
runner.model_config = SimpleNamespace(
model_arch=model_arch,
model_stage=model_stage,
async_chunk=async_chunk,
final_output=final_output,
custom_process_next_stage_input_func=custom_process_next_stage_input_func,
)
runner._custom_process_func = object()
runner._pending_full_payload_send = {}
runner._stage_id = 1
# Non-None sentinel: the gate short-circuits to False when no connector
# is configured at all (terminal stages in pipelines with no connector).
runner._omni_connector = object()
return runner
@@ -425,7 +432,7 @@ def test_accumulate_full_payload_output_preserves_aligned_all_zero_qwen3_omni_co
def test_accumulate_full_payload_output_keeps_misaligned_all_zero_qwen3_omni_codec_rows():
# After removing the sender-side zero filter, the accumulator keeps every
# After removing the sender-side zero filter, the full-payload accumulator keeps every
# codec row including misaligned all-zero rows. The downstream consumer
# (_extract_qwen3_full_payload_codec_rows) is the authoritative crop and
# filters by output_token_ids.
@@ -472,18 +479,45 @@ def test_accumulate_full_payload_output_keeps_all_zero_qwen3_omni_prefill_placeh
def test_full_payload_output_accumulation_hook_matrix():
"""Producer-side gate: fires iff an explicit next-stage payload hook is loaded.
A derived `*_full_payload` helper from `custom_process_input_func` is not
enough: terminal/input-only consumer stages must not enqueue orphan
downstream payloads.
"""
# Thinker / talker producer stages: explicit next-stage payload hook -> gate fires.
assert _make_full_payload_accumulation_runner(model_stage="thinker")._should_accumulate_full_payload_output()
assert _make_full_payload_accumulation_runner(model_stage="talker")._should_accumulate_full_payload_output()
assert not _make_full_payload_accumulation_runner(model_stage="code2wav")._should_accumulate_full_payload_output()
# Terminal stage: even if _load_custom_func derived a builder from
# custom_process_input_func, final output stages are not producers.
runner = _make_full_payload_accumulation_runner(model_stage="code2wav", final_output=True)
assert not runner._should_accumulate_full_payload_output()
# Input-only consumer stage without an explicit producer hook must not
# accumulate/send just because a same-module *_full_payload helper exists.
runner = _make_full_payload_accumulation_runner(
model_stage="token2audio",
custom_process_next_stage_input_func=None,
)
assert not runner._should_accumulate_full_payload_output()
# async_chunk mode -> gate off.
assert not _make_full_payload_accumulation_runner(
model_stage="talker", async_chunk=True
)._should_accumulate_full_payload_output()
assert not _make_full_payload_accumulation_runner(
model_arch="Qwen3TTSForConditionalGeneration"
)._should_accumulate_full_payload_output()
assert not _make_full_payload_accumulation_runner(
model_arch="Qwen2_5OmniForConditionalGeneration"
)._should_accumulate_full_payload_output()
# Non-qwen3 arches: gate is arch-agnostic, but if the fixture's arch
# does not configure a connector payload builder, its runtime
# `_custom_process_func` is None. Emulate that.
runner = _make_full_payload_accumulation_runner(model_arch="Qwen3TTSForConditionalGeneration")
runner._custom_process_func = None
runner._should_accumulate_full_payload_output_cached = None
assert not runner._should_accumulate_full_payload_output()
runner = _make_full_payload_accumulation_runner(model_arch="Qwen2_5OmniForConditionalGeneration")
runner._custom_process_func = None
runner._should_accumulate_full_payload_output_cached = None
assert not runner._should_accumulate_full_payload_output()
def test_sync_local_stage_payloads_retains_payload_until_request_is_active():