Skip to content

Commit dae0441

Browse files
committed
More rigorous correctness check
Signed-off-by: Yong Hoon Shin <yhshin@meta.com>
1 parent d112b85 commit dae0441

File tree

3 files changed

+40
-37
lines changed

3 files changed

+40
-37
lines changed

tests/v1/e2e/conftest.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import random
2+
3+
import pytest
4+
5+
6+
@pytest.fixture
7+
def test_prompts():
8+
prompt_types = ["repeat", "sentence"]
9+
num_prompts = 100
10+
prompts = []
11+
12+
random.seed(0)
13+
random_prompt_type_choices = random.choices(prompt_types, k=num_prompts)
14+
15+
# Generate a mixed batch of prompts, some of which can be easily
16+
# predicted by n-gram matching and some which likely cannot.
17+
for kind in random_prompt_type_choices:
18+
word_choices = ["test", "temp", "hello", "where"]
19+
word = random.choice(word_choices)
20+
if kind == "repeat":
21+
prompt = f"""
22+
please repeat the word '{word}' 10 times.
23+
give no other output than the word at least ten times in a row,
24+
in lowercase with spaces between each word and without quotes.
25+
"""
26+
elif kind == "sentence":
27+
prompt = f"""
28+
please give a ten-word sentence that
29+
uses the word {word} at least once.
30+
give no other output than that simple sentence without quotes.
31+
"""
32+
else:
33+
raise ValueError(f"Unknown prompt type: {kind}")
34+
prompts.append([{"role": "user", "content": prompt}])
35+
36+
return prompts

tests/v1/e2e/test_kv_sharing_skip_prefill.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import gc
55
from collections.abc import Iterable
6-
from typing import Optional, Union
6+
from typing import Any, Optional, Union
77

88
import pytest
99
import torch
@@ -275,10 +275,11 @@ def load_weights(self, weights: Iterable[tuple[str,
275275
def test_kv_sharing_skip_prefill(
276276
monkeypatch: pytest.MonkeyPatch,
277277
enforce_eager: bool,
278+
test_prompts: list[list[dict[str, Any]]],
278279
):
279280
ModelRegistry.register_model("Qwen2ForCausalLM", TestQwen2ForCausalLM)
280-
sampling_params = SamplingParams(temperature=0.0, max_tokens=100)
281-
prompts = ["What is the capital of France?"]
281+
sampling_params = SamplingParams(temperature=0.0, max_tokens=42)
282+
prompts = [prompt[0]['content'] for prompt in test_prompts]
282283
compilation_config = CompilationConfig(
283284
level=CompilationLevel.PIECEWISE
284285
if not enforce_eager else CompilationLevel.NO_COMPILATION,

tests/v1/e2e/test_spec_decode.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,13 @@
22
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
33
from __future__ import annotations
44

5-
import random
65
from typing import Any
76

87
import pytest
98

109
from vllm import LLM, SamplingParams
1110

1211

13-
@pytest.fixture
14-
def test_prompts():
15-
prompt_types = ["repeat", "sentence"]
16-
num_prompts = 100
17-
prompts = []
18-
19-
random.seed(0)
20-
random_prompt_type_choices = random.choices(prompt_types, k=num_prompts)
21-
22-
# Generate a mixed batch of prompts, some of which can be easily
23-
# predicted by n-gram matching and some which likely cannot.
24-
for kind in random_prompt_type_choices:
25-
word_choices = ["test", "temp", "hello", "where"]
26-
word = random.choice(word_choices)
27-
if kind == "repeat":
28-
prompt = f"""
29-
please repeat the word '{word}' 10 times.
30-
give no other output than the word at least ten times in a row,
31-
in lowercase with spaces between each word and without quotes.
32-
"""
33-
elif kind == "sentence":
34-
prompt = f"""
35-
please give a ten-word sentence that
36-
uses the word {word} at least once.
37-
give no other output than that simple sentence without quotes.
38-
"""
39-
else:
40-
raise ValueError(f"Unknown prompt type: {kind}")
41-
prompts.append([{"role": "user", "content": prompt}])
42-
43-
return prompts
44-
45-
4612
@pytest.fixture
4713
def sampling_config():
4814
return SamplingParams(temperature=0, max_tokens=10, ignore_eos=False)

0 commit comments

Comments
 (0)