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
e42c634a
Unverified
Commit
e42c634a
authored
Sep 20, 2024
by
盏一
Committed by
GitHub
Sep 19, 2024
Browse files
[Core] simplify logits resort in _apply_top_k_top_p (#8619)
parent
9cc373f3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
6 deletions
+3
-6
vllm/model_executor/layers/sampler.py
vllm/model_executor/layers/sampler.py
+3
-6
No files found.
vllm/model_executor/layers/sampler.py
View file @
e42c634a
...
@@ -433,12 +433,9 @@ def _apply_top_k_top_p(
...
@@ -433,12 +433,9 @@ def _apply_top_k_top_p(
logits_sort
.
masked_fill_
(
top_p_mask
,
-
float
(
"inf"
))
logits_sort
.
masked_fill_
(
top_p_mask
,
-
float
(
"inf"
))
# Re-sort the probabilities.
# Re-sort the probabilities.
src
=
torch
.
arange
(
logits_idx
.
shape
[
-
1
],
logits
=
torch
.
empty_like
(
logits_sort
).
scatter_
(
dim
=-
1
,
device
=
logits_idx
.
device
).
expand_as
(
logits_idx
)
logits_idx_inv
=
torch
.
empty_like
(
logits_idx
).
scatter_
(
dim
=-
1
,
index
=
logits_idx
,
index
=
logits_idx
,
src
=
src
)
src
=
logits_sort
)
logits
=
torch
.
gather
(
logits_sort
,
dim
=-
1
,
index
=
logits_idx_inv
)
return
logits
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