Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
norm
vllm
Commits
29a8d6a5
Unverified
Commit
29a8d6a5
authored
Feb 29, 2024
by
Nick Hill
Committed by
GitHub
Feb 29, 2024
Browse files
[Fix] Don't deep-copy LogitsProcessors when copying SamplingParams (#3099)
parent
2c08ff23
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
2 deletions
+18
-2
vllm/engine/llm_engine.py
vllm/engine/llm_engine.py
+3
-2
vllm/sampling_params.py
vllm/sampling_params.py
+15
-0
No files found.
vllm/engine/llm_engine.py
View file @
29a8d6a5
...
...
@@ -484,8 +484,9 @@ class LLMEngine:
prompt_token_ids
[:
prefix_pos
],
lora_request
.
lora_int_id
if
lora_request
else
0
)
if
prefix_pos
is
not
None
else
None
# Defensive copy of SamplingParams, which are used by the sampler
sampling_params
=
copy
.
deepcopy
(
sampling_params
)
# Defensive copy of SamplingParams, which are used by the sampler,
# this doesn't deep-copy LogitsProcessor objects
sampling_params
=
sampling_params
.
clone
()
# Create the sequence group.
seq_group
=
SequenceGroup
(
request_id
,
[
seq
],
sampling_params
,
...
...
vllm/sampling_params.py
View file @
29a8d6a5
"""Sampling parameters for text generation."""
import
copy
from
enum
import
IntEnum
from
functools
import
cached_property
from
typing
import
Callable
,
List
,
Optional
,
Union
...
...
@@ -237,6 +238,20 @@ class SamplingParams:
return
SamplingType
.
RANDOM_SEED
return
SamplingType
.
RANDOM
def
clone
(
self
)
->
"SamplingParams"
:
"""Deep copy excluding LogitsProcessor objects.
LogitsProcessor objects are excluded because they may contain an
arbitrary, nontrivial amount of data.
See https://github.com/vllm-project/vllm/issues/3087
"""
logit_processor_refs
=
None
if
self
.
logits_processors
is
None
else
{
id
(
lp
):
lp
for
lp
in
self
.
logits_processors
}
return
copy
.
deepcopy
(
self
,
memo
=
logit_processor_refs
)
def
__repr__
(
self
)
->
str
:
return
(
f
"SamplingParams(n=
{
self
.
n
}
, "
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment