Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
6a62cb82
Unverified
Commit
6a62cb82
authored
Jun 28, 2024
by
Robert Shaw
Committed by
GitHub
Jun 28, 2024
Browse files
[Bugfix] Fix Engine Failing After Invalid Request - AsyncEngineDeadError (#5963)
Co-authored-by:
Robert Shaw
<
rshaw@neuralmagic
>
parent
5d2a1a9c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
10 deletions
+24
-10
vllm/entrypoints/openai/protocol.py
vllm/entrypoints/openai/protocol.py
+24
-10
No files found.
vllm/entrypoints/openai/protocol.py
View file @
6a62cb82
...
...
@@ -234,15 +234,22 @@ class ChatCompletionRequest(OpenAIBaseModel):
logits_processors
=
None
if
self
.
logit_bias
:
logit_bias
:
Dict
[
int
,
float
]
=
{}
try
:
for
token_id
,
bias
in
self
.
logit_bias
.
items
():
# Convert token_id to integer before we add to LLMEngine
# Clamp the bias between -100 and 100 per OpenAI API spec
logit_bias
[
int
(
token_id
)]
=
min
(
100
,
max
(
-
100
,
bias
))
except
ValueError
as
exc
:
raise
ValueError
(
f
"Found token_id `
{
token_id
}
` in logit_bias "
f
"but token_id must be an integer or string "
f
"representing an integer"
)
from
exc
def
logit_bias_logits_processor
(
token_ids
:
List
[
int
],
logits
:
torch
.
Tensor
)
->
torch
.
Tensor
:
assert
self
.
logit_bias
is
not
None
for
token_id
,
bias
in
self
.
logit_bias
.
items
():
# Clamp the bias between -100 and 100 per OpenAI API spec
bias
=
min
(
100
,
max
(
-
100
,
bias
))
logits
[
int
(
token_id
)]
+=
bias
for
token_id
,
bias
in
logit_bias
.
items
():
logits
[
token_id
]
+=
bias
return
logits
logits_processors
=
[
logit_bias_logits_processor
]
...
...
@@ -419,15 +426,22 @@ class CompletionRequest(OpenAIBaseModel):
logits_processors
=
None
if
self
.
logit_bias
:
logit_bias
:
Dict
[
int
,
float
]
=
{}
try
:
for
token_id
,
bias
in
self
.
logit_bias
.
items
():
# Convert token_id to integer
# Clamp the bias between -100 and 100 per OpenAI API spec
logit_bias
[
int
(
token_id
)]
=
min
(
100
,
max
(
-
100
,
bias
))
except
ValueError
as
exc
:
raise
ValueError
(
f
"Found token_id `
{
token_id
}
` in logit_bias "
f
"but token_id must be an integer or string "
f
"representing an integer"
)
from
exc
def
logit_bias_logits_processor
(
token_ids
:
List
[
int
],
logits
:
torch
.
Tensor
)
->
torch
.
Tensor
:
assert
self
.
logit_bias
is
not
None
for
token_id
,
bias
in
self
.
logit_bias
.
items
():
# Clamp the bias between -100 and 100 per OpenAI API spec
bias
=
min
(
100
,
max
(
-
100
,
bias
))
logits
[
int
(
token_id
)]
+=
bias
for
token_id
,
bias
in
logit_bias
.
items
():
logits
[
token_id
]
+=
bias
return
logits
logits_processors
=
[
logit_bias_logits_processor
]
...
...
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