[2/5] [core]refactor communication layer: PR 2 of 5 Qwen3 Omni non async (#2677)

Signed-off-by: natureofnature <wzliu@connect.hku.hk>
Co-authored-by: Hongsheng Liu <liuhongsheng4@huawei.com>
This commit is contained in:
NATUREandHongsheng Liu authored and GitHub committed 2026-05-15 14:14:08 +08:00
1 parent c7178d89bb
commit 82a0b3a467
20 files changed
+1223 -100

No files matched your search

@@ -30,7 +30,8 @@ QWEN3_OMNI_PIPELINE = PipelineConfig(
requires_multimodal_data=True,
hf_config_name="thinker_config",
engine_output_type="latent",
custom_process_next_stage_input_func=(f"{_PROC}.thinker2talker_async_chunk"),
custom_process_next_stage_input_func=(f"{_PROC}.thinker2talker_full_payload"),
async_chunk_process_next_stage_input_func=(f"{_PROC}.thinker2talker_async_chunk"),
sampling_constraints={"detokenize": True},
),
StagePipelineConfig(
@@ -41,7 +42,9 @@ QWEN3_OMNI_PIPELINE = PipelineConfig(
hf_config_name="talker_config",
engine_output_type="latent",
custom_process_input_func=f"{_PROC}.thinker2talker",
custom_process_next_stage_input_func=(f"{_PROC}.talker2code2wav_async_chunk"),
sync_process_input_func=f"{_PROC}.thinker2talker_token_only",
custom_process_next_stage_input_func=(f"{_PROC}.talker2code2wav_full_payload"),
async_chunk_process_next_stage_input_func=(f"{_PROC}.talker2code2wav_async_chunk"),
sampling_constraints={
"detokenize": False,
"stop_token_ids": [2150],
@@ -237,14 +237,22 @@ class Qwen3OmniMoeForConditionalGeneration(
prompt_token_ids = tokenizer.encode(prompt_template)
# In non-async-chunk (full-payload) mode the engine treats each
# streaming TokensPrompt as a fresh decode, so mid-stream segment
# yields cause the thinker to emit duplicate responses and the
# talker to emit duplicate audio. Defer all audio to the final
# flush so the thinker sees one complete prompt.
async_chunk = getattr(model_config, "async_chunk", False)
async for audio_chunk in audio_stream:
buffer.write_audio(audio_chunk)
while (segment := buffer.read_audio()) is not None:
yield TokensPrompt(
prompt_token_ids=prompt_token_ids,
multi_modal_data={"audio": segment},
)
if async_chunk:
while (segment := buffer.read_audio()) is not None:
yield TokensPrompt(
prompt_token_ids=prompt_token_ids,
multi_modal_data={"audio": segment},
)
remaining = buffer.flush()
if remaining is not None and len(remaining) > 0: