Skip to content

Commit 89446ce

Browse files
WoosukKwonxuebwang-amd
authored andcommitted
[CI] Revert back prepare_prompts and check_answers (vllm-project#25087)
Signed-off-by: Woosuk Kwon <woosuk.kwon@berkeley.edu> Signed-off-by: xuebwang-amd <xuebwang@amd.com>
1 parent f33b2d9 commit 89446ce

File tree

3 files changed

+49
-4
lines changed

3 files changed

+49
-4
lines changed

tests/models/test_transformers.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
from vllm.platforms import current_platform
99

1010
from ..conftest import HfRunner, VllmRunner
11-
from ..core.block.e2e.test_correctness_sliding_window import prep_prompts
12-
from ..utils import multi_gpu_test
11+
from ..utils import multi_gpu_test, prep_prompts
1312
from .utils import check_logprobs_close
1413

1514

tests/utils.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import importlib
99
import json
1010
import os
11+
import random
1112
import signal
1213
import subprocess
1314
import sys
@@ -1150,3 +1151,49 @@ def override_cutlass_fp8_supported(value: bool):
11501151
"vllm.model_executor.layers.quantization.utils.w8a8_utils.cutlass_fp8_supported",
11511152
return_value=value):
11521153
yield
1154+
1155+
1156+
def prep_prompts(batch_size: int, ln_range: tuple[int, int] = (800, 1100)):
1157+
"""
1158+
Generate prompts which a bunch of assignments,
1159+
then asking for the value of one of them.
1160+
The prompt is just under 10k tokens; sliding window is 4k
1161+
so the answer is outside sliding window, but should still be correct.
1162+
Args:
1163+
batch_size: number of prompts to generate
1164+
ln_range: an argument to control the length of the prompt
1165+
"""
1166+
prompts: list[str] = []
1167+
answer: list[int] = []
1168+
indices: list[int] = []
1169+
random.seed(1)
1170+
for _ in range(batch_size):
1171+
idx = random.randint(30, 90)
1172+
indices.append(idx)
1173+
prompt = "```python\n# We set a number of variables, " + \
1174+
f"x{idx} will be important later\n"
1175+
ln = random.randint(*ln_range)
1176+
for k in range(30, ln):
1177+
v = random.randint(10, 99)
1178+
if k == idx:
1179+
answer.append(v)
1180+
prompt += f"x{k} = {v}\n"
1181+
prompt += f"# Now, we check the value of x{idx}:\n"
1182+
prompt += f"assert x{idx} == "
1183+
prompts.append(prompt)
1184+
return prompts, answer, indices
1185+
1186+
1187+
def check_answers(indices: list[int],
1188+
answer: list[int],
1189+
outputs: list[str],
1190+
accept_rate: float = 0.7):
1191+
answer2 = [int(text[0:2].strip()) for text in outputs]
1192+
print(list(zip(indices, zip(answer, answer2))))
1193+
numok = 0
1194+
for a1, a2 in zip(answer, answer2):
1195+
if a1 == a2:
1196+
numok += 1
1197+
frac_ok = numok / len(answer)
1198+
print(f"Num OK: {numok}/{len(answer)} {frac_ok}")
1199+
assert frac_ok >= accept_rate

tests/v1/e2e/test_correctness_sliding_window.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66

77
from vllm import LLM, SamplingParams
88

9-
from ...core.block.e2e.test_correctness_sliding_window import (check_answers,
10-
prep_prompts)
9+
from ...utils import check_answers, prep_prompts
1110

1211

1312
@dataclass

0 commit comments

Comments
 (0)