Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
norm
vllm
Commits
48cf1e41
Unverified
Commit
48cf1e41
authored
Jan 13, 2024
by
陈序
Committed by
GitHub
Jan 12, 2024
Browse files
fix: deque mutated during iteration in abort_seq_group (#2371)
parent
97460585
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
13 deletions
+16
-13
vllm/core/scheduler.py
vllm/core/scheduler.py
+16
-13
No files found.
vllm/core/scheduler.py
View file @
48cf1e41
...
@@ -104,21 +104,24 @@ class Scheduler:
...
@@ -104,21 +104,24 @@ class Scheduler:
request_id
=
(
request_id
,
)
request_id
=
(
request_id
,
)
request_ids
=
set
(
request_id
)
request_ids
=
set
(
request_id
)
for
state_queue
in
[
self
.
waiting
,
self
.
running
,
self
.
swapped
]:
for
state_queue
in
[
self
.
waiting
,
self
.
running
,
self
.
swapped
]:
# We need to reverse the list as we are removing elements
aborted_groups
=
[]
# from it as we iterate over it. If we don't do it,
for
seq_group
in
state_queue
:
# indices will get messed up and we will skip over elements.
if
not
request_ids
:
for
seq_group
in
reversed
(
state_queue
):
# Using 'break' here may add two extra iterations,
# but is acceptable to reduce complexity .
break
if
seq_group
.
request_id
in
request_ids
:
if
seq_group
.
request_id
in
request_ids
:
# Remove the sequence group from the state queue.
# Appending aborted group into pending list.
state_queue
.
remove
(
seq_group
)
aborted_groups
.
append
(
seq_group
)
for
seq
in
seq_group
.
get_seqs
():
if
seq
.
is_finished
():
continue
seq
.
status
=
SequenceStatus
.
FINISHED_ABORTED
self
.
free_seq
(
seq
)
request_ids
.
remove
(
seq_group
.
request_id
)
request_ids
.
remove
(
seq_group
.
request_id
)
if
not
request_ids
:
for
aborted_group
in
aborted_groups
:
return
# Remove the sequence group from the state queue.
state_queue
.
remove
(
aborted_group
)
for
seq
in
seq_group
.
get_seqs
():
if
seq
.
is_finished
():
continue
seq
.
status
=
SequenceStatus
.
FINISHED_ABORTED
self
.
free_seq
(
seq
)
def
has_unfinished_seqs
(
self
)
->
bool
:
def
has_unfinished_seqs
(
self
)
->
bool
:
return
self
.
waiting
or
self
.
running
or
self
.
swapped
return
self
.
waiting
or
self
.
running
or
self
.
swapped
...
...
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