[Core][Model] Enable Qwen3-TTS MRV2 and optimize the TTS pipeline (#7781)
Signed-off-by: Sy03 <1370724210@qq.com>
This commit is contained in:
103 files changed
+10232
-661
No files matched your search
@@ -1,14 +1,22 @@
|
||||
"""Test that OmniGenerationScheduler restores chunk-waiting requests
|
||||
even when the OmniNewRequestData rewrapping fails.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
Regression test: if process_pending_chunks() moves requests into
|
||||
internal deques but restore_queues() is not called due to an exception,
|
||||
those requests are permanently orphaned.
|
||||
"""
|
||||
"""Chunk-lifecycle coverage for OmniGenerationScheduler: restore on error,
|
||||
native terminal state, in-flight no-resubmission, slot release on finish,
|
||||
and single scheduling of a terminal empty-prompt chunk."""
|
||||
|
||||
from collections import deque
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
import torch
|
||||
from vllm import SamplingParams
|
||||
from vllm.v1.core.sched.interface import PauseState
|
||||
from vllm.v1.core.sched.request_queue import SchedulingPolicy, create_request_queue
|
||||
from vllm.v1.request import Request, RequestStatus
|
||||
|
||||
from vllm_omni.core.sched.omni_generation_scheduler import OmniGenerationScheduler, _has_async_chunk_payload_to_run
|
||||
from vllm_omni.engine.serialization import serialize_additional_information
|
||||
|
||||
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
|
||||
|
||||
@@ -20,16 +28,20 @@ class FakeAdapter:
|
||||
self.waiting_for_chunk_waiting_requests = deque()
|
||||
self.waiting_for_chunk_running_requests = deque()
|
||||
self.restore_called = False
|
||||
self.done_request_ids = set()
|
||||
|
||||
def process_pending_chunks(self, waiting, running):
|
||||
"""Simulate moving requests out of the scheduler queues."""
|
||||
# Move one request from running into internal deque
|
||||
def process_pending_chunks(self, waiting, running, scheduler_requests=None):
|
||||
if running:
|
||||
req = running.pop()
|
||||
self.waiting_for_chunk_running_requests.append(req)
|
||||
|
||||
def is_done_receiving_chunks(self, request_id):
|
||||
return request_id in self.done_request_ids
|
||||
|
||||
def collect_failed_send_request_ids(self):
|
||||
return {}
|
||||
|
||||
def restore_queues(self, waiting, running, scheduler_requests=None):
|
||||
"""Put requests back."""
|
||||
self.restore_called = True
|
||||
running.extend(self.waiting_for_chunk_running_requests)
|
||||
self.waiting_for_chunk_running_requests = deque()
|
||||
@@ -38,6 +50,131 @@ class FakeAdapter:
|
||||
pass
|
||||
|
||||
|
||||
def _make_generation_scheduler(waiting_request, *, use_v2_model_runner=False):
|
||||
scheduler = OmniGenerationScheduler.__new__(OmniGenerationScheduler)
|
||||
scheduler.max_num_scheduled_tokens = 8
|
||||
scheduler.max_num_running_reqs = 1
|
||||
scheduler._pause_state = PauseState.UNPAUSED
|
||||
scheduler.running = []
|
||||
scheduler.waiting = create_request_queue(SchedulingPolicy.FCFS)
|
||||
scheduler.waiting.add_request(waiting_request)
|
||||
scheduler.skipped_waiting = create_request_queue(SchedulingPolicy.FCFS)
|
||||
scheduler.requests = {waiting_request.request_id: waiting_request}
|
||||
scheduler.policy = SchedulingPolicy.FCFS
|
||||
scheduler.chunk_transfer_adapter = FakeAdapter()
|
||||
scheduler.input_coordinator = None
|
||||
scheduler.log_stats = False
|
||||
scheduler.scheduler_config = SimpleNamespace(enable_chunked_prefill=True)
|
||||
scheduler.num_lookahead_tokens = 0
|
||||
scheduler.kv_cache_manager = SimpleNamespace(
|
||||
new_step_starts=lambda: None,
|
||||
allocate_slots=lambda *args, **kwargs: SimpleNamespace(get_block_ids=lambda: ([1],)),
|
||||
get_num_common_prefix_blocks=lambda request_id: [0],
|
||||
take_new_block_ids=lambda: None,
|
||||
)
|
||||
scheduler.kv_cache_config = SimpleNamespace(kv_cache_groups=[object()])
|
||||
scheduler.use_v2_model_runner = use_v2_model_runner
|
||||
scheduler._retains_state_across_chunks = False
|
||||
scheduler.needs_kv_cache_zeroing = False
|
||||
scheduler.finished_req_ids = set()
|
||||
scheduler.encoder_cache_manager = SimpleNamespace(get_freed_mm_hashes=lambda: [])
|
||||
scheduler.connector = None
|
||||
scheduler.ec_connector = None
|
||||
scheduler.prev_step_scheduled_req_ids = set()
|
||||
scheduler._pending_finish_reqs = []
|
||||
scheduler._consume_pending_connector_output = lambda model_mode: None
|
||||
scheduler._process_pending_input_timeouts = lambda: None
|
||||
scheduler._make_cached_request_data = lambda **kwargs: SimpleNamespace(
|
||||
req_ids=[],
|
||||
resumed_req_ids=[],
|
||||
new_token_ids=[],
|
||||
all_token_ids=[],
|
||||
new_block_ids=[],
|
||||
num_computed_tokens=[],
|
||||
num_output_tokens=[],
|
||||
)
|
||||
scheduler._update_after_schedule = lambda output: None
|
||||
scheduler._wrap_omni_scheduler_output = lambda output: output
|
||||
return scheduler
|
||||
|
||||
|
||||
def _chunk_request(request_id, **kwargs):
|
||||
defaults = dict(
|
||||
request_id=request_id,
|
||||
prompt_token_ids=[1],
|
||||
num_computed_tokens=0,
|
||||
num_in_flight_tokens=0,
|
||||
status=None,
|
||||
sampling_params=None,
|
||||
pooling_params=None,
|
||||
mm_features=None,
|
||||
lora_request=None,
|
||||
prompt_is_token_ids=True,
|
||||
additional_information=None,
|
||||
external_req_id=request_id,
|
||||
prefill_stats=None,
|
||||
record_event=lambda *args, **kwargs: None,
|
||||
)
|
||||
defaults.update(kwargs)
|
||||
return SimpleNamespace(**defaults)
|
||||
|
||||
|
||||
def test_chunk_lifecycle_no_resubmit_and_state_survives_requeue(monkeypatch) -> None:
|
||||
# Native plane: a completed payload without a new chunk is never executed
|
||||
# again; requeued requests keep WAITING_FOR_CHUNK and their token counts.
|
||||
scheduler = _make_generation_scheduler(_chunk_request("unused"))
|
||||
monkeypatch.setattr("vllm_omni.core.sched.omni_generation_scheduler.create_request_queue", create_request_queue)
|
||||
scheduler._native_data_plane = True
|
||||
scheduler.chunk_transfer_adapter = None
|
||||
scheduler.input_coordinator = SimpleNamespace(finished_requests=set(), restore_queues=lambda *args, **kwargs: None)
|
||||
scheduler.running = []
|
||||
scheduler.waiting = create_request_queue(scheduler.policy)
|
||||
scheduler.skipped_waiting = create_request_queue(scheduler.policy)
|
||||
|
||||
completed = Request("completed", [1, 2], SamplingParams(max_tokens=4), pooling_params=None)
|
||||
completed.status = RequestStatus.RUNNING
|
||||
completed.num_computed_tokens = 2
|
||||
scheduler.running = [completed]
|
||||
scheduler.requests = {"completed": completed}
|
||||
scheduler.input_coordinator.finished_requests.add("completed") # terminal payload, no new chunk
|
||||
|
||||
assert scheduler._is_done_receiving_chunks("completed")
|
||||
assert not scheduler._is_done_receiving_chunks("unknown")
|
||||
output = scheduler.schedule()
|
||||
assert not output.num_scheduled_tokens
|
||||
assert scheduler._pending_finish_reqs == [completed]
|
||||
|
||||
completed.status = RequestStatus.WAITING_FOR_CHUNK
|
||||
scheduler._pending_finish_reqs = []
|
||||
scheduler._requeue_completed_native_chunks()
|
||||
assert completed.status == RequestStatus.WAITING_FOR_CHUNK
|
||||
assert completed.num_computed_tokens == 2
|
||||
assert not scheduler.running
|
||||
|
||||
|
||||
def test_generation_scheduler_schedules_terminal_empty_prompt_chunk_once(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
waiting = _chunk_request(
|
||||
"terminal",
|
||||
prompt_token_ids=[],
|
||||
num_prompt_tokens=0,
|
||||
additional_information=serialize_additional_information(
|
||||
{"codes": {"audio": torch.tensor([[1, 2, 3]], dtype=torch.long)}}
|
||||
),
|
||||
)
|
||||
scheduler = _make_generation_scheduler(waiting)
|
||||
scheduler.chunk_transfer_adapter.done_request_ids.add("terminal")
|
||||
scheduler.requests = {"terminal": waiting}
|
||||
assert _has_async_chunk_payload_to_run(waiting)
|
||||
# A terminal codec request with an empty prompt is still scheduled exactly once.
|
||||
monkeypatch.setattr("vllm_omni.core.sched.omni_generation_scheduler.create_request_queue", create_request_queue)
|
||||
|
||||
output = OmniGenerationScheduler.schedule(scheduler)
|
||||
|
||||
assert output.num_scheduled_tokens == {"terminal": 1}
|
||||
assert output.scheduled_new_reqs[0].req_id == "terminal"
|
||||
assert scheduler._pending_finish_reqs == []
|
||||
|
||||
|
||||
class TestRestoreQueuesOnError:
|
||||
"""Verify that restore_queues is called even when rewrapping raises."""
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
"""Tests for ``OmniARScheduler._drop_aborted_queued_requests``.
|
||||
|
||||
``schedule()`` sweeps ``FINISHED_ABORTED`` requests out of the queues before
|
||||
@@ -68,6 +71,7 @@ def test_schedule_sweeps_skipped_waiting_before_upstream_selection(
|
||||
aborted = _StubRequest("req-aborted", RequestStatus.FINISHED_ABORTED)
|
||||
scheduler = _make_scheduler(policy, skipped_waiting=[aborted])
|
||||
scheduler.chunk_transfer_adapter = None
|
||||
scheduler.max_num_running_reqs = 8
|
||||
scheduler.input_coordinator = None
|
||||
scheduler.num_waiting_for_streaming_input = 0
|
||||
scheduler._process_pending_omni_inputs = lambda model_mode: None
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
"""Tests for the AR sampled-token logprob contract."""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -93,6 +96,7 @@ class _Request:
|
||||
self.num_computed_tokens = 0
|
||||
self.num_in_flight_tokens = 0
|
||||
self.num_output_placeholders = 0
|
||||
self.output_token_ids: list[int] = []
|
||||
# vLLM 0.27 (a0c092ee72): Request gained num_stale_output_tokens to
|
||||
# track in-flight outputs discarded at preemption/streaming-stop.
|
||||
self.num_stale_output_tokens = 0
|
||||
@@ -145,6 +149,14 @@ def _make_scheduler_stub(requests: list[_Request]) -> SimpleNamespace:
|
||||
kv_cache_manager=SimpleNamespace(take_events=lambda: None),
|
||||
kv_event_publisher=SimpleNamespace(publish=lambda _events: None),
|
||||
recompute_kv_load_failures=False,
|
||||
_native_data_plane=False,
|
||||
vllm_config=SimpleNamespace(
|
||||
model_config=SimpleNamespace(
|
||||
use_v2_model_runner=False,
|
||||
async_chunk=False,
|
||||
final_output=True,
|
||||
)
|
||||
),
|
||||
)
|
||||
for name in _MIXIN_UPDATE_HELPERS:
|
||||
setattr(scheduler, name, MethodType(getattr(OmniSchedulerMixin, name), scheduler))
|
||||
@@ -167,10 +179,15 @@ def _bind_request_lifecycle(
|
||||
scheduler.requests.pop(request.request_id, None)
|
||||
scheduler.finished_req_ids.add(request.request_id)
|
||||
scheduler.finished_req_ids_dict[request.client_index].add(request.request_id)
|
||||
# vLLM 0.26 contract: (kv_xfer_params, ec_xfer_params)
|
||||
# Current vLLM contract: (kv_xfer_params, ec_xfer_params)
|
||||
return None, None
|
||||
|
||||
scheduler._update_request_with_output = update_request
|
||||
def update_with_history(request, token_ids):
|
||||
accepted, stopped = update_request(request, token_ids)
|
||||
request.output_token_ids.extend(accepted)
|
||||
return accepted, stopped
|
||||
|
||||
scheduler._update_request_with_output = update_with_history
|
||||
scheduler._process_kv_transfer_trigger = lambda _request, _tokens: False
|
||||
scheduler._handle_stopped_request = handle_stopped or (lambda _request: True)
|
||||
scheduler._free_request = free_request
|
||||
@@ -219,6 +236,7 @@ def test_mid_step_stop_trims_logprob_rows_with_token_ids() -> None:
|
||||
(output,) = outputs[0].outputs
|
||||
|
||||
assert output.new_token_ids == [7]
|
||||
assert output.num_generation_tokens == 1
|
||||
assert output.finish_reason is FinishReason.STOP
|
||||
token_rows = np.asarray(output.new_logprobs.logprob_token_ids)
|
||||
value_rows = np.asarray(output.new_logprobs.logprobs)
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
|
||||
from vllm_omni.core.sched.omni_ar_scheduler import _should_emit_engine_output
|
||||
|
||||
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("async_chunk", "final_output", "use_v2", "stopped", "has_control", "expected"),
|
||||
[
|
||||
(True, False, True, False, False, False), # async+v2 suppresses data
|
||||
(True, False, False, False, False, True), # v1 continues to emit
|
||||
(True, False, True, True, False, True), # stopped always emits
|
||||
(True, False, True, False, True, True), # control-only still emits
|
||||
],
|
||||
)
|
||||
def test_async_chunk_intermediate_stage_emits_only_control_outputs(
|
||||
async_chunk: bool,
|
||||
final_output: bool,
|
||||
use_v2: bool,
|
||||
stopped: bool,
|
||||
has_control: bool,
|
||||
expected: bool,
|
||||
) -> None:
|
||||
model_config = SimpleNamespace(
|
||||
async_chunk=async_chunk,
|
||||
final_output=final_output,
|
||||
use_v2_model_runner=use_v2,
|
||||
)
|
||||
|
||||
assert (
|
||||
_should_emit_engine_output(
|
||||
model_config,
|
||||
stopped=stopped,
|
||||
has_control=has_control,
|
||||
)
|
||||
is expected
|
||||
)
|
||||
@@ -17,6 +17,7 @@ import pytest
|
||||
import vllm_omni # noqa: F401 - import for side effects (patch vLLM)
|
||||
from vllm.sampling_params import SamplingParams
|
||||
from vllm.v1.core.sched.output import SchedulerOutput
|
||||
from vllm.v1.core.sched.scheduler import Scheduler as VLLMScheduler
|
||||
from vllm.v1.outputs import ModelRunnerOutput
|
||||
from vllm.v1.engine import FinishReason
|
||||
from vllm.v1.core.sched.request_queue import SchedulingPolicy, create_request_queue
|
||||
@@ -1261,3 +1262,47 @@ def test_context_overflow_emits_an_error_output_with_the_reason() -> None:
|
||||
|
||||
sched._emit_streaming_context_overflow_outputs(outputs)
|
||||
assert len(outputs[2]) == 1
|
||||
|
||||
|
||||
@pytest.mark.parametrize("native", [True, False])
|
||||
def test_async_chunk_reserves_parked_slots_during_ar_admission(monkeypatch, native) -> None:
|
||||
sched = _make_scheduler(stage_id=1)
|
||||
parked = SimpleNamespace(request_id="parked")
|
||||
sched.requests = {"parked": parked}
|
||||
sched.waiting = []
|
||||
sched.running = []
|
||||
sched._native_data_plane = native
|
||||
sched.use_v2_model_runner = native
|
||||
sched.max_num_running_reqs = 8
|
||||
sched.input_coordinator = (
|
||||
SimpleNamespace(_waiting_for_chunk_running=[parked], restore_queues=lambda _w, _r: None) if native else None
|
||||
)
|
||||
sched.chunk_transfer_adapter = (
|
||||
None
|
||||
if native
|
||||
else SimpleNamespace(
|
||||
waiting_for_chunk_running_requests=[parked],
|
||||
_held_non_active=[],
|
||||
process_pending_chunks=lambda *_a, **_kw: None,
|
||||
collect_failed_send_request_ids=lambda: {},
|
||||
restore_queues=lambda *_a, **_kw: None,
|
||||
postprocess_scheduler_output=lambda *_a, **_kw: None,
|
||||
)
|
||||
)
|
||||
sched._consume_pending_connector_output = lambda model_mode: None
|
||||
sched._process_pending_input_timeouts = lambda: None
|
||||
sched._should_defer_waiting_admission = lambda: False
|
||||
sched.get_finished_requests_needing_kv_transfer = lambda: {}
|
||||
sched._wrap_omni_scheduler_output = lambda output, **_kwargs: output
|
||||
observed_limits: list[int] = []
|
||||
|
||||
def fake_schedule(self, _throttle_prefills=False):
|
||||
observed_limits.append(self.max_num_running_reqs)
|
||||
return SimpleNamespace(scheduled_new_reqs=[])
|
||||
|
||||
monkeypatch.setattr(VLLMScheduler, "schedule", fake_schedule)
|
||||
|
||||
sched.schedule()
|
||||
|
||||
assert observed_limits == [7 if native else 8]
|
||||
assert sched.max_num_running_reqs == 8
|
||||
@@ -1,3 +1,6 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from types import SimpleNamespace
|
||||
@@ -141,6 +144,7 @@ def test_voxcpm2_unified_decode_graph_does_not_defer_without_cuda_graph(monkeypa
|
||||
|
||||
def test_unified_decode_graph_deferral_restores_waiting_queue(monkeypatch) -> None:
|
||||
scheduler = _make_scheduler()
|
||||
scheduler.max_num_running_reqs = 8
|
||||
scheduler.running = [_MockRequest("decode")]
|
||||
original_waiting_req = _MockRequest("waiting", status=RequestStatus.WAITING)
|
||||
deferred_by_upstream = _MockRequest("deferred-by-upstream", status=RequestStatus.WAITING)
|
||||
|
||||
@@ -123,6 +123,9 @@ def _make_fast_path_sched(*, defer_block_free: bool) -> tuple[MagicMock, Request
|
||||
|
||||
sched = MagicMock()
|
||||
sched.max_num_scheduled_tokens = 8
|
||||
sched.max_num_running_reqs = 8
|
||||
sched._native_data_plane = False
|
||||
sched._retains_state_across_chunks = False
|
||||
sched._pause_state = PauseState.UNPAUSED
|
||||
sched.requests = {request.request_id: request}
|
||||
sched.running = [request]
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
from collections import defaultdict
|
||||
from types import SimpleNamespace
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
from vllm.v1.engine import FinishReason
|
||||
@@ -87,7 +91,7 @@ def test_full_payload_coordinator_matches_legacy_gate(monkeypatch, stage_id, asy
|
||||
|
||||
|
||||
def test_schedule_lifecycle_helpers_process_and_restore_both_input_paths():
|
||||
calls = []
|
||||
calls: list[tuple[Any, ...]] = []
|
||||
scheduler = _Scheduler()
|
||||
scheduler.waiting = ["waiting"]
|
||||
scheduler.running = ["running"]
|
||||
@@ -115,7 +119,7 @@ def test_schedule_lifecycle_helpers_process_and_restore_both_input_paths():
|
||||
collect_failed_send_request_ids=_collect_failed_sends,
|
||||
)
|
||||
scheduler.input_coordinator = SimpleNamespace(
|
||||
restore_queues=lambda waiting: calls.append(("restore-full", waiting))
|
||||
restore_queues=lambda waiting, running: calls.append(("restore-full", waiting, running))
|
||||
)
|
||||
|
||||
scheduler._process_pending_omni_inputs("ar")
|
||||
@@ -130,7 +134,7 @@ def test_schedule_lifecycle_helpers_process_and_restore_both_input_paths():
|
||||
("chunk-timeouts", omni_scheduler_mixin.DEFAULT_INPUT_WAIT_TIMEOUT_S),
|
||||
("failed-sends",),
|
||||
("restore-chunks", scheduler.waiting, scheduler.running, scheduler.requests),
|
||||
("restore-full", scheduler.waiting),
|
||||
("restore-full", scheduler.waiting, scheduler.running),
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
"""Drain ready events once, merging live requests and filtering cancellations."""
|
||||
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
|
||||
from vllm_omni.core.sched.omni_scheduler_mixin import OmniSchedulerMixin
|
||||
from vllm_omni.outputs import OmniConnectorOutput
|
||||
|
||||
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
|
||||
|
||||
|
||||
def test_ready_inbox_coalesces_live_events_and_drops_cancelled(mocker):
|
||||
scheduler = OmniSchedulerMixin()
|
||||
scheduler.requests, scheduler.waiting, scheduler.running = {"r": object()}, [], []
|
||||
coordinator = SimpleNamespace(
|
||||
_async_chunk=True, update_request_metadata=mocker.Mock(), process_pending_chunks=mocker.Mock()
|
||||
)
|
||||
scheduler.input_coordinator = coordinator
|
||||
scheduler._init_omni_connector_output_inbox()
|
||||
scheduler.enqueue_omni_connector_output(OmniConnectorOutput(chunk_ready_req_ids={"r"}))
|
||||
scheduler.enqueue_omni_connector_output(
|
||||
OmniConnectorOutput(
|
||||
chunk_ready_req_ids={"r", "aborted"},
|
||||
chunk_finished_req_ids={"r", "aborted"},
|
||||
request_metadata={"r": {"decode_token_end": 2}, "aborted": {"decode_token_end": 99}},
|
||||
)
|
||||
)
|
||||
scheduler._consume_pending_connector_output(model_mode="ar")
|
||||
coordinator.update_request_metadata.assert_called_once_with(
|
||||
scheduler.requests, {"r": {"decode_token_end": 2}}, model_mode="ar"
|
||||
)
|
||||
coordinator.process_pending_chunks.assert_called_once_with([], [], {"r"}, {"r"})
|
||||
scheduler._consume_pending_connector_output(model_mode="ar")
|
||||
assert coordinator.update_request_metadata.call_count == 1
|
||||
coordinator.process_pending_chunks.assert_called_with([], [], set(), set())
|
||||
@@ -1,3 +1,6 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
"""Tests for the ``num_waiting_for_streaming_input`` resync placed in
|
||||
``OmniARScheduler.finish_requests`` / ``OmniGenerationScheduler.finish_requests``
|
||||
and in ``OmniARScheduler.schedule``.
|
||||
@@ -128,6 +131,7 @@ def test_ar_schedule_resyncs_before_delegating_upstream(monkeypatch: pytest.Monk
|
||||
scheduler.skipped_waiting = []
|
||||
scheduler.num_waiting_for_streaming_input = 1 # leaked by the status rewrite
|
||||
scheduler.policy = "fcfs"
|
||||
scheduler.max_num_running_reqs = 8
|
||||
|
||||
seen: dict[str, int] = {}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
"""Unit tests for OmniSchedulingCoordinator.
|
||||
|
||||
These tests use mock request objects and mock queues. They do not require
|
||||
@@ -20,7 +20,9 @@ import torch
|
||||
import vllm_omni.core.sched.omni_scheduling_coordinator as coord_mod
|
||||
from vllm_omni.core.sched.omni_scheduling_coordinator import (
|
||||
OmniSchedulingCoordinator,
|
||||
uses_native_mrv2_data_plane,
|
||||
)
|
||||
from vllm_omni.core.sched.output import OmniChunkRecvHandle
|
||||
|
||||
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
|
||||
|
||||
@@ -56,6 +58,7 @@ def _make_request(req_id: str, status: str = "waiting") -> SimpleNamespace:
|
||||
prompt_token_ids=[],
|
||||
num_prompt_tokens=0,
|
||||
num_computed_tokens=0,
|
||||
num_output_placeholders=0,
|
||||
_all_token_ids=[],
|
||||
_output_token_ids=[],
|
||||
payload_sender_info=None,
|
||||
@@ -83,7 +86,7 @@ class MockQueue:
|
||||
def prepend_requests(self, requests):
|
||||
self._items = list(requests) + self._items
|
||||
|
||||
def remove(self, request):
|
||||
def remove_request(self, request):
|
||||
self._items.remove(request)
|
||||
|
||||
def remove_requests(self, requests):
|
||||
@@ -96,7 +99,47 @@ class MockQueue:
|
||||
# ------------------------------------------------------------------ #
|
||||
|
||||
|
||||
class TestCoordinatorUpdateRequestMetadata(unittest.TestCase):
|
||||
class TestNativeMRV2DataPlaneSelection(unittest.TestCase):
|
||||
def test_native_plane_requires_v2_and_async_chunk_capability(self):
|
||||
native = SimpleNamespace(async_chunk=True, supports_native_mrv2_data_plane=True)
|
||||
|
||||
self.assertTrue(uses_native_mrv2_data_plane(native, use_v2_model_runner=True))
|
||||
self.assertFalse(uses_native_mrv2_data_plane(native, use_v2_model_runner=False))
|
||||
self.assertFalse(uses_native_mrv2_data_plane(SimpleNamespace(async_chunk=False), use_v2_model_runner=True))
|
||||
|
||||
|
||||
def test_chunk_registration_ready_and_terminal_lifecycle():
|
||||
coord = OmniSchedulingCoordinator(scheduler_max_num_seqs=10, stage_id=1, async_chunk=True)
|
||||
req = _make_request("internal", status=RequestStatus.WAITING)
|
||||
req.external_req_id = "external"
|
||||
waiting = MockQueue([req])
|
||||
coord.process_pending_chunks(waiting, [], set(), set())
|
||||
assert req.status == RequestStatus.WAITING_FOR_CHUNK
|
||||
[handle] = coord.pending_chunk_registrations
|
||||
assert isinstance(handle, OmniChunkRecvHandle)
|
||||
assert (handle.request_id, handle.external_req_id) == ("internal", "external")
|
||||
coord.restore_queues(waiting, [])
|
||||
coord.process_pending_chunks(waiting, [], {"internal"}, set())
|
||||
assert req.status == RequestStatus.WAITING
|
||||
assert "internal" in coord.requests_with_ready_chunks
|
||||
req.status = RequestStatus.WAITING_FOR_CHUNK
|
||||
coord.process_pending_chunks(waiting, [], set(), {"internal"})
|
||||
assert "internal" in coord.finished_requests
|
||||
|
||||
|
||||
def test_chunk_waiting_removes_request_from_running_list():
|
||||
coord = OmniSchedulingCoordinator(scheduler_max_num_seqs=10, stage_id=1, async_chunk=True)
|
||||
req = _make_request("running", status=RequestStatus.RUNNING)
|
||||
running = [req]
|
||||
|
||||
coord.process_pending_chunks(MockQueue(), running, set(), set())
|
||||
|
||||
assert running == []
|
||||
assert req.status == RequestStatus.WAITING_FOR_CHUNK
|
||||
assert list(coord._waiting_for_chunk_running) == [req]
|
||||
|
||||
|
||||
class TestChunkCoordinatorUpdateRequestMetadata(unittest.TestCase):
|
||||
"""Test update_request_metadata applies scheduling metadata to requests."""
|
||||
|
||||
def test_ar_mode_no_longer_sets_additional_information(self):
|
||||
@@ -382,17 +425,18 @@ class TestTimeoutDetection(unittest.TestCase):
|
||||
self.assertEqual(result, {"r1"})
|
||||
self.assertEqual(len(coord._waiting_for_input), 0)
|
||||
|
||||
def test_free_finished_request_clears_waiting_since(self):
|
||||
"""free_finished_request clears coordinator lifecycle markers."""
|
||||
coord = OmniSchedulingCoordinator(stage_id=1)
|
||||
coord._waiting_since["r1"] = 0.0
|
||||
coord._full_payload_input_received.add("r1")
|
||||
def test_free_finished_request_clears_all_lifecycle_state(self):
|
||||
"""free_finished_request makes stale connector events harmless."""
|
||||
coord = OmniSchedulingCoordinator(scheduler_max_num_seqs=10, stage_id=1)
|
||||
r1, r2 = _make_request("r1"), _make_request("r2")
|
||||
coord.finished_requests.add("r1")
|
||||
coord.requests_with_ready_chunks.add("r1")
|
||||
coord._waiting_for_chunk_running.extend([r1, r2])
|
||||
coord.pending_chunk_registrations = [OmniChunkRecvHandle(request_id="r1"), OmniChunkRecvHandle(request_id="r2")]
|
||||
|
||||
coord.free_finished_request("r1")
|
||||
self.assertNotIn("r1", coord._waiting_since)
|
||||
self.assertNotIn("r1", coord._full_payload_input_received)
|
||||
|
||||
self.assertNotIn("r1", coord.finished_requests)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
self.assertNotIn("r1", coord.requests_with_ready_chunks)
|
||||
self.assertEqual([r.request_id for r in coord._waiting_for_chunk_running], ["r2"])
|
||||
self.assertEqual([h.request_id for h in coord.pending_chunk_registrations], ["r2"])
|
||||
Reference in new issue
Block a user