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
2cb921da
Commit
2cb921da
authored
Sep 24, 2025
by
lizhigong
Browse files
fix scheduler issu in pp + mtp
parent
5086453d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
6 deletions
+8
-6
vllm/v1/core/sched/scheduler.py
vllm/v1/core/sched/scheduler.py
+5
-4
vllm/v1/request.py
vllm/v1/request.py
+1
-0
vllm/v1/worker/gpu_model_runner.py
vllm/v1/worker/gpu_model_runner.py
+2
-2
No files found.
vllm/v1/core/sched/scheduler.py
View file @
2cb921da
...
@@ -1047,16 +1047,14 @@ class Scheduler(SchedulerInterface):
...
@@ -1047,16 +1047,14 @@ class Scheduler(SchedulerInterface):
for
req
in
itertools
.
chain
(
running_reqs
,
resumed_reqs
):
for
req
in
itertools
.
chain
(
running_reqs
,
resumed_reqs
):
req_id
=
req
.
request_id
req_id
=
req
.
request_id
req_ids
.
append
(
req_id
)
req_ids
.
append
(
req_id
)
num_tokens
=
(
num_scheduled_tokens
[
req_id
]
-
num_tokens
=
req
.
num_generated_token_ids
len
(
spec_decode_tokens
.
get
(
req_id
,
())))
if
self
.
use_pp
:
if
self
.
use_pp
:
# When using PP, the scheduler sends the sampled tokens back,
# When using PP, the scheduler sends the sampled tokens back,
# because there's no direct communication between the first-
# because there's no direct communication between the first-
# stage worker and the last-stage worker. Otherwise, we don't
# stage worker and the last-stage worker. Otherwise, we don't
# need to send the sampled tokens back because the model runner
# need to send the sampled tokens back because the model runner
# will cache them.
# will cache them.
token_ids
=
req
.
all_token_ids
[
req
.
num_computed_tokens
:
req
.
token_ids
=
req
.
all_token_ids
[
-
num_tokens
:]
num_computed_tokens
+
num_tokens
]
new_token_ids
.
append
(
token_ids
)
new_token_ids
.
append
(
token_ids
)
new_block_ids
.
append
(
req_to_new_block_ids
[
req_id
])
new_block_ids
.
append
(
req_to_new_block_ids
[
req_id
])
num_computed_tokens
.
append
(
req
.
num_computed_tokens
)
num_computed_tokens
.
append
(
req
.
num_computed_tokens
)
...
@@ -1190,6 +1188,7 @@ class Scheduler(SchedulerInterface):
...
@@ -1190,6 +1188,7 @@ class Scheduler(SchedulerInterface):
scheduled_spec_token_ids
=
(
scheduled_spec_token_ids
=
(
scheduler_output
.
scheduled_spec_decode_tokens
.
get
(
req_id
))
scheduler_output
.
scheduled_spec_decode_tokens
.
get
(
req_id
))
request
.
num_generated_token_ids
=
1
if
scheduled_spec_token_ids
:
if
scheduled_spec_token_ids
:
# num_computed_tokens represents the number of tokens
# num_computed_tokens represents the number of tokens
# processed in the current step, considering scheduled
# processed in the current step, considering scheduled
...
@@ -1197,9 +1196,11 @@ class Scheduler(SchedulerInterface):
...
@@ -1197,9 +1196,11 @@ class Scheduler(SchedulerInterface):
# num_computed_tokens is decreased by the number of rejected
# num_computed_tokens is decreased by the number of rejected
# tokens, where is given by:
# tokens, where is given by:
# len(scheduled_spec_token_ids) + 1 - len(generated_token_ids).
# len(scheduled_spec_token_ids) + 1 - len(generated_token_ids).
num_tokens_rejected
=
(
len
(
scheduled_spec_token_ids
)
+
1
-
num_tokens_rejected
=
(
len
(
scheduled_spec_token_ids
)
+
1
-
len
(
generated_token_ids
))
len
(
generated_token_ids
))
request
.
num_computed_tokens
-=
num_tokens_rejected
request
.
num_computed_tokens
-=
num_tokens_rejected
request
.
num_generated_token_ids
=
len
(
generated_token_ids
)
spec_decoding_stats
=
self
.
make_spec_decoding_stats
(
spec_decoding_stats
=
self
.
make_spec_decoding_stats
(
spec_decoding_stats
,
spec_decoding_stats
,
num_draft_tokens
=
len
(
scheduled_spec_token_ids
),
num_draft_tokens
=
len
(
scheduled_spec_token_ids
),
...
...
vllm/v1/request.py
View file @
2cb921da
...
@@ -79,6 +79,7 @@ class Request:
...
@@ -79,6 +79,7 @@ class Request:
self
.
_all_token_ids
:
list
[
int
]
=
self
.
prompt_token_ids
.
copy
()
self
.
_all_token_ids
:
list
[
int
]
=
self
.
prompt_token_ids
.
copy
()
self
.
spec_token_ids
:
list
[
int
]
=
[]
self
.
spec_token_ids
:
list
[
int
]
=
[]
self
.
num_computed_tokens
=
0
self
.
num_computed_tokens
=
0
self
.
num_generated_token_ids
=
0
self
.
cache_salt
:
Optional
[
str
]
=
cache_salt
self
.
cache_salt
:
Optional
[
str
]
=
cache_salt
# Multi-modal related
# Multi-modal related
...
...
vllm/v1/worker/gpu_model_runner.py
View file @
2cb921da
...
@@ -496,8 +496,8 @@ class GPUModelRunner(LoRAModelRunnerMixin):
...
@@ -496,8 +496,8 @@ class GPUModelRunner(LoRAModelRunnerMixin):
elif
num_new_tokens
>
0
:
elif
num_new_tokens
>
0
:
req_state
.
output_token_ids
.
extend
(
req_state
.
output_token_ids
.
extend
(
new_token_ids
[
-
num_new_tokens
:])
new_token_ids
[
-
num_new_tokens
:])
if
len
(
spec_token_ids
)
>
0
:
if
len
(
spec_token_ids
)
>
0
:
req_state
.
spec_token_ids
=
spec_token_ids
req_state
.
spec_token_ids
=
spec_token_ids
# Update the block IDs.
# Update the block IDs.
if
not
resumed_from_preemption
:
if
not
resumed_from_preemption
:
...
...
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