Repository navigation
fix(vllm): build SamplingParams once so stop reaches the engine - #12872
pos-ei-don wants to merge 2 commits into
Conversation
_build_sampling_params constructed SamplingParams and then assigned the request values with setattr. protobuf repeated fields (StopPrompts) stay RepeatedScalarContainer that way, and __post_init__ never sees them: - vLLM's argument checks assert `isinstance(self.stop, list)` and the msgpack encoder that ships the params to the engine core cannot serialise the container, so every request with `stop` failed (HTTP 500, EngineGenerateError), streaming or not. - the stop-string hold-back buffer (output_text_buffer_length) was never set, so the start of a multi-character stop string could be streamed; seed -1 was not mapped to None. Collect the values, turn repeated fields into lists and construct SamplingParams once, as vLLM's OpenAI server does. Values vLLM rejects (e.g. a penalty out of range, an empty stop string) now fail with vLLM's validation error instead of being set unchecked. Signed-off-by: pos-ei-don <1822533+pos-ei-don@users.noreply.github.com>
Describe stop strings, greedy decoding, and seed handling after sampling parameters are validated during construction. Assisted-by: Codex:gpt-6
|
@mudler source review complete against master I pushed the missing sampling documentation as Validation: clean integration with current master and whitespace checks pass. I could not run the backend tests: the available Python executables require a loader absent from this environment. The contributor's reported test results have not been independently reproduced here. Source-review sign-off, conditional on backend test validation and human DCO certification of the docs commit. The added commit has Assisted-by attribution and no AI Signed-off-by. |
Description
Every chat request with
stopfails on the vLLM backend with HTTP 500 (EngineGenerateError), streaming or not. Reproduce with any model on thevllmbackend:{"model": "<vllm model>", "messages": [{"role": "user", "content": "Count from 1 to 10"}], "stop": ["4"]}Cause:
_build_sampling_paramsconstructsSamplingParamsand then assigns the request values withsetattr. The protobuf repeated fieldStopPromptsarrives asRepeatedScalarContainer, notlist, and__post_init__never runs. On current master withStopPrompts=["4"]:sp._verify_args()/sp.clone()→AssertionError(assert isinstance(self.stop, list))MsgpackEncoder().encode(sp)(what ships the params to the engine core) →TypeError: Object of type RepeatedScalarContainer is not serializableSkipping
__post_init__also means the stop-string hold-back buffer (output_text_buffer_length) is never set, so the start of a multi-character stop string can be streamed, andseed=-1is not mapped toNone.This PR collects the values, turns repeated fields into lists and constructs
SamplingParamsonce, as vLLM's OpenAI server does.Behaviour changes worth noting:
presence_penaltyoutside [-2, 2], an empty stop string) now fail with vLLM's validation error instead of being set unchecked.temperature=0, vLLM's__post_init__now normalises to greedy (top_p=1.0,top_k=0). Sampling was already greedy; the existing testtest_explicit_zero_temperature_and_seed_are_preservedcheckedtop_p == 0.9on a temperature-0 request, so that assertion now uses a sampled request.Notes for Reviewers
New server-less tests in
backend/python/vllm/test.py(TestSamplingParamsConstruction, no GPU/model): stop is a list and survives_verify_args/clone/msgpack, hold-back buffer, request values applied, seed -1, invalid values rejected. Run in the backend's venv against vLLM 0.31.0 and 0.32.0: all pass, together with the existing server-less classes. On unpatched master, 3 of the new tests fail with exactly the errors above.Signed commits