Skip to content

Fix wrong running_bs in priority scheduling#13142

Merged
hnyls2002 merged 1 commit intosgl-project:mainfrom
openanolis:dtcccc/fixbs
Nov 13, 2025
Merged

Fix wrong running_bs in priority scheduling#13142
hnyls2002 merged 1 commit intosgl-project:mainfrom
openanolis:dtcccc/fixbs

Conversation

@dtcccc
Copy link
Copy Markdown
Contributor

@dtcccc dtcccc commented Nov 12, 2025

I receive following logs when running
test_priority_scheduling_with_multiple_running_requests_preemption.

Prefill batch, #new-seq: 1, #new-token: 30, #cached-token: 0, token usage: 0.00, #running-req: -1, #queue-req: 2,

running_batch has been filtered in preempt_to_schedule(). No need to subtract preempt_list again.

Motivation

Modifications

Accuracy Tests

Benchmarking and Profiling

Checklist

I receive following logs when running
test_priority_scheduling_with_multiple_running_requests_preemption.

Prefill batch, #new-seq: 1, #new-token: 30, #cached-token: 0, token usage: 0.00, #running-req: -1, #queue-req: 2,

running_batch has been filtered in preempt_to_schedule().
No need to subtract preempt_list again.

Signed-off-by: Tianchen Ding <dtcccc@linux.alibaba.com>
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @dtcccc, 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 addresses a critical bug in the priority scheduling mechanism where the count of active requests (running_bs) was inaccurately computed. By rectifying this calculation, the change ensures that the scheduler makes correct decisions regarding batching and preemption, thereby improving the stability and efficiency of the system's resource allocation.

Highlights

  • Scheduling Logic Fix: Corrected an error in the calculation of running_bs within the scheduler, which represents the number of currently running requests.
  • Redundant Subtraction Removal: Removed a redundant subtraction of len(adder.preempt_list) from running_bs, as the running_batch had already been filtered by preempt_to_schedule().
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a 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 correctly fixes a bug in the priority scheduling logic. The original code was incorrectly calculating the running batch size after preemption by subtracting the number of preempted requests from an already-updated running batch, which led to double-counting. The change ensures the running batch size is calculated correctly by simply using the length of the running_batch.reqs, which is already filtered. This is a good and necessary fix.

Copy link
Copy Markdown
Collaborator

@ShangmingCai ShangmingCai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@harrisonlimh
Copy link
Copy Markdown
Collaborator

LGTM! Thank you!

@hnyls2002 hnyls2002 merged commit 8779100 into sgl-project:main Nov 13, 2025
203 of 242 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants