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
1528e079
Unverified
Commit
1528e079
authored
Dec 02, 2025
by
jthomson04
Committed by
GitHub
Dec 02, 2025
Browse files
[Perf] Avoid pageable HtoD transfer in MinTokensLogitsProcessor (#29826)
Signed-off-by:
jthomson04
<
jwillthomson19@gmail.com
>
parent
afb1e5b3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
vllm/v1/sample/logits_processor/builtin.py
vllm/v1/sample/logits_processor/builtin.py
+6
-2
No files found.
vllm/v1/sample/logits_processor/builtin.py
View file @
1528e079
...
...
@@ -110,7 +110,7 @@ class MinPLogitsProcessor(LogitsProcessor):
# Identify valid tokens using threshold comparison
invalid_token_mask
=
probability_values
<
adjusted_min_p
# Apply mask using boolean indexing
logits
[
invalid_token_mask
]
=
-
float
(
"inf"
)
logits
.
masked_fill_
(
invalid_token_mask
,
-
float
(
"inf"
)
)
return
logits
...
...
@@ -178,6 +178,10 @@ class MinTokensLogitsProcessor(LogitsProcessor):
self
.
_device_tensor
([],
torch
.
int32
),
)
self
.
neg_inf_tensor
=
torch
.
tensor
(
-
float
(
"inf"
),
dtype
=
torch
.
float32
,
device
=
self
.
device
)
def
is_argmax_invariant
(
self
)
->
bool
:
"""By censoring stop tokens, min-tokens can change the outcome
of the argmax operation in greedy sampling."""
...
...
@@ -229,7 +233,7 @@ class MinTokensLogitsProcessor(LogitsProcessor):
def
apply
(
self
,
logits
:
torch
.
Tensor
)
->
torch
.
Tensor
:
if
self
.
min_toks
:
# Inhibit EOS token for requests which have not reached min length
logits
[
self
.
logits_slice
]
=
-
float
(
"inf"
)
logits
.
index_put_
(
self
.
logits_slice
,
self
.
neg_inf_tensor
)
return
logits
...
...
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