2026-04-18 15:42:41 +08:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
2026-10-06 10:07:31 -04:00
|
|
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
|
|
|
|
"""Unit tests for AsyncOmni input streaming parameter validation."""
|
2026-04-18 15:42:41 +08:00
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
from vllm.sampling_params import RequestOutputKind, SamplingParams
|
|
|
|
|
|
|
|
|
|
from vllm_omni.entrypoints.async_omni import AsyncOmni
|
|
|
|
|
|
|
|
|
|
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestAsyncOmniStreamingParamsValidation:
|
|
|
|
|
def test_accepts_streaming_friendly_params(self) -> None:
|
|
|
|
|
p = SamplingParams(
|
|
|
|
|
n=1,
|
|
|
|
|
stop=[],
|
|
|
|
|
output_kind=RequestOutputKind.DELTA,
|
|
|
|
|
)
|
|
|
|
|
AsyncOmni._validate_streaming_input_sampling_params(p)
|
|
|
|
|
|
|
|
|
|
def test_rejects_non_sampling_params(self) -> None:
|
|
|
|
|
with pytest.raises(ValueError, match="Input streaming"):
|
|
|
|
|
AsyncOmni._validate_streaming_input_sampling_params(object()) # type: ignore[arg-type]
|
|
|
|
|
|
|
|
|
|
def test_rejects_n_greater_than_one(self) -> None:
|
|
|
|
|
p = SamplingParams(n=2, stop=[], output_kind=RequestOutputKind.DELTA)
|
|
|
|
|
with pytest.raises(ValueError, match="Input streaming"):
|
|
|
|
|
AsyncOmni._validate_streaming_input_sampling_params(p)
|
|
|
|
|
|
|
|
|
|
def test_rejects_final_only(self) -> None:
|
|
|
|
|
p = SamplingParams(n=1, stop=[], output_kind=RequestOutputKind.FINAL_ONLY)
|
|
|
|
|
with pytest.raises(ValueError, match="Input streaming"):
|
|
|
|
|
AsyncOmni._validate_streaming_input_sampling_params(p)
|
|
|
|
|
|
|
|
|
|
def test_rejects_stop_strings(self) -> None:
|
|
|
|
|
p = SamplingParams(n=1, stop=["\n"], output_kind=RequestOutputKind.DELTA)
|
|
|
|
|
with pytest.raises(ValueError, match="Input streaming"):
|
|
|
|
|
AsyncOmni._validate_streaming_input_sampling_params(p)
|