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
7bdb42b2
Unverified
Commit
7bdb42b2
authored
Nov 07, 2025
by
Zhang Xiangze
Committed by
GitHub
Nov 07, 2025
Browse files
[CPU]Avoid repeated random sample compile (#28260)
Signed-off-by:
Zhang Xiangze
<
Xiangze.Zhang@arm.com
>
parent
315068eb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
9 deletions
+10
-9
vllm/v1/sample/ops/topk_topp_sampler.py
vllm/v1/sample/ops/topk_topp_sampler.py
+10
-9
No files found.
vllm/v1/sample/ops/topk_topp_sampler.py
View file @
7bdb42b2
...
...
@@ -127,15 +127,6 @@ class TopKTopPSampler(nn.Module):
elif
self
.
logprobs_mode
==
"processed_logprobs"
:
logits_to_return
=
logits
.
log_softmax
(
dim
=-
1
,
dtype
=
torch
.
float32
)
# Note: this is a workaround for
# https://github.com/pytorch/pytorch/pull/151218
@
torch
.
compile
(
dynamic
=
True
)
def
compiled_random_sample
(
logits
:
torch
.
Tensor
)
->
torch
.
Tensor
:
probs
=
logits
.
softmax
(
dim
=-
1
,
dtype
=
torch
.
float32
)
q
=
torch
.
empty_like
(
probs
)
q
.
exponential_
()
return
probs
.
div
(
q
).
argmax
(
dim
=-
1
).
view
(
-
1
)
if
len
(
generators
)
!=
logits
.
shape
[
0
]:
return
compiled_random_sample
(
logits
),
logits_to_return
else
:
...
...
@@ -148,6 +139,16 @@ class TopKTopPSampler(nn.Module):
return
probs
.
div_
(
q
).
argmax
(
dim
=-
1
).
view
(
-
1
),
logits_to_return
# Note: this is a workaround for
# https://github.com/pytorch/pytorch/pull/151218
@
torch
.
compile
(
dynamic
=
True
)
def
compiled_random_sample
(
logits
:
torch
.
Tensor
)
->
torch
.
Tensor
:
probs
=
logits
.
softmax
(
dim
=-
1
,
dtype
=
torch
.
float32
)
q
=
torch
.
empty_like
(
probs
)
q
.
exponential_
()
return
probs
.
div
(
q
).
argmax
(
dim
=-
1
).
view
(
-
1
)
def
apply_top_k_top_p
(
logits
:
torch
.
Tensor
,
k
:
torch
.
Tensor
|
None
,
...
...
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