[Model] Stop MiniCPM-o Thinker at TTS boundaries (#7463)

Signed-off-by: Zhu Shihao <zhushihao@bytedance.com>
Co-authored-by: Zhu Shihao <zhushihao@bytedance.com>
This commit is contained in:
Ethan ZHUandZhu Shihao authored and GitHub committed 2026-09-14 15:25:00 -07:00
1 parent 7ad51f0007
commit 9f85b3722e
9 files changed
+113 -30

No files matched your search

+46 -1
View File
@@ -1332,6 +1332,10 @@ class TestDeployConfigLoading:
assert deploy.duplex_session.max_sessions == max_sessions
assert [stage.session_mode for stage in stages] == ["duplex", "duplex", "duplex"]
assert [stage.to_omegaconf().session_mode for stage in stages] == ["duplex", "duplex", "duplex"]
assert stages[0].yaml_extras["default_sampling_params"]["stop_token_ids"] == [
151704,
151645,
]
def test_load_minicpmo_default_deploy_config(self):
deploy_path = Path(get_deploy_config_path("minicpmo_4_5.yaml"))
@@ -3212,7 +3216,7 @@ class TestSentinelDefaultPrecedence:
class TestSamplingConstraintsPrecedence:
"""Test that pipeline sampling_constraints override deploy defaults."""
"""Test scalar constraint precedence and additive required stop tokens."""
def test_constraints_win(self):
deploy_path = Path(get_deploy_config_path("qwen3_omni_moe.yaml"))
@@ -3232,6 +3236,47 @@ class TestSamplingConstraintsPrecedence:
# Pipeline says stop_token_ids=[2150] for talker
assert stages[1].yaml_extras["default_sampling_params"]["stop_token_ids"] == [2150]
def test_required_stop_tokens_extend_yaml_defaults(self, tmp_path):
pipeline = PipelineConfig(
model_type="required_stop_tokens",
stages=(
StagePipelineConfig(
stage_id=0,
model_stage="thinker",
final_output=True,
sampling_constraints={
"detokenize": True,
"stop_token_ids": [151704, 151645],
},
),
),
)
deploy_path = tmp_path / "required-stop-tokens.yaml"
deploy_path.write_text(
"""
stages:
- stage_id: 0
default_sampling_params:
max_tokens: 7
stop_token_ids: [100, 151704]
""",
encoding="utf-8",
)
legacy_stage = merge_pipeline_deploy(pipeline, load_deploy_config(deploy_path))[0]
structured_stage = VllmOmniConfig.from_pipeline_config(
pipeline,
deploy_config_path=str(deploy_path),
).stage_by_id(0)
expected = {
"max_tokens": 7,
"detokenize": True,
"stop_token_ids": [100, 151704, 151645],
}
assert legacy_stage.yaml_extras["default_sampling_params"] == expected
assert structured_stage.model_config.default_sampling_params == expected
class TestPipelineConfigResolvers:
@pytest.mark.parametrize("resolver", [obj for obj in OMNI_PIPELINES.values() if callable(obj)])
+16 -8
View File
@@ -200,20 +200,28 @@ def _make_base():
return obj
def test_resolve_sampling_params_list_preserves_stage_constraints():
def test_resolve_sampling_params_list_merges_required_stop_tokens():
base = _make_base()
base.engine.num_stages = 1
base.default_sampling_params_list = [SamplingParams(max_tokens=1000, detokenize=False, stop_token_ids=[42])]
required_stop_ids = [151704, 151645]
base.default_sampling_params_list = [
SamplingParams(max_tokens=1000, detokenize=False, stop_token_ids=[99, *required_stop_ids])
]
base.engine.stage_configs = [
StageConfig(
stage_id=0,
model_stage="dummy-model",
sampling_constraints={"detokenize": False, "stop_token_ids": [42]},
sampling_constraints={"detokenize": False, "stop_token_ids": required_stop_ids},
).to_omegaconf()
]
base.sampling_constraints_list = base._get_sampling_constraints_list(base.engine.stage_configs)
assert base.sampling_constraints_list == [{"detokenize": False, "stop_token_ids": [42]}]
caller_params = SamplingParams(seed=1234, max_tokens=7, detokenize=True, stop_token_ids=[7])
assert base.sampling_constraints_list == [{"detokenize": False, "stop_token_ids": required_stop_ids}]
resolved_defaults = base.resolve_sampling_params_list(None)
assert resolved_defaults[0].stop_token_ids == [99, 151704, 151645]
caller_params = SamplingParams(seed=1234, max_tokens=7, detokenize=True, stop_token_ids=[100, 151704])
resolved = base.resolve_sampling_params_list(caller_params)
@@ -221,10 +229,10 @@ def test_resolve_sampling_params_list_preserves_stage_constraints():
assert resolved[0].seed == 1234
assert resolved[0].max_tokens == 7
assert resolved[0].detokenize is False
assert resolved[0].stop_token_ids == [42]
assert 42 in resolved[0]._all_stop_token_ids
assert resolved[0].stop_token_ids == [100, 151704, 151645]
assert {100, 151704, 151645}.issubset(resolved[0]._all_stop_token_ids)
assert caller_params.detokenize is True
assert caller_params.stop_token_ids == [7]
assert caller_params.stop_token_ids == [100, 151704]
@pytest.mark.parametrize("use_defaults", [False, True])
@@ -9,7 +9,7 @@ Covers ``vllm_omni.model_executor.stage_input_processors.minicpmo_4_5_omni.llm2t
- both inputs missing -> raises
- structured model_intermediate_buffer carries the thinker ids and text
- scheduler prompt tokens follow the selected TTS region or output tokens
- MiniCPM-o 4.5 TTS region detection on 151703 / 151704 tokens
- MiniCPM-o 4.5 TTS region detection on 151703 / 151704 / 151645 tokens
- plain chat without TTS markers conditions on the generated assistant span
- prompt arg is normalized to a list and ``multi_modal_data`` is gated by
``requires_multimodal_data``
@@ -260,13 +260,14 @@ class TestTtsRegionDetection:
)
return result[0]["model_intermediate_buffer"], hidden
def test_4_5_markers_detected(self) -> None:
@pytest.mark.parametrize("tts_end_id", [151704, 151645])
def test_4_5_markers_detected(self, tts_end_id: int) -> None:
# prompt: [10, 11]
# output: [151703, 30, 31, 151704, 40]
# full sequence: [10, 11, 151703, 30, 31, 151704, 40]
# output: [151703, 30, 31, end, 40]
# full sequence: [10, 11, 151703, 30, 31, end, 40]
# 0 1 2 3 4 5 6
# 4.5 BOS at idx 2 -> slice starts at 3; EOS at idx 5 -> slice ends at 5.
buffer, hidden = self._run([10, 11], [151703, 30, 31, 151704, 40])
# 4.5 BOS at idx 2 -> slice starts at 3; end at idx 5 -> slice ends at 5.
buffer, hidden = self._run([10, 11], [151703, 30, 31, tts_end_id, 40])
assert buffer["ids"]["tts"] == [30, 31]
assert torch.equal(torch.tensor(buffer["hidden_states"]["tts"]), hidden[3:5])
@@ -91,6 +91,10 @@ class TestPipelineTopology:
assert thinker.final_output_type == "text"
assert thinker.owns_tokenizer is True
assert thinker.requires_multimodal_data is True
assert thinker.sampling_constraints == {
"detokenize": True,
"stop_token_ids": [151704, 151645],
}
def test_talker_stage(self, pipeline: PipelineConfig) -> None:
talker = pipeline.get_stage(1)