Skip to content

Commit aad5c06

Browse files
njhilljimpang
authored andcommitted
Defensively copy sampling_params (vllm-project#2881)
If the SamplingParams object passed to LLMEngine.add_request() is mutated after it returns, it could affect the async sampling process for that request. Suggested by @Yard1 vllm-project#2514 (comment)
1 parent 779087c commit aad5c06

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

vllm/engine/llm_engine.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,9 @@ def add_request(
464464
prompt_token_ids[:prefix_pos], lora_request.lora_int_id
465465
if lora_request else 0) if prefix_pos is not None else None
466466

467+
# Defensive copy of SamplingParams, which are used by the sampler
468+
sampling_params = copy.deepcopy(sampling_params)
469+
467470
# Create the sequence group.
468471
seq_group = SequenceGroup(request_id, [seq], sampling_params,
469472
arrival_time, lora_request, prefix)

0 commit comments

Comments
 (0)