[perf] Minicpm o4.5 optimization (#5228)
Signed-off-by: R2-Y <ruiruyang2@gmail.com> Co-authored-by: Sy03 <1370724210@qq.com>
This commit is contained in:
1 parent
acf941da4d
commit
ad3a162eb8
54 files changed
+3861
-3997
No files matched your search
@@ -8,6 +8,7 @@ from vllm_omni.distributed.omni_connectors.adapter import try_recv_via_connector
|
||||
from vllm_omni.distributed.omni_connectors.connectors.shm_connector import SharedMemoryConnector
|
||||
from vllm_omni.distributed.omni_connectors.utils.config import ConnectorSpec, OmniTransferConfig
|
||||
from vllm_omni.distributed.omni_connectors.utils.initialization import get_connectors_config_for_stage
|
||||
from vllm_omni.engine.stage_init_utils import get_stage_connector_spec
|
||||
|
||||
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
|
||||
|
||||
@@ -217,6 +218,22 @@ def test_get_connectors_for_stage():
|
||||
assert stage_2_config["from_stage_1"]["spec"]["name"] == "C2"
|
||||
|
||||
|
||||
def test_outgoing_only_async_stage_uses_sender_connector_spec():
|
||||
config = OmniTransferConfig(
|
||||
connectors={
|
||||
("1", "2"): ConnectorSpec(
|
||||
name="SharedMemoryConnector",
|
||||
extra={"codec_chunk_frames": 25},
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
spec = get_stage_connector_spec(config, stage_id=1, async_chunk=True)
|
||||
|
||||
assert spec["name"] == "SharedMemoryConnector"
|
||||
assert spec["extra"] == {"codec_chunk_frames": 25, "role": "sender"}
|
||||
|
||||
|
||||
def test_recv_with_missing_metadata(mocker: MockerFixture):
|
||||
"""Test recv when queue payload is malformed (missing metadata)."""
|
||||
# Connector expects metadata but task doesn't have it
|
||||
|
||||
@@ -13,6 +13,7 @@ from vllm.v1.core.sched.scheduler import Scheduler as VLLMScheduler
|
||||
from vllm.v1.request import RequestStatus
|
||||
|
||||
from vllm_omni.data_entry_keys import CodesStruct, MetaStruct, OmniPayload, OmniPayloadStruct
|
||||
from vllm_omni.distributed.omni_connectors.adapter import construct_next_stage_streaming_input_prompt
|
||||
from vllm_omni.distributed.omni_connectors.transfer_adapter.base import OmniTransferAdapterBase
|
||||
from vllm_omni.distributed.omni_connectors.transfer_adapter.chunk_transfer_adapter import (
|
||||
OmniChunkTransferAdapter,
|
||||
@@ -43,6 +44,33 @@ def _req(req_id: str, status: RequestStatus, external_req_id: str | None = None)
|
||||
)
|
||||
|
||||
|
||||
def test_streaming_payload_can_replace_placeholder_prompt(mocker: MockerFixture) -> None:
|
||||
request = SimpleNamespace(
|
||||
_all_token_ids=[0, 0, 7, 8],
|
||||
_output_token_ids=[7, 8],
|
||||
prompt_token_ids=[0, 0],
|
||||
num_computed_tokens=4,
|
||||
num_prompt_tokens=2,
|
||||
update_block_hashes=mocker.Mock(),
|
||||
)
|
||||
payload = {
|
||||
"ids": {"prompt": [1, 2, 3]},
|
||||
"meta": {
|
||||
"replace_streaming_prompt": True,
|
||||
"next_stage_prompt_len": 7,
|
||||
},
|
||||
}
|
||||
|
||||
construct_next_stage_streaming_input_prompt(payload, request)
|
||||
|
||||
assert request.prompt_token_ids == [0] * 7
|
||||
assert request._all_token_ids == [0] * 7
|
||||
assert request._output_token_ids == []
|
||||
assert request.num_computed_tokens == 0
|
||||
assert request.num_prompt_tokens == 7
|
||||
request.update_block_hashes.assert_called_once_with()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def build_adapter(monkeypatch, mocker: MockerFixture):
|
||||
def _build(
|
||||
@@ -81,6 +109,10 @@ def build_adapter(monkeypatch, mocker: MockerFixture):
|
||||
worker_type=model_mode,
|
||||
max_num_seqs=max_num_seqs,
|
||||
active_stream_window=active_stream_window,
|
||||
stage_connector_config={
|
||||
"name": "SharedMemoryConnector",
|
||||
"extra": connector_extra or {},
|
||||
},
|
||||
)
|
||||
scheduler_config = SimpleNamespace(max_num_seqs=max_num_seqs)
|
||||
adapter = OmniChunkTransferAdapter(
|
||||
@@ -381,6 +413,26 @@ def test_load_poll_ar_request_additional_information_concats_tensors(build_adapt
|
||||
assert request.additional_information["meta"]["finished"].item() is True
|
||||
|
||||
|
||||
def test_sender_only_adapter_does_not_park_or_clear_requests(build_adapter):
|
||||
adapter, _ = build_adapter(stage_id=1, connector_extra={"role": "sender"})
|
||||
request = _req("req-1", RequestStatus.WAITING)
|
||||
request.additional_information = {"tts_token_ids": torch.tensor([1])}
|
||||
waiting_queue = DummyWaitingQueue([request])
|
||||
running_queue = []
|
||||
|
||||
adapter.load_async(request)
|
||||
adapter.process_pending_chunks(
|
||||
waiting_queue,
|
||||
running_queue,
|
||||
scheduler_requests={request.request_id: request},
|
||||
)
|
||||
|
||||
assert waiting_queue == [request]
|
||||
assert request.status == RequestStatus.WAITING
|
||||
assert request.additional_information["tts_token_ids"].item() == 1
|
||||
assert adapter._pending_load_reqs == deque()
|
||||
|
||||
|
||||
def test_process_and_restore_queues(build_adapter):
|
||||
adapter, _ = build_adapter(stage_id=1, max_num_seqs=8)
|
||||
waiting_req = _req("w1", RequestStatus.WAITING)
|
||||
|
||||
@@ -2,10 +2,15 @@
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
|
||||
# Use the new import path for initialization utilities
|
||||
from vllm_omni.distributed.omni_connectors.utils.config import (
|
||||
stage_receives_chunks,
|
||||
stage_sends_async_output,
|
||||
)
|
||||
from vllm_omni.distributed.omni_connectors.utils.initialization import load_omni_transfer_config
|
||||
|
||||
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
|
||||
@@ -38,6 +43,26 @@ def get_config_files():
|
||||
config_files = get_config_files()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("role", "stage_id", "receives", "sends"),
|
||||
[
|
||||
("sender", 0, False, True),
|
||||
("receiver", 1, True, False),
|
||||
(None, 0, True, False),
|
||||
(None, None, True, True),
|
||||
],
|
||||
)
|
||||
def test_stage_chunk_direction_helpers(role, stage_id, receives, sends):
|
||||
extra = {} if role is None else {"role": role}
|
||||
model_config = SimpleNamespace(
|
||||
stage_id=stage_id,
|
||||
stage_connector_config={"extra": extra},
|
||||
)
|
||||
|
||||
assert stage_receives_chunks(model_config) is receives
|
||||
assert stage_sends_async_output(model_config) is sends
|
||||
|
||||
|
||||
@pytest.mark.skipif(len(config_files) == 0, reason="No config files found or directory missing")
|
||||
@pytest.mark.parametrize("yaml_file", config_files, ids=lambda p: p.name)
|
||||
def test_load_qwen_yaml_configs(yaml_file):
|
||||
|
||||
Reference in new issue
Block a user