Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
Signed-off-by: sasha0552 <[email protected]>
  • Loading branch information
sasha0552 authored Oct 30, 2024
1 parent d82d162 commit 868a7ec
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/prefix_caching/test_prefix_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,22 @@
import pytest

from tests.kernels.utils import override_backend_env_variable
from vllm import SamplingParams, TokensPrompt

from ..models.utils import check_outputs_equal

MODELS = [
"facebook/opt-125m",
]

UNSTABLE_PROMPT_SEQUENCE = [
([0] * 588) + ([1] * 1332) + ([2] * 30) + ([3] * 1),
([0] * 588) + ([1] * 1332) + ([4] * 3) + ([5] * 50),
([0] * 588) + ([1] * 1332) + ([2] * 30) + ([6] * 95),
([0] * 588) + ([1] * 1332) + ([4] * 3) + ([7] * 174),
([0] * 588) + ([8] * 1539),
]


@pytest.mark.parametrize("model", MODELS)
@pytest.mark.parametrize("backend", ["FLASH_ATTN", "FLASHINFER", "XFORMERS"])
Expand Down Expand Up @@ -57,3 +66,22 @@ def test_mixed_requests(
name_0="hf",
name_1="vllm",
)


@pytest.mark.parametrize("backend", ["FLASH_ATTN", "FLASHINFER", "XFORMERS"])
def test_unstable_prompt_sequence(
vllm_runner,
backend: str,
monkeypatch,
) -> None:
override_backend_env_variable(monkeypatch, backend)

with vllm_runner(
enable_chunked_prefill=True,
enable_prefix_caching=True,
max_model_len=4096,
model="Qwen/Qwen2.5-0.5B-Instruct",
) as vllm_model:
for prompt in UNSTABLE_PROMPT_SEQUENCE:
vllm_model.generate(TokensPrompt(prompt_token_ids=prompt),
SamplingParams(max_tokens=1))

0 comments on commit 868a7ec

Please sign in to comment.