-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changed scheduler to use deques instead of lists #2290
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @NadavShmayo, thanks for submitting the PR! Yes, it seems we should use deque instead of list for the queues in our scheduler. I left some minor comments on the PR. Please take a look at them!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I've made some minor changes to accelerate the merge. Thanks again for the PR!
Hey, sorry for the delayed response. Regarding the changes in the Thanks for the review! 😄 |
Co-authored-by: Woosuk Kwon <[email protected]>
vllm-project#2290 changed the scheduler seq group lists to be deques for more efficient updates, but missed one place where the `running` deque gets converted back to a list.
Co-authored-by: Woosuk Kwon <[email protected]>
Currently the scheduler uses lists to store the running, waiting and swapped requests.
When iterating over each state queue we pop the first item and append to a new list, which is not good for performance since each pop is O(N) time complexity, which means the scheduler currently runs in O(N^2) time complexity (a pop happens for each item in the state queue).
Instead of using lists we could use deques, since we can pop the first item from a deque in O(1) time complexity, making the scheduler run in O(N) time complexity instead of O(N^2).
I wasn't sure whether I should keep the same types in the SchedulerOutputs class and cast from a deque to a list before returning the result, but since it seems to work with the SchedulerOutputs contains deques instead of lists I decided to change the types.