Skip to content

Commit f72b9f5

Browse files
authored
[Test] CB rejects requests longer than max length (#236)
Add test to ensure that request lengths are validated and rejected in continuous batching mode. --------- Signed-off-by: Rafael Vasquez <[email protected]>
1 parent d56423f commit f72b9f5

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tests/e2e/test_spyre_cb.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,48 @@ def test_cb_handling(
9292
][0])
9393

9494

95+
@pytest.mark.parametrize("max_num_seqs", [2])
96+
@pytest.mark.parametrize("model", get_spyre_model_list())
97+
@pytest.mark.parametrize(
98+
"backend", [pytest.param("eager", marks=pytest.mark.cpu, id="eager")])
99+
@pytest.mark.parametrize("cb",
100+
[pytest.param(1, marks=pytest.mark.cb, id="cb")])
101+
# @pytest.mark.v1
102+
def test_cb_max_tokens(
103+
model: str,
104+
backend: str,
105+
max_num_seqs: int,
106+
cb: int,
107+
monkeypatch: pytest.MonkeyPatch,
108+
):
109+
"""Test that continuous batches of requests that
110+
are longer than the max_model_len are correctly rejected"""
111+
112+
max_model_len = 2048
113+
max_tokens = 20
114+
115+
overflow_prompt = " ".join(["a"] * max_model_len)
116+
117+
vllm_sampling_params = SamplingParams(max_tokens=max_tokens,
118+
temperature=0,
119+
ignore_eos=True,
120+
logprobs=0)
121+
122+
with pytest.raises(ValueError, match="max model context length"):
123+
generate_cb_spyre_vllm_output(
124+
model=model,
125+
prompts=overflow_prompt,
126+
max_model_len=max_model_len,
127+
block_size=max_model_len,
128+
sampling_params=vllm_sampling_params,
129+
tensor_parallel_size=1,
130+
backend=backend,
131+
max_num_seqs=max_num_seqs,
132+
use_cb=cb,
133+
monkeypatch=monkeypatch,
134+
)
135+
136+
95137
def get_params_test_blocks_borders_aligned_prompts():
96138
""" Scenario where it happens that all the sequences get scheduled in a
97139
fashion where they are aligned with the block boundaries (i.e. tkv multiple

0 commit comments

Comments
 (0)