Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,26 @@ async def test_generate_defaults_max_tokens_when_omitted(client):
)


@pytest.mark.asyncio
async def test_generate_returns_all_choices_when_n_greater_than_one(client):
"""Regression: ``n > 1`` must return ``n`` choices.

Non-streaming requests kept ``SamplingParams``' default output kind,
``CUMULATIVE``, so only the sequences updated during the last engine step
reached the response and the others were silently dropped.
"""
payload = {
"model": MODEL_NAME,
"token_ids": [1, 2, 3],
"sampling_params": {"max_tokens": 5, "temperature": 1.0, "n": 4},
"stream": False,
}
resp = await client.post(GEN_ENDPOINT, json=payload)
resp.raise_for_status()
data = resp.json()
assert sorted(choice["index"] for choice in data["choices"]) == [0, 1, 2, 3]


@pytest.mark.asyncio
async def test_generate_stream(client):
payload = {
Expand Down
5 changes: 3 additions & 2 deletions vllm/entrypoints/scale_out/token_in_token_out/serving.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,9 @@ async def serve_tokens(

if self.force_no_detokenize:
sampling_params.detokenize = False
if request.stream:
sampling_params.output_kind = RequestOutputKind.DELTA
sampling_params.output_kind = (
RequestOutputKind.DELTA if request.stream else RequestOutputKind.FINAL_ONLY
)

self._log_inputs(
request_id,
Expand Down
Loading