-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Use dynamically maintained num_waiting_tokens in get_load() #13203
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
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @vipwangerxiao, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors the token load calculation within the scheduler by introducing a dedicated counter for waiting tokens. This counter is updated incrementally as requests move through different queues, eliminating the need for expensive on-the-fly summations. The primary goal is to enhance performance and reduce computational overhead when determining the system's current load. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request introduces a significant performance improvement by replacing the expensive, on-demand calculation of num_waiting_tokens with a dynamically maintained counter. The implementation is well-executed, with the counter being correctly updated across various request lifecycle events and queues. This change not only optimizes the get_load() function but also fixes a pre-existing bug where tokens in the transfer queue were not being counted. I've also identified and suggested a fix for a similar issue in the calculation of num_waiting_reqs to ensure load balancing accuracy. Overall, this is a solid contribution that enhances both performance and correctness.
ecb24b6 to
e4f8180
Compare
Signed-off-by: Peng Wang <[email protected]>
e4f8180 to
ae1867b
Compare
Motivation
Use dynamically maintained num_waiting_tokens in get_load() to avoid list access
Modifications
num_waiting_tokens represents the total number of tokens in the waiting queue
It increases when requests enter the waiting queue, and decreases when requests leave the waiting queue to running list or abort
num_waiting_tokens represents the total number of tokens in the bootstrap/waiting queue
It increases when requests enter the bootstrap queue, and decreases when requests leave the waiting queue to running list or fail in bootstrap queue
num_waiting_tokens represents the total number of tokens in the prealloc/retract queue, not including waiting queue because KV cache allocating is done before request gets in waiting queue
It increases when requests enter the prealloc/retrac queue, and decreases when requests leave the prealloc queue to transfer queue, or leave retract queue to waiting queue, or abort in prealloc queue
Accuracy Tests
Compare the dynamically maintained num_waiting_tokens(num_tokens) with the value obtained directly from the queues(direct_sum_num_tokens), and they are expected to be the same.
no PD disaggregation
PD disaggregation: P node
PD disaggregation: D node
Benchmarking and Profiling
Checklist