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
544fe76b
Unverified
Commit
544fe76b
authored
Sep 17, 2025
by
Chauncey
Committed by
GitHub
Sep 17, 2025
Browse files
[Frontend] Support returning all prompt logprobs (#24956)
Signed-off-by:
chaunceyjiang
<
chaunceyjiang@gmail.com
>
parent
bb58dc8c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
8 deletions
+38
-8
tests/entrypoints/openai/test_chat_echo.py
tests/entrypoints/openai/test_chat_echo.py
+22
-0
vllm/entrypoints/openai/protocol.py
vllm/entrypoints/openai/protocol.py
+16
-8
No files found.
tests/entrypoints/openai/test_chat_echo.py
View file @
544fe76b
...
...
@@ -22,6 +22,8 @@ def server():
"--enforce-eager"
,
"--max-model-len"
,
"4080"
,
"--max-logprobs"
,
# test prompt_logprobs equal to -1
"151936"
]
with
RemoteOpenAIServer
(
MODEL_NAME
,
args
)
as
remote_server
:
...
...
@@ -77,3 +79,23 @@ async def test_chat_session_with_echo_and_continue_final_message(
else
:
assert
message
.
content
is
not
None
and
saying
not
in
message
.
content
assert
message
.
role
==
"assistant"
@
pytest
.
mark
.
asyncio
async
def
test_prompt_logprobs
(
client
:
openai
.
AsyncOpenAI
):
messages
=
[{
"role"
:
"system"
,
"content"
:
"You are a helpful assistant."
},
{
"role"
:
"user"
,
"content"
:
"Beijing is the capital of which country?"
}]
completion
=
await
client
.
chat
.
completions
.
create
(
model
=
MODEL_NAME
,
messages
=
messages
,
extra_body
=
{
"prompt_logprobs"
:
-
1
},
)
assert
completion
.
prompt_logprobs
is
not
None
assert
len
(
completion
.
prompt_logprobs
)
>
0
vllm/entrypoints/openai/protocol.py
View file @
544fe76b
...
...
@@ -822,13 +822,17 @@ class ChatCompletionRequest(OpenAIBaseModel):
@
classmethod
def
check_logprobs
(
cls
,
data
):
if
(
prompt_logprobs
:
=
data
.
get
(
"prompt_logprobs"
))
is
not
None
:
if
data
.
get
(
"stream"
)
and
prompt_logprobs
>
0
:
if
data
.
get
(
"stream"
)
and
(
prompt_logprobs
>
0
or
prompt_logprobs
==
-
1
):
raise
ValueError
(
"`prompt_logprobs` are not available when `stream=True`."
)
if
prompt_logprobs
<
0
:
raise
ValueError
(
"`prompt_logprobs` must be a positive value."
)
if
prompt_logprobs
<
0
and
prompt_logprobs
!=
-
1
:
raise
ValueError
(
"`prompt_logprobs` must be a positive value or -1."
)
if
prompt_logprobs
==
-
1
and
not
envs
.
VLLM_USE_V1
:
raise
ValueError
(
"`prompt_logprobs=-1` is only supported with "
"vLLM engine V1."
)
if
(
top_logprobs
:
=
data
.
get
(
"top_logprobs"
))
is
not
None
:
if
top_logprobs
<
0
:
raise
ValueError
(
"`top_logprobs` must be a positive value."
)
...
...
@@ -1246,13 +1250,17 @@ class CompletionRequest(OpenAIBaseModel):
@
classmethod
def
check_logprobs
(
cls
,
data
):
if
(
prompt_logprobs
:
=
data
.
get
(
"prompt_logprobs"
))
is
not
None
:
if
data
.
get
(
"stream"
)
and
prompt_logprobs
>
0
:
if
data
.
get
(
"stream"
)
and
(
prompt_logprobs
>
0
or
prompt_logprobs
==
-
1
):
raise
ValueError
(
"`prompt_logprobs` are not available when `stream=True`."
)
if
prompt_logprobs
<
0
:
raise
ValueError
(
"`prompt_logprobs` must be a positive value."
)
if
prompt_logprobs
<
0
and
prompt_logprobs
!=
-
1
:
raise
ValueError
(
"`prompt_logprobs` must be a positive value or -1."
)
if
prompt_logprobs
==
-
1
and
not
envs
.
VLLM_USE_V1
:
raise
ValueError
(
"`prompt_logprobs=-1` is only supported with "
"vLLM engine V1."
)
if
(
logprobs
:
=
data
.
get
(
"logprobs"
))
is
not
None
and
logprobs
<
0
:
raise
ValueError
(
"`logprobs` must be a positive value."
)
...
...
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