[Bugfix][MiniCPM-o] Fix async-chunk snapshot replacement and prompt cleanup (#6406)
Signed-off-by: natureofnature <wzliu@connect.hku.hk> Co-authored-by: amy-why-3459 <wuhaiyan17@huawei.com>
This commit is contained in:
1 parent
ea0a24465b
commit
4f7c08c0eb
14 files changed
+458
-19
No files matched your search
@@ -543,6 +543,80 @@ def test_update_additional_information_deserializes_new_request_payload():
|
||||
)
|
||||
|
||||
|
||||
def test_streaming_new_request_marker_replaces_terminal_chunk_snapshot():
|
||||
from vllm_omni.engine.serialization import serialize_additional_information
|
||||
|
||||
runner = _make_runner(req_ids=("r1", "r2"), hidden_size=4)
|
||||
runner.model.replace_runtime_additional_information = True
|
||||
terminal = {
|
||||
"codes": {"audio": torch.tensor([1, 2])},
|
||||
"meta": {"cache_epoch": 0, "chunk_seq": 2, "last_chunk": True},
|
||||
}
|
||||
peer = {
|
||||
"codes": {"audio": torch.tensor([9])},
|
||||
"meta": {"cache_epoch": 3, "chunk_seq": 1, "last_chunk": False},
|
||||
}
|
||||
runner.model_intermediate_buffer.update(r1=terminal, r2=peer)
|
||||
marker = {
|
||||
"meta": {
|
||||
"finished": False,
|
||||
"is_segment_finished": True,
|
||||
"request_finished": False,
|
||||
"replace_runtime_additional_information": True,
|
||||
}
|
||||
}
|
||||
new_req = SimpleNamespace(
|
||||
req_id="r1",
|
||||
model_intermediate_buffer=marker,
|
||||
additional_information=serialize_additional_information(terminal),
|
||||
)
|
||||
|
||||
OmniGPUModelRunner._update_streaming_input_additional_info(runner, new_req, "r1")
|
||||
OmniGPUModelRunner._update_additional_information(
|
||||
runner,
|
||||
SimpleNamespace(
|
||||
scheduled_new_reqs=[new_req],
|
||||
scheduled_cached_reqs=SimpleNamespace(),
|
||||
),
|
||||
)
|
||||
|
||||
info = runner.model_intermediate_buffer["r1"]
|
||||
assert "codes" not in info
|
||||
assert info["meta"] == {
|
||||
**marker["meta"],
|
||||
"num_processed_tokens": 0,
|
||||
"resumable": True,
|
||||
}
|
||||
assert runner.requests["r1"].additional_information_cpu == info
|
||||
assert runner.model_intermediate_buffer["r2"] == peer
|
||||
|
||||
|
||||
def test_cached_empty_marker_replaces_terminal_chunk_snapshot():
|
||||
runner = _make_runner(req_ids=("r1",), hidden_size=4)
|
||||
runner.model.replace_runtime_additional_information = True
|
||||
runner.model_intermediate_buffer["r1"] = {
|
||||
"codes": {"audio": torch.tensor([1, 2])},
|
||||
"meta": {"cache_epoch": 0, "chunk_seq": 2, "last_chunk": True},
|
||||
}
|
||||
marker = {
|
||||
"meta": {
|
||||
"is_segment_finished": torch.tensor(True, dtype=torch.bool),
|
||||
"replace_runtime_additional_information": True,
|
||||
}
|
||||
}
|
||||
|
||||
OmniGPUModelRunner._update_additional_information(
|
||||
runner,
|
||||
SimpleNamespace(
|
||||
scheduled_new_reqs=[],
|
||||
scheduled_cached_reqs=SimpleNamespace(additional_information={"r1": marker}),
|
||||
),
|
||||
)
|
||||
|
||||
assert runner.model_intermediate_buffer["r1"] == marker
|
||||
assert runner.requests["r1"].additional_information_cpu == marker
|
||||
|
||||
|
||||
def test_update_intermediate_buffer_skips_empty_update():
|
||||
"""Validate that an empty update dict is a no-op."""
|
||||
runner = _make_runner(req_ids=("r1",), hidden_size=4)
|
||||
|
||||
Reference in new issue
Block a user