[Refactor] msgspec standardisation for data entry key names and improved type checks (#3149)
Signed-off-by: Divyansh Singhvi <divyanshsinghvi@gmail.com> Signed-off-by: dsinghvi <divyanshsinghvi@gmail.com>
This commit is contained in:
1 parent
9a60e11e3d
commit
e40076e872
25 files changed
+1047
-686
No files matched your search
@@ -222,7 +222,7 @@ class TestChunkCoordinatorUpdateRequestMetadata(unittest.TestCase):
|
||||
self.assertEqual(req.prompt_token_ids, [10, 20, 30])
|
||||
self.assertEqual(req.num_computed_tokens, 0)
|
||||
self.assertIsNone(req.additional_information)
|
||||
self.assertEqual(req._omni_initial_model_buffer, {"left_context_size": 25})
|
||||
self.assertEqual(req._omni_initial_model_buffer, {"meta": {"left_context_size": 25}})
|
||||
|
||||
|
||||
class TestChunkCoordinatorPostprocess(unittest.TestCase):
|
||||
|
||||
@@ -12,7 +12,7 @@ from pytest_mock import MockerFixture
|
||||
from vllm.v1.core.sched.scheduler import Scheduler as VLLMScheduler
|
||||
from vllm.v1.request import RequestStatus
|
||||
|
||||
from vllm_omni.data_entry_keys import OmniPayload
|
||||
from vllm_omni.data_entry_keys import CodesStruct, MetaStruct, OmniPayload, OmniPayloadStruct
|
||||
from vllm_omni.distributed.omni_connectors.transfer_adapter.base import OmniTransferAdapterBase
|
||||
from vllm_omni.distributed.omni_connectors.transfer_adapter.chunk_transfer_adapter import (
|
||||
OmniChunkTransferAdapter,
|
||||
@@ -140,11 +140,54 @@ def test_save_async(build_adapter):
|
||||
assert task["is_finished"] is False
|
||||
|
||||
|
||||
def test_send_single_request_struct_without_meta_does_not_crash(build_adapter, monkeypatch):
|
||||
"""Producer may return a struct with ``meta=None`` (e.g. payload that
|
||||
carries only ``embed`` or ``codes``). The sender's ``meta is not None``
|
||||
guard handles this without AttributeError; ``finished_flag`` is None and
|
||||
the cleanup path is not triggered.
|
||||
"""
|
||||
adapter, _ = build_adapter(stage_id=1)
|
||||
request = _req("req-no-meta", RequestStatus.WAITING, external_req_id="ext-no-meta")
|
||||
|
||||
adapter.custom_process_next_stage_input_func = lambda **kwargs: OmniPayloadStruct(
|
||||
codes=CodesStruct(audio=torch.tensor([1, 2], dtype=torch.long)),
|
||||
)
|
||||
cleanup_calls = []
|
||||
monkeypatch.setattr(adapter, "cleanup", lambda *a, **kw: cleanup_calls.append((a, kw)))
|
||||
|
||||
adapter._send_single_request({"pooling_output": None, "request": request, "is_finished": False})
|
||||
|
||||
assert cleanup_calls == [] # no terminal cleanup; meta.finished is unobservable
|
||||
|
||||
|
||||
def test_send_single_request_empty_struct_goes_on_wire(build_adapter, monkeypatch):
|
||||
"""Pin the contract: an explicitly empty ``OmniPayloadStruct()`` passes
|
||||
the ``payload_data is None`` check and gets sent. To skip a chunk, the
|
||||
producer must return ``None``, not an empty struct. (Filtering empty
|
||||
structs at the adapter would require introspecting all struct fields on
|
||||
every send and was rejected for cost vs. value.)
|
||||
"""
|
||||
adapter, connector = build_adapter(stage_id=1)
|
||||
request = _req("req-empty", RequestStatus.WAITING, external_req_id="ext-empty")
|
||||
|
||||
adapter.custom_process_next_stage_input_func = lambda **kwargs: OmniPayloadStruct()
|
||||
monkeypatch.setattr(adapter, "cleanup", lambda *a, **kw: None)
|
||||
|
||||
adapter._send_single_request({"pooling_output": None, "request": request, "is_finished": False})
|
||||
|
||||
assert connector.put.called
|
||||
sent_payload = connector.put.call_args.kwargs["data"]
|
||||
assert isinstance(sent_payload, OmniPayloadStruct)
|
||||
assert sent_payload.meta is None # confirms it's the empty struct on the wire
|
||||
|
||||
|
||||
def test_send_single_request_cleans_up_after_finished_payload(build_adapter, monkeypatch):
|
||||
adapter, _ = build_adapter(stage_id=1)
|
||||
request = _req("req-finished", RequestStatus.FINISHED_STOPPED, external_req_id="ext-finished")
|
||||
|
||||
adapter.custom_process_next_stage_input_func = lambda **kwargs: {"x": [1], "finished": True}
|
||||
adapter.custom_process_next_stage_input_func = lambda **kwargs: OmniPayloadStruct(
|
||||
meta=MetaStruct(finished=torch.tensor(True, dtype=torch.bool))
|
||||
)
|
||||
cleanup_calls = []
|
||||
monkeypatch.setattr(adapter, "cleanup", lambda *a, **kw: cleanup_calls.append((a, kw)))
|
||||
|
||||
@@ -604,3 +647,42 @@ def test_omni_ar_scheduler_finish_requests(mocker: MockerFixture):
|
||||
OmniARScheduler.finish_requests(sched, ["r1"], RequestStatus.FINISHED_ABORTED)
|
||||
|
||||
assert order == ["adapter", "super"]
|
||||
|
||||
|
||||
def test_wire_round_trip_struct_to_dict_contract():
|
||||
"""Pin the wire contract: encoding ``OmniPayloadStruct`` and decoding it
|
||||
yields a dict equivalent to ``to_dict(struct)``.
|
||||
|
||||
The chunk-adapter sender uses struct attribute access while the receiver
|
||||
uses dict-key access. This works only because ``OmniMsgpackDecoder`` has
|
||||
no target type and decodes structs back to plain dicts. If this test
|
||||
breaks, the receiver's dict access will silently drop fields or KeyError.
|
||||
"""
|
||||
from vllm_omni.data_entry_keys import CodesStruct, to_dict
|
||||
from vllm_omni.distributed.omni_connectors.utils.serialization import (
|
||||
OmniMsgpackDecoder,
|
||||
OmniMsgpackEncoder,
|
||||
)
|
||||
|
||||
struct = OmniPayloadStruct(
|
||||
meta=MetaStruct(
|
||||
finished=torch.tensor(True, dtype=torch.bool),
|
||||
left_context_size=12,
|
||||
),
|
||||
codes=CodesStruct(audio=torch.tensor([1, 2, 3], dtype=torch.int64)),
|
||||
)
|
||||
|
||||
encoded = OmniMsgpackEncoder().encode(struct)
|
||||
decoded = OmniMsgpackDecoder().decode(encoded)
|
||||
|
||||
assert isinstance(decoded, dict)
|
||||
assert isinstance(decoded["meta"], dict)
|
||||
assert isinstance(decoded["meta"]["finished"], torch.Tensor)
|
||||
assert bool(decoded["meta"]["finished"].item()) is True
|
||||
assert decoded["meta"]["left_context_size"] == 12
|
||||
assert torch.equal(decoded["codes"]["audio"], torch.tensor([1, 2, 3], dtype=torch.int64))
|
||||
|
||||
expected = to_dict(struct)
|
||||
assert set(decoded.keys()) == set(expected.keys())
|
||||
assert set(decoded["meta"].keys()) == set(expected["meta"].keys())
|
||||
assert set(decoded["codes"].keys()) == set(expected["codes"].keys())
|
||||
@@ -164,11 +164,12 @@ def test_forward_prefers_token_offset_when_present():
|
||||
|
||||
runtime_info = [
|
||||
{
|
||||
"speech_token": torch.tensor([[1, 2, 3]], dtype=torch.long),
|
||||
"speech_feat": torch.tensor([[[0.1, 0.2], [0.3, 0.4]]], dtype=torch.float32),
|
||||
"embedding": torch.tensor([[0.5, 0.6]], dtype=torch.float32),
|
||||
"token_offset": 2,
|
||||
"left_context_size": 1,
|
||||
"embed": {
|
||||
"speech_token": torch.tensor([[1, 2, 3]], dtype=torch.long),
|
||||
"speech_feat": torch.tensor([[[0.1, 0.2], [0.3, 0.4]]], dtype=torch.float32),
|
||||
"embedding": torch.tensor([[0.5, 0.6]], dtype=torch.float32),
|
||||
},
|
||||
"meta": {"left_context_size": 2},
|
||||
}
|
||||
]
|
||||
|
||||
@@ -193,10 +194,12 @@ def test_forward_falls_back_to_left_context_size_for_backward_compat():
|
||||
|
||||
runtime_info = [
|
||||
{
|
||||
"speech_token": torch.tensor([[1, 2, 3]], dtype=torch.long),
|
||||
"speech_feat": torch.tensor([[[0.1, 0.2], [0.3, 0.4]]], dtype=torch.float32),
|
||||
"embedding": torch.tensor([[0.5, 0.6]], dtype=torch.float32),
|
||||
"left_context_size": 2,
|
||||
"embed": {
|
||||
"speech_token": torch.tensor([[1, 2, 3]], dtype=torch.long),
|
||||
"speech_feat": torch.tensor([[[0.1, 0.2], [0.3, 0.4]]], dtype=torch.float32),
|
||||
"embedding": torch.tensor([[0.5, 0.6]], dtype=torch.float32),
|
||||
},
|
||||
"meta": {"left_context_size": 2},
|
||||
}
|
||||
]
|
||||
|
||||
@@ -214,10 +217,12 @@ def test_forward_ignores_single_request_padded_tail_tokens():
|
||||
model = _make_code2wav_model(with_stride_cfg=True)
|
||||
runtime_info = [
|
||||
{
|
||||
"speech_token": torch.tensor([[1, 2, 3]], dtype=torch.long),
|
||||
"speech_feat": torch.tensor([[[0.1, 0.2], [0.3, 0.4]]], dtype=torch.float32),
|
||||
"embedding": torch.tensor([[0.5, 0.6]], dtype=torch.float32),
|
||||
"token_offset": 0,
|
||||
"embed": {
|
||||
"speech_token": torch.tensor([[1, 2, 3]], dtype=torch.long),
|
||||
"speech_feat": torch.tensor([[[0.1, 0.2], [0.3, 0.4]]], dtype=torch.float32),
|
||||
"embedding": torch.tensor([[0.5, 0.6]], dtype=torch.float32),
|
||||
},
|
||||
"meta": {"left_context_size": 0},
|
||||
}
|
||||
]
|
||||
|
||||
@@ -238,10 +243,12 @@ def test_forward_uses_non_stream_decode_without_chunk_metadata():
|
||||
|
||||
runtime_info = [
|
||||
{
|
||||
"speech_token": torch.tensor([[1, 2, 3]], dtype=torch.long),
|
||||
"speech_feat": torch.tensor([[[0.1, 0.2], [0.3, 0.4]]], dtype=torch.float32),
|
||||
"embedding": torch.tensor([[0.5, 0.6]], dtype=torch.float32),
|
||||
"prefix_ids": [101, 102],
|
||||
"embed": {
|
||||
"speech_token": torch.tensor([[1, 2, 3]], dtype=torch.long),
|
||||
"speech_feat": torch.tensor([[[0.1, 0.2], [0.3, 0.4]]], dtype=torch.float32),
|
||||
"embedding": torch.tensor([[0.5, 0.6]], dtype=torch.float32),
|
||||
},
|
||||
"ids": {"prompt": [101, 102]},
|
||||
"generated_len": 3,
|
||||
}
|
||||
]
|
||||
@@ -275,12 +282,16 @@ def test_forward_reuses_streaming_cache_state_between_chunks():
|
||||
)
|
||||
runtime_info = [
|
||||
{
|
||||
"req_id": ["rid-stream"],
|
||||
"speech_token": torch.tensor([[1, 2, 3]], dtype=torch.long),
|
||||
"speech_feat": torch.tensor([[[0.1, 0.2], [0.3, 0.4]]], dtype=torch.float32),
|
||||
"embedding": torch.tensor([[0.5, 0.6]], dtype=torch.float32),
|
||||
"token_offset": 0,
|
||||
"stream_finished": torch.tensor(False),
|
||||
"embed": {
|
||||
"speech_token": torch.tensor([[1, 2, 3]], dtype=torch.long),
|
||||
"speech_feat": torch.tensor([[[0.1, 0.2], [0.3, 0.4]]], dtype=torch.float32),
|
||||
"embedding": torch.tensor([[0.5, 0.6]], dtype=torch.float32),
|
||||
},
|
||||
"meta": {
|
||||
"req_id": ["rid-stream"],
|
||||
"stream_finished": torch.tensor(False),
|
||||
"left_context_size": 0,
|
||||
},
|
||||
}
|
||||
]
|
||||
|
||||
@@ -321,12 +332,16 @@ def test_forward_clears_streaming_cache_on_terminal_chunk():
|
||||
)
|
||||
runtime_info = [
|
||||
{
|
||||
"req_id": ["rid-stream"],
|
||||
"speech_token": torch.tensor([[1, 2, 3]], dtype=torch.long),
|
||||
"speech_feat": torch.tensor([[[0.1, 0.2], [0.3, 0.4]]], dtype=torch.float32),
|
||||
"embedding": torch.tensor([[0.5, 0.6]], dtype=torch.float32),
|
||||
"token_offset": 0,
|
||||
"stream_finished": torch.tensor(False),
|
||||
"embed": {
|
||||
"speech_token": torch.tensor([[1, 2, 3]], dtype=torch.long),
|
||||
"speech_feat": torch.tensor([[[0.1, 0.2], [0.3, 0.4]]], dtype=torch.float32),
|
||||
"embedding": torch.tensor([[0.5, 0.6]], dtype=torch.float32),
|
||||
},
|
||||
"meta": {
|
||||
"req_id": ["rid-stream"],
|
||||
"stream_finished": torch.tensor(False),
|
||||
"left_context_size": 0,
|
||||
},
|
||||
}
|
||||
]
|
||||
|
||||
@@ -338,7 +353,7 @@ def test_forward_clears_streaming_cache_on_terminal_chunk():
|
||||
)
|
||||
assert "rid-stream" in model._stream_vocoder_cache_by_req
|
||||
|
||||
runtime_info[0]["stream_finished"] = torch.tensor(True)
|
||||
runtime_info[0]["meta"]["stream_finished"] = torch.tensor(True)
|
||||
out = model.forward(
|
||||
input_ids=torch.tensor([0, 1, 2], dtype=torch.long),
|
||||
positions=torch.tensor([0, 1, 2], dtype=torch.long),
|
||||
|
||||
+33
-32
@@ -64,9 +64,11 @@ def test_talker2code2wav_async_chunk_final_payload_uses_absolute_token_offset():
|
||||
external_req_id="rid-0",
|
||||
output_token_ids=[1, 2, 6562, 3],
|
||||
additional_information={
|
||||
"speech_token": [torch.tensor([[11, 12, 13]])],
|
||||
"speech_feat": [torch.tensor([[[0.1, 0.2], [0.3, 0.4]]])],
|
||||
"embedding": [torch.tensor([[0.5, 0.6]])],
|
||||
"embed": {
|
||||
"speech_token": [torch.tensor([[11, 12, 13]])],
|
||||
"speech_feat": [torch.tensor([[[0.1, 0.2], [0.3, 0.4]]])],
|
||||
"embedding": [torch.tensor([[0.5, 0.6]])],
|
||||
},
|
||||
},
|
||||
is_finished=lambda: True,
|
||||
)
|
||||
@@ -79,15 +81,14 @@ def test_talker2code2wav_async_chunk_final_payload_uses_absolute_token_offset():
|
||||
)
|
||||
|
||||
assert payload is not None
|
||||
assert payload["meta"]["finished"].item() is True
|
||||
assert payload["codes"]["audio"] == [1, 2, 3]
|
||||
assert payload["token_offset"] == 0
|
||||
assert payload["left_context_size"] == 0
|
||||
assert payload["req_id"] == ["rid-0"]
|
||||
assert payload["stream_finished"].item() is True
|
||||
assert "speech_token" in payload
|
||||
assert "speech_feat" in payload
|
||||
assert "embedding" in payload
|
||||
assert payload.meta.finished.item() is True
|
||||
assert payload.codes.audio.tolist() == [1, 2, 3]
|
||||
assert payload.meta.left_context_size == 0
|
||||
assert payload.meta.req_id == ["rid-0"]
|
||||
assert payload.meta.stream_finished.item() is True
|
||||
assert payload.embed.speech_token is not None
|
||||
assert payload.embed.speech_feat is not None
|
||||
assert payload.embed.embedding is not None
|
||||
|
||||
|
||||
def test_talker2code2wav_async_chunk_emits_eof_when_finished_without_valid_codes():
|
||||
@@ -107,8 +108,8 @@ def test_talker2code2wav_async_chunk_emits_eof_when_finished_without_valid_codes
|
||||
)
|
||||
|
||||
assert payload is not None
|
||||
assert payload["codes"]["audio"] == []
|
||||
assert payload["meta"]["finished"].item() is True
|
||||
assert payload.codes.audio.tolist() == []
|
||||
assert payload.meta.finished.item() is True
|
||||
|
||||
|
||||
def test_talker2code2wav_async_chunk_does_not_reemit_without_new_tokens():
|
||||
@@ -134,8 +135,8 @@ def test_talker2code2wav_async_chunk_does_not_reemit_without_new_tokens():
|
||||
)
|
||||
|
||||
assert payload1 is not None
|
||||
assert payload1["codes"]["audio"] == [1, 2]
|
||||
assert payload1["token_offset"] == 0
|
||||
assert payload1.codes.audio.tolist() == [1, 2]
|
||||
assert payload1.meta.left_context_size == 0
|
||||
assert payload2 is None
|
||||
|
||||
|
||||
@@ -164,9 +165,9 @@ def test_talker2code2wav_async_chunk_waits_for_prelookahead_and_emits_cumulative
|
||||
|
||||
assert payload_pending is None
|
||||
assert payload_ready is not None
|
||||
assert payload_ready["codes"]["audio"] == [1, 2, 3]
|
||||
assert payload_ready["token_offset"] == 0
|
||||
assert payload_ready["meta"]["finished"].item() is False
|
||||
assert payload_ready.codes.audio.tolist() == [1, 2, 3]
|
||||
assert payload_ready.meta.left_context_size == 0
|
||||
assert payload_ready.meta.finished.item() is False
|
||||
|
||||
|
||||
def test_talker2code2wav_async_chunk_final_flush_uses_previous_token_offset():
|
||||
@@ -193,13 +194,13 @@ def test_talker2code2wav_async_chunk_final_flush_uses_previous_token_offset():
|
||||
)
|
||||
|
||||
assert payload_stream is not None
|
||||
assert payload_stream["meta"]["finished"].item() is False
|
||||
assert payload_stream["codes"]["audio"] == [3, 4, 5]
|
||||
assert payload_stream["token_offset"] == 0
|
||||
assert payload_stream.meta.finished.item() is False
|
||||
assert payload_stream.codes.audio.tolist() == [3, 4, 5]
|
||||
assert payload_stream.meta.left_context_size == 0
|
||||
assert payload_final is not None
|
||||
assert payload_final["meta"]["finished"].item() is True
|
||||
assert payload_final["codes"]["audio"] == [3, 4, 5, 6]
|
||||
assert payload_final["token_offset"] == 2
|
||||
assert payload_final.meta.finished.item() is True
|
||||
assert payload_final.codes.audio.tolist() == [3, 4, 5, 6]
|
||||
assert payload_final.meta.left_context_size == 2
|
||||
|
||||
|
||||
def test_talker2code2wav_async_chunk_respects_prompt_token_pad_on_first_chunk():
|
||||
@@ -208,7 +209,7 @@ def test_talker2code2wav_async_chunk_respects_prompt_token_pad_on_first_chunk():
|
||||
external_req_id="rid-pad",
|
||||
output_token_ids=[8, 9, 10],
|
||||
additional_information={
|
||||
"speech_token": [torch.tensor([[1, 2, 3]])],
|
||||
"embed": {"speech_token": [torch.tensor([[1, 2, 3]])]},
|
||||
},
|
||||
is_finished=lambda: False,
|
||||
)
|
||||
@@ -229,8 +230,8 @@ def test_talker2code2wav_async_chunk_respects_prompt_token_pad_on_first_chunk():
|
||||
|
||||
assert payload_pending is None
|
||||
assert payload_ready is not None
|
||||
assert payload_ready["codes"]["audio"] == [8, 9, 10, 11]
|
||||
assert payload_ready["token_offset"] == 0
|
||||
assert payload_ready.codes.audio.tolist() == [8, 9, 10, 11]
|
||||
assert payload_ready.meta.left_context_size == 0
|
||||
|
||||
|
||||
def test_talker2code2wav_async_chunk_emits_terminal_eof_without_duplicate_audio():
|
||||
@@ -256,8 +257,8 @@ def test_talker2code2wav_async_chunk_emits_terminal_eof_without_duplicate_audio(
|
||||
)
|
||||
|
||||
assert payload_stream is not None
|
||||
assert payload_stream["meta"]["finished"].item() is False
|
||||
assert payload_stream["codes"]["audio"] == [3, 4]
|
||||
assert payload_stream.meta.finished.item() is False
|
||||
assert payload_stream.codes.audio.tolist() == [3, 4]
|
||||
assert payload_final is not None
|
||||
assert payload_final["meta"]["finished"].item() is True
|
||||
assert payload_final["codes"]["audio"] == []
|
||||
assert payload_final.meta.finished.item() is True
|
||||
assert payload_final.codes.audio.tolist() == []
|
||||
+9
-9
@@ -20,16 +20,16 @@ def test_flush_remaining_codes_when_no_codes_accumulated_missing_request_id():
|
||||
"""No entry for request_id: treat as empty, return finished sentinel with empty codes."""
|
||||
tm = SimpleNamespace(code_prompt_token_ids={})
|
||||
out = _flush_remaining_codes(tm, "missing", chunk_size=3, left_context_size=3)
|
||||
assert out["codes"]["audio"] == _sentinel()["codes"]["audio"]
|
||||
assert out["meta"]["finished"].item() is True
|
||||
assert out.codes.audio.tolist() == _sentinel()["codes"]["audio"]
|
||||
assert out.meta.finished.item() is True
|
||||
|
||||
|
||||
def test_flush_remaining_codes_when_no_codes_accumulated_empty_list():
|
||||
"""Explicit empty accumulation list returns the same sentinel."""
|
||||
tm = SimpleNamespace(code_prompt_token_ids={"r": []})
|
||||
out = _flush_remaining_codes(tm, "r", chunk_size=3, left_context_size=3)
|
||||
assert out["codes"]["audio"] == []
|
||||
assert out["meta"]["finished"].item() is True
|
||||
assert out.codes.audio.tolist() == []
|
||||
assert out.meta.finished.item() is True
|
||||
|
||||
|
||||
def test_flush_remaining_codes_partial_chunk_remaining():
|
||||
@@ -41,8 +41,8 @@ def test_flush_remaining_codes_partial_chunk_remaining():
|
||||
code_prompt_token_ids={"r": [[1], [2], [3], [4], [5], [6], [7]]},
|
||||
)
|
||||
out = _flush_remaining_codes(tm, "r", chunk_size=3, left_context_size=3)
|
||||
assert out["meta"]["finished"].item() is True
|
||||
assert out["codes"]["audio"] == [4, 5, 6, 7]
|
||||
assert out.meta.finished.item() is True
|
||||
assert out.codes.audio.tolist() == [4, 5, 6, 7]
|
||||
|
||||
|
||||
def test_flush_remaining_codes_when_length_is_exact_multiple_of_chunk_size():
|
||||
@@ -52,7 +52,7 @@ def test_flush_remaining_codes_when_length_is_exact_multiple_of_chunk_size():
|
||||
)
|
||||
out = _flush_remaining_codes(tm, "r", chunk_size=3, left_context_size=3)
|
||||
# context_length = chunk_size = 3, end_index = min(6, 6) -> all 6
|
||||
assert out["codes"]["audio"] == [1, 2, 3, 4, 5, 6]
|
||||
assert out.codes.audio.tolist() == [1, 2, 3, 4, 5, 6]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -74,5 +74,5 @@ def test_flush_remaining_codes_context_window_end_index(
|
||||
tm = SimpleNamespace(code_prompt_token_ids={"r": accumulated})
|
||||
out = _flush_remaining_codes(tm, "r", chunk_size=chunk_size, left_context_size=left_context)
|
||||
expected_flat = list(range(length - expected_end_index, length))
|
||||
assert out["codes"]["audio"] == expected_flat
|
||||
assert out["meta"]["finished"].item() is True
|
||||
assert out.codes.audio.tolist() == expected_flat
|
||||
assert out.meta.finished.item() is True
|
||||
@@ -80,8 +80,8 @@ def test_eof_marker_when_finished_empty():
|
||||
request=_req("r", finished=True),
|
||||
is_finished=True,
|
||||
)
|
||||
assert p["codes"] == {"audio": []}
|
||||
assert p["meta"]["finished"].item() is True
|
||||
assert p.codes.audio.tolist() == []
|
||||
assert p.meta.finished.item() is True
|
||||
|
||||
|
||||
def test_flush_on_finish():
|
||||
@@ -94,8 +94,8 @@ def test_flush_on_finish():
|
||||
is_finished=True,
|
||||
)
|
||||
assert p is not None
|
||||
assert p["meta"]["finished"].item() is True
|
||||
assert len(p["codes"]["audio"]) == _Q * 24
|
||||
assert p.meta.finished.item() is True
|
||||
assert len(p.codes.audio) == _Q * 24
|
||||
|
||||
|
||||
_CASES = [
|
||||
@@ -149,8 +149,8 @@ def test_streaming_phases(config, n_frames, finished, expected):
|
||||
else:
|
||||
exp_ctx, exp_window = expected
|
||||
assert payload is not None
|
||||
assert payload["meta"]["left_context_size"] == exp_ctx
|
||||
assert len(payload["codes"]["audio"]) == _Q * exp_window
|
||||
assert payload.meta.left_context_size == exp_ctx
|
||||
assert len(payload.codes.audio) == _Q * exp_window
|
||||
|
||||
|
||||
def test_dynamic_ic_adapts_to_load():
|
||||
@@ -160,14 +160,14 @@ def test_dynamic_ic_adapts_to_load():
|
||||
# Low load (1/8) -> IC=2 -> emit at 2
|
||||
p1 = _call(tm, "r", n_frames=2)
|
||||
assert p1 is not None
|
||||
assert len(p1["codes"]["audio"]) == _Q * 2
|
||||
assert len(p1.codes.audio) == _Q * 2
|
||||
|
||||
# High load on a new request: active=6/8 -> IC=8 -> emit at 8
|
||||
for i in range(4):
|
||||
tm.code_prompt_token_ids[f"other-{i}"] = [[0]]
|
||||
p2 = _call(tm, "new-high-load", n_frames=8)
|
||||
assert p2 is not None
|
||||
assert len(p2["codes"]["audio"]) == _Q * 8
|
||||
assert len(p2.codes.audio) == _Q * 8
|
||||
|
||||
# Requests past initial phase still count in load factor
|
||||
tm2 = _tm(max_num_seqs=4)
|
||||
@@ -176,7 +176,7 @@ def test_dynamic_ic_adapts_to_load():
|
||||
# active=4/4=1.0 -> IC=16
|
||||
p3 = _call(tm2, "new", n_frames=16)
|
||||
assert p3 is not None
|
||||
assert len(p3["codes"]["audio"]) == _Q * 16
|
||||
assert len(p3.codes.audio) == _Q * 16
|
||||
|
||||
|
||||
def test_ic_load_change_mid_request():
|
||||
@@ -195,7 +195,7 @@ def test_ic_load_change_mid_request():
|
||||
assert _call(tm, "r", n_frames=25) is None
|
||||
p3 = _call(tm, "r", n_frames=27)
|
||||
assert p3 is not None
|
||||
assert p3["meta"]["left_context_size"] == 2
|
||||
assert p3.meta.left_context_size == 2
|
||||
|
||||
# A *new* request under high load gets IC=16 (not IC=2).
|
||||
# Frame 2 would emit under IC=2 but must hold under IC=16.
|
||||
@@ -214,13 +214,13 @@ def test_connector_initial_chunk_config_overrides_dynamic_ic():
|
||||
|
||||
p1 = _call(tm, "r", n_frames=4)
|
||||
assert p1 is not None
|
||||
assert len(p1["codes"]["audio"]) == _Q * 4
|
||||
assert len(p1.codes.audio) == _Q * 4
|
||||
|
||||
# Only the first chunk uses the small size; the next emit is 4+25.
|
||||
assert _call(tm, "r", n_frames=25) is None
|
||||
p2 = _call(tm, "r", n_frames=29)
|
||||
assert p2 is not None
|
||||
assert p2["meta"]["left_context_size"] == 4
|
||||
assert p2.meta.left_context_size == 4
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -268,8 +268,8 @@ def test_first_streaming_chunk_prepends_ref_code_context():
|
||||
)
|
||||
|
||||
assert payload is not None
|
||||
assert payload["meta"]["left_context_size"] == 2
|
||||
assert len(payload["codes"]["audio"]) == _Q * 12
|
||||
assert payload.meta.left_context_size == 2
|
||||
assert len(payload.codes.audio) == _Q * 12
|
||||
|
||||
|
||||
def test_ref_code_context_applies_to_all_streaming_chunks():
|
||||
@@ -290,8 +290,8 @@ def test_ref_code_context_applies_to_all_streaming_chunks():
|
||||
|
||||
assert payload is not None
|
||||
# ref_code (2 frames) prepended as left context on second chunk too
|
||||
assert payload["meta"]["left_context_size"] == 10 + 2
|
||||
assert len(payload["codes"]["audio"]) == _Q * (35 + 2)
|
||||
assert payload.meta.left_context_size == 10 + 2
|
||||
assert len(payload.codes.audio) == _Q * (35 + 2)
|
||||
|
||||
|
||||
def test_ref_code_context_can_be_buffered_before_first_emit():
|
||||
@@ -325,8 +325,8 @@ def test_ref_code_context_can_be_buffered_before_first_emit():
|
||||
|
||||
assert payload is not None
|
||||
# ref_code (2 frames) is kept (not popped) for subsequent chunks
|
||||
assert payload["meta"]["left_context_size"] == 2
|
||||
assert len(payload["codes"]["audio"]) == _Q * 12
|
||||
assert payload.meta.left_context_size == 2
|
||||
assert len(payload.codes.audio) == _Q * 12
|
||||
assert rid in tm.request_payload
|
||||
|
||||
|
||||
@@ -353,7 +353,7 @@ def test_non_async_processor_prepends_ref_code_and_sets_trim_context():
|
||||
|
||||
assert len(prompts) == 1
|
||||
prompt = prompts[0]
|
||||
assert prompt["additional_information"] == {"meta": {"left_context_size": [2]}}
|
||||
assert prompt["additional_information"] == {"meta": {"left_context_size": 2}}
|
||||
assert prompt["prompt_token_ids"] == [
|
||||
9,
|
||||
8,
|
||||
@@ -401,4 +401,4 @@ def test_non_async_processor_filters_out_of_range_codec_values():
|
||||
prompt = prompts[0]
|
||||
# Only ref_code (1 frame) + 2 valid frames = 3 frames * 4 quantizers = 12 codes
|
||||
assert len(prompt["prompt_token_ids"]) == 4 * 3
|
||||
assert prompt["additional_information"] == {"meta": {"left_context_size": [1]}}
|
||||
assert prompt["additional_information"] == {"meta": {"left_context_size": 1}}
|
||||
@@ -57,8 +57,8 @@ def test_latent2vae_async_chunk_serializes_latent_payload():
|
||||
)
|
||||
|
||||
assert payload is not None
|
||||
assert torch.equal(payload["finished"], torch.tensor(False, dtype=torch.bool))
|
||||
recovered = _decode_serialized_latent(payload["code_predictor_codes"])
|
||||
assert torch.equal(payload.meta.finished, torch.tensor(False, dtype=torch.bool))
|
||||
recovered = _decode_serialized_latent(payload.codes.audio.tolist())
|
||||
torch.testing.assert_close(recovered, latent.to(torch.bfloat16).to(torch.float32).unsqueeze(0))
|
||||
|
||||
|
||||
@@ -70,10 +70,8 @@ def test_latent2vae_async_chunk_returns_terminal_marker_without_latent():
|
||||
is_finished=False,
|
||||
)
|
||||
|
||||
assert payload == {
|
||||
"code_predictor_codes": [],
|
||||
"finished": torch.tensor(True, dtype=torch.bool),
|
||||
}
|
||||
assert payload.codes.audio.tolist() == []
|
||||
assert torch.equal(payload.meta.finished, torch.tensor(True, dtype=torch.bool))
|
||||
|
||||
|
||||
def test_latent2vae_async_chunk_returns_none_for_nonterminal_empty_chunk():
|
||||
|
||||
@@ -114,8 +114,8 @@ def test_flush_tail_when_finished():
|
||||
)
|
||||
|
||||
assert payload is not None
|
||||
assert payload["meta"]["finished"].item() is True
|
||||
codes = payload["codes"]["audio"]
|
||||
assert payload.meta.finished.item() is True
|
||||
codes = payload.codes.audio
|
||||
# Format: [ctx_frames, context_length, ...flat_codes]
|
||||
assert len(codes) >= 2 # At least ctx_frames + context_length header
|
||||
ctx_frames = codes[0]
|
||||
@@ -137,8 +137,8 @@ def test_eof_marker_when_finished_with_no_frames():
|
||||
request=request,
|
||||
)
|
||||
|
||||
assert payload["codes"] == {"audio": []}
|
||||
assert payload["meta"]["finished"].item() is True
|
||||
assert payload.codes.audio.tolist() == []
|
||||
assert payload.meta.finished.item() is True
|
||||
|
||||
|
||||
def test_normal_chunk_emission():
|
||||
@@ -162,7 +162,7 @@ def test_normal_chunk_emission():
|
||||
|
||||
# A chunk should be emitted
|
||||
assert payload is not None
|
||||
codes = payload["codes"]["audio"]
|
||||
codes = payload.codes.audio
|
||||
ctx_frames = codes[0]
|
||||
context_length = codes[1]
|
||||
assert ctx_frames == 20 # 25 - 5(chunk_size_at_begin)
|
||||
@@ -189,7 +189,7 @@ def test_small_initial_chunks():
|
||||
)
|
||||
|
||||
assert payload is not None
|
||||
codes = payload["codes"]["audio"]
|
||||
codes = payload.codes.audio
|
||||
ctx_frames = codes[0]
|
||||
context_length = codes[1]
|
||||
assert ctx_frames == 0
|
||||
@@ -238,19 +238,16 @@ def test_context_handling_format():
|
||||
)
|
||||
|
||||
assert payload is not None
|
||||
codes = payload["codes"]["audio"]
|
||||
# First two elements are ctx_frames and context_length
|
||||
ctx_frames = codes[0]
|
||||
context_length = codes[1]
|
||||
codes = payload.codes.audio
|
||||
# codes is a 1-D long tensor: [ctx_frames, context_length, ...flat_codes]
|
||||
ctx_frames = int(codes[0].item())
|
||||
context_length = int(codes[1].item())
|
||||
flat_codes = codes[2:]
|
||||
# The window has ctx_frames + context_length frames
|
||||
assert isinstance(ctx_frames, int)
|
||||
assert isinstance(context_length, int)
|
||||
assert ctx_frames >= 0
|
||||
assert context_length > 0
|
||||
# flat_codes = total_window_frames * codebook_dim
|
||||
total_window_frames = ctx_frames + context_length
|
||||
assert len(flat_codes) == total_window_frames * 2 # codebook_dim=2
|
||||
assert flat_codes.numel() == total_window_frames * 2 # codebook_dim=2
|
||||
|
||||
|
||||
def test_none_pooling_output_not_finished_returns_none():
|
||||
|
||||
+156
-28
@@ -1,41 +1,175 @@
|
||||
"""Tests for data_entry_keys: TypedDict payload structure, flatten/unflatten, serialize/deserialize."""
|
||||
"""Tests for data_entry_keys."""
|
||||
|
||||
import msgspec
|
||||
import pytest
|
||||
import torch
|
||||
|
||||
from vllm_omni.data_entry_keys import (
|
||||
CodesStruct,
|
||||
EmbeddingsStruct,
|
||||
HiddenStatesStruct,
|
||||
IdsStruct,
|
||||
MetaStruct,
|
||||
OmniPayload,
|
||||
OmniPayloadStruct,
|
||||
deserialize_payload,
|
||||
flatten_payload,
|
||||
serialize_payload,
|
||||
to_dict,
|
||||
to_struct,
|
||||
unflatten_payload,
|
||||
)
|
||||
from vllm_omni.engine import AdditionalInformationPayload
|
||||
|
||||
|
||||
class TestOmniPayload:
|
||||
def test_nested_payload_structure(self):
|
||||
"""Verify OmniPayload can be constructed with nested dicts."""
|
||||
payload: OmniPayload = {
|
||||
"hidden_states": {"output": torch.tensor([1.0])},
|
||||
"embed": {"prefill": torch.tensor([2.0])},
|
||||
"codes": {"audio": torch.tensor([3.0])},
|
||||
"ids": {"all": [1, 2, 3]},
|
||||
"meta": {"finished": torch.tensor(True, dtype=torch.bool)},
|
||||
class TestOmniPayloadStruct:
|
||||
"""Runtime-validated mirror of OmniPayload (msgspec.Struct)."""
|
||||
|
||||
def test_to_struct_validates_dict(self):
|
||||
d = {"meta": {"left_context_size": 25, "finished": torch.tensor(False)}}
|
||||
s = to_struct(d)
|
||||
assert s.meta.left_context_size == 25
|
||||
|
||||
def test_to_struct_rejects_legacy_flat_top_level(self):
|
||||
with pytest.raises(msgspec.ValidationError, match="unknown field"):
|
||||
to_struct({"code_predictor_codes": torch.zeros(3, 8)})
|
||||
|
||||
def test_to_struct_rejects_legacy_flat_meta_field(self):
|
||||
# `left_context_size` at top level (legacy) instead of under `meta`
|
||||
with pytest.raises(msgspec.ValidationError, match="unknown field"):
|
||||
to_struct({"left_context_size": 25})
|
||||
|
||||
def test_to_struct_rejects_typo_in_subkey(self):
|
||||
with pytest.raises(msgspec.ValidationError, match="unknown field"):
|
||||
to_struct({"meta": {"finisheed": True}})
|
||||
|
||||
def test_to_struct_rejects_wrong_type(self):
|
||||
with pytest.raises(msgspec.ValidationError, match="Expected"):
|
||||
to_struct({"meta": {"left_context_size": "not_an_int"}})
|
||||
|
||||
def test_round_trip_dict_struct_dict(self):
|
||||
original = {
|
||||
"meta": {"left_context_size": 7, "finished": torch.tensor(True)},
|
||||
"codes": {"audio": torch.zeros(2, 8)},
|
||||
"hidden_states": {"output": torch.zeros(4, 16)},
|
||||
}
|
||||
assert torch.equal(payload["hidden_states"]["output"], torch.tensor([1.0]))
|
||||
assert torch.equal(payload["embed"]["prefill"], torch.tensor([2.0]))
|
||||
assert torch.equal(payload["codes"]["audio"], torch.tensor([3.0]))
|
||||
assert payload["ids"]["all"] == [1, 2, 3]
|
||||
assert payload["meta"]["finished"].item() is True
|
||||
s = to_struct(original)
|
||||
d = to_dict(s)
|
||||
assert sorted(d.keys()) == sorted(original.keys())
|
||||
for top, sub in original.items():
|
||||
assert sorted(d[top].keys()) == sorted(sub.keys())
|
||||
|
||||
def test_partial_payload(self):
|
||||
"""OmniPayload fields are all optional (total=False)."""
|
||||
payload: OmniPayload = {"meta": {"finished": torch.tensor(False, dtype=torch.bool)}}
|
||||
assert payload["meta"]["finished"].item() is False
|
||||
def test_to_dict_drops_unset_fields(self):
|
||||
s = OmniPayloadStruct(meta=MetaStruct(left_context_size=10))
|
||||
d = to_dict(s)
|
||||
assert d == {"meta": {"left_context_size": 10}}
|
||||
|
||||
def test_empty_payload(self):
|
||||
payload: OmniPayload = {}
|
||||
assert len(payload) == 0
|
||||
def test_struct_with_all_categories(self):
|
||||
d = {
|
||||
"hidden_states": {"output": torch.zeros(1)},
|
||||
"embed": {"prefill": torch.zeros(1), "tts_bos": torch.zeros(1)},
|
||||
"ids": {"all": [1, 2], "prompt": [1]},
|
||||
"codes": {"audio": torch.zeros(1)},
|
||||
"meta": {"left_context_size": 3, "num_processed_tokens": 7},
|
||||
}
|
||||
s = to_struct(d)
|
||||
assert isinstance(s.hidden_states, HiddenStatesStruct)
|
||||
assert isinstance(s.embed, EmbeddingsStruct)
|
||||
assert isinstance(s.ids, IdsStruct)
|
||||
assert isinstance(s.codes, CodesStruct)
|
||||
assert isinstance(s.meta, MetaStruct)
|
||||
assert s.ids.all == [1, 2]
|
||||
assert s.meta.num_processed_tokens == 7
|
||||
|
||||
|
||||
class TestValidatePayload:
|
||||
def test_raises_on_unknown_top_level(self):
|
||||
from vllm_omni.data_entry_keys import validate_payload
|
||||
|
||||
with pytest.raises(msgspec.ValidationError, match="unknown field"):
|
||||
validate_payload({"code_predictor_codes": torch.zeros(3, 8)}, context="test_boundary")
|
||||
|
||||
def test_raises_on_unknown_sub_key(self):
|
||||
from vllm_omni.data_entry_keys import validate_payload
|
||||
|
||||
with pytest.raises(msgspec.ValidationError, match="unknown field"):
|
||||
validate_payload({"meta": {"finisheed": True}})
|
||||
|
||||
def test_none_is_ok(self):
|
||||
from vllm_omni.data_entry_keys import validate_payload
|
||||
|
||||
validate_payload(None) # should not raise
|
||||
|
||||
def test_valid_payload_passes(self):
|
||||
from vllm_omni.data_entry_keys import validate_payload
|
||||
|
||||
validate_payload({"meta": {"left_context_size": 5}})
|
||||
|
||||
def test_context_in_error_message(self):
|
||||
from vllm_omni.data_entry_keys import validate_payload
|
||||
|
||||
with pytest.raises(msgspec.ValidationError, match="my_call_site"):
|
||||
validate_payload({"bad": 1}, context="my_call_site")
|
||||
|
||||
|
||||
class TestWireEquivalenceStructVsDict:
|
||||
"""Producer return-side migration invariant: encoding an ``OmniPayloadStruct``
|
||||
via the connector serializer must decode to the same payload as encoding
|
||||
the equivalent ``to_dict(struct)``.
|
||||
|
||||
Guards against regressions where the wire format diverges between the two
|
||||
paths (e.g. msgspec adds a struct tag, or ``to_dict`` drops a non-default
|
||||
sub-field that ``omit_defaults`` retains).
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def _round_trip(obj):
|
||||
from vllm_omni.distributed.omni_connectors.utils.serialization import (
|
||||
OmniMsgpackDecoder,
|
||||
OmniMsgpackEncoder,
|
||||
)
|
||||
|
||||
return OmniMsgpackDecoder().decode(OmniMsgpackEncoder().encode(obj))
|
||||
|
||||
@staticmethod
|
||||
def _assert_decoded_equal(a, b):
|
||||
if isinstance(a, dict):
|
||||
assert isinstance(b, dict)
|
||||
assert sorted(a.keys()) == sorted(b.keys())
|
||||
for k in a:
|
||||
TestWireEquivalenceStructVsDict._assert_decoded_equal(a[k], b[k])
|
||||
elif isinstance(a, torch.Tensor):
|
||||
assert isinstance(b, torch.Tensor)
|
||||
assert a.dtype == b.dtype
|
||||
assert a.shape == b.shape
|
||||
assert torch.equal(a, b)
|
||||
elif isinstance(a, list):
|
||||
assert isinstance(b, list) and len(a) == len(b)
|
||||
for x, y in zip(a, b, strict=True):
|
||||
TestWireEquivalenceStructVsDict._assert_decoded_equal(x, y)
|
||||
else:
|
||||
assert a == b
|
||||
|
||||
def test_basic_payload(self):
|
||||
struct = OmniPayloadStruct(
|
||||
codes=CodesStruct(audio=torch.tensor([1, 2, 3], dtype=torch.long)),
|
||||
meta=MetaStruct(left_context_size=10, finished=torch.tensor(True, dtype=torch.bool)),
|
||||
)
|
||||
self._assert_decoded_equal(self._round_trip(struct), self._round_trip(to_dict(struct)))
|
||||
|
||||
def test_nested_sub_structs(self):
|
||||
# Exercises depth-2 sub-struct encoding (embed.*) which was the case that
|
||||
# exposed schema drift in the #1829 migration.
|
||||
struct = OmniPayloadStruct(
|
||||
codes=CodesStruct(audio=torch.tensor([5, 6], dtype=torch.long)),
|
||||
meta=MetaStruct(finished=torch.tensor(False, dtype=torch.bool)),
|
||||
embed=EmbeddingsStruct(
|
||||
speech_token=torch.tensor([[1, 2, 3]]),
|
||||
speech_feat=torch.tensor([[[0.1, 0.2], [0.3, 0.4]]]),
|
||||
embedding=torch.tensor([[0.5, 0.6]]),
|
||||
),
|
||||
)
|
||||
self._assert_decoded_equal(self._round_trip(struct), self._round_trip(to_dict(struct)))
|
||||
|
||||
|
||||
class TestFlattenPayload:
|
||||
@@ -76,9 +210,6 @@ class TestFlattenPayload:
|
||||
assert torch.equal(flat["hidden_states.layer_24"], torch.tensor([3.0]))
|
||||
assert "hidden_states.layers" not in flat
|
||||
|
||||
def test_empty_payload(self):
|
||||
assert flatten_payload({}) == {}
|
||||
|
||||
def test_mixed_nested_and_top_level(self):
|
||||
nested: OmniPayload = {
|
||||
"codes": {"audio": torch.tensor([1.0])},
|
||||
@@ -118,9 +249,6 @@ class TestUnflattenPayload:
|
||||
assert torch.equal(nested["hidden_states"]["layers"][0], torch.tensor([2.0]))
|
||||
assert torch.equal(nested["hidden_states"]["layers"][24], torch.tensor([3.0]))
|
||||
|
||||
def test_empty_payload(self):
|
||||
assert unflatten_payload({}) == {}
|
||||
|
||||
|
||||
class TestFlattenUnflattenRoundTrip:
|
||||
def test_round_trip_simple(self):
|
||||
|
||||
@@ -1044,10 +1044,12 @@ class TestAsyncPayloadLifecycle(unittest.TestCase):
|
||||
)
|
||||
host._request_ids_mapping["r1"] = "r1"
|
||||
payload = {
|
||||
"thinker_decode_embeddings": torch.ones(1, 2),
|
||||
"thinker_output_token_ids": [1],
|
||||
"override_keys": ["thinker_decode_embeddings", "thinker_output_token_ids"],
|
||||
"finished": torch.tensor(False),
|
||||
"embed": {"decode": torch.ones(1, 2)},
|
||||
"ids": {"output": [1]},
|
||||
"meta": {
|
||||
"finished": torch.tensor(False),
|
||||
"override_keys": [["embed", "decode"], ["ids", "output"]],
|
||||
},
|
||||
}
|
||||
|
||||
host._accumulate_payload("r1", dict(payload))
|
||||
@@ -1065,15 +1067,16 @@ class TestAsyncPayloadLifecycle(unittest.TestCase):
|
||||
model_config=_make_model_config(stage_id=1, async_chunk=True, worker_type="ar"),
|
||||
)
|
||||
payload = {
|
||||
"thinker_output_token_ids": [1, 2, 3],
|
||||
"finished": torch.tensor(False),
|
||||
"override_keys": [
|
||||
"thinker_output_token_ids",
|
||||
"thinker_decode_embeddings_token_start",
|
||||
"thinker_decode_embeddings_token_end",
|
||||
],
|
||||
"thinker_decode_embeddings_token_start": 2,
|
||||
"thinker_decode_embeddings_token_end": 3,
|
||||
"ids": {"output": [1, 2, 3]},
|
||||
"embed": {"decode_token_start": 2, "decode_token_end": 3},
|
||||
"meta": {
|
||||
"finished": torch.tensor(False),
|
||||
"override_keys": [
|
||||
["ids", "output"],
|
||||
["embed", "decode_token_start"],
|
||||
["embed", "decode_token_end"],
|
||||
],
|
||||
},
|
||||
}
|
||||
self.assertFalse(host._payload_is_consumable(payload))
|
||||
host.shutdown_omni_connectors()
|
||||
@@ -1085,9 +1088,9 @@ class TestAsyncPayloadLifecycle(unittest.TestCase):
|
||||
model_config=_make_model_config(stage_id=1, async_chunk=True, worker_type="ar"),
|
||||
)
|
||||
payload = {
|
||||
"thinker_output_token_ids": [1, 2, 3],
|
||||
"thinker_decode_embeddings": torch.ones(1, 2),
|
||||
"finished": torch.tensor(False),
|
||||
"ids": {"output": [1, 2, 3]},
|
||||
"embed": {"decode": torch.ones(1, 2)},
|
||||
"meta": {"finished": torch.tensor(False)},
|
||||
}
|
||||
self.assertTrue(host._payload_is_consumable(payload))
|
||||
host.shutdown_omni_connectors()
|
||||
@@ -1108,15 +1111,14 @@ class TestAsyncPayloadLifecycle(unittest.TestCase):
|
||||
host._omni_connector.get.side_effect = [
|
||||
(
|
||||
{
|
||||
"thinker_decode_embeddings": torch.ones(1, 2),
|
||||
"finished": torch.tensor(False),
|
||||
"embed": {"decode": torch.ones(1, 2)},
|
||||
"meta": {"finished": torch.tensor(False)},
|
||||
},
|
||||
1,
|
||||
),
|
||||
(
|
||||
{
|
||||
"next_stage_prompt_len": 7,
|
||||
"finished": torch.tensor(False),
|
||||
"meta": {"next_stage_prompt_len": 7, "finished": torch.tensor(False)},
|
||||
},
|
||||
1,
|
||||
),
|
||||
|
||||
Reference in new issue
Block a user