Skip to content

feat: add forward timeout#17831

Merged
BBuf merged 1 commit intosgl-project:mainfrom
zhooooong:zhong/add_forward_timeout
Jan 30, 2026
Merged

feat: add forward timeout#17831
BBuf merged 1 commit intosgl-project:mainfrom
zhooooong:zhong/add_forward_timeout

Conversation

@zhooooong
Copy link
Copy Markdown
Contributor

Motivation

Introduce a timeout for requests in the forward batch.

Modifications

Introduce a new environment variable SGLANG_FORWARD_TIMEOUT_MS. In the scheduler, abort requests that have exceeded the forward timeout before the next decode step.

Accuracy Tests

server cmd:

export SGLANG_FORWARD_TIMEOUT_MS=1  # 1ms for test
python3 -m sglang.launch_server --model $model_path --skip-server-warmup

Then, send a few requests casually. Subsequently, the requests encountered the error, as expected:

{"object":"error","message":"Forward timeout.","type":"HTTPStatus.SERVICE_UNAVAILABLE","param":null,"code":503}

Benchmarking and Profiling

Checklist

Review Process

  1. Ping Merge Oncalls to start the PR flow. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • /tag-run-ci-label, /rerun-failed-ci, /tag-and-rerun-ci
  4. After green CI and required approvals, ask Merge Oncalls to merge.

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Jan 27, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @zhooooong, 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 enhances the SGLang server's robustness by integrating a configurable timeout mechanism for requests during their forward processing. This feature prevents requests from consuming excessive resources or hanging indefinitely, thereby improving the overall stability and responsiveness of the server by gracefully handling long-running or stuck operations.

Highlights

  • New Environment Variable: Introduced SGLANG_FORWARD_TIMEOUT_MS to configure a timeout for requests within the forward batch.
  • Request Abort Mechanism: Implemented logic in the scheduler to abort requests that exceed the configured SGLANG_FORWARD_TIMEOUT_MS during both prefill and decode phases.
  • Documentation Update: The new environment variable SGLANG_FORWARD_TIMEOUT_MS has been added to the official documentation.
  • Unit Test Coverage: A new unit test has been added to verify the functionality of the forward timeout, ensuring requests are correctly aborted when the timeout is exceeded.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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

The pull request introduces a new environment variable SGLANG_FORWARD_TIMEOUT_MS to control the timeout for requests in the forward batch. The implementation correctly integrates this timeout into both prefill and decode stages of the scheduler, aborting requests that exceed the configured duration. A dedicated unit test has been added to verify the functionality, ensuring that requests time out as expected. The documentation has also been updated to reflect the new environment variable. The changes are well-implemented and thoroughly tested.

@BBuf
Copy link
Copy Markdown
Collaborator

BBuf commented Jan 28, 2026

/tag-and-rerun-ci

@BBuf BBuf merged commit 2b3408f into sgl-project:main Jan 30, 2026
198 of 221 checks passed
charlesHsuGG pushed a commit to charlesHsuGG/sglang that referenced this pull request Jan 30, 2026
Co-authored-by: qiuxuan.lzw <qiuxuan.lzw@alibaba-inc.com>
Chen-0210 pushed a commit to Chen-0210/sglang that referenced this pull request Jan 30, 2026
Co-authored-by: qiuxuan.lzw <qiuxuan.lzw@alibaba-inc.com>
sfiisf pushed a commit to sfiisf/sglang that referenced this pull request Feb 5, 2026
Co-authored-by: qiuxuan.lzw <qiuxuan.lzw@alibaba-inc.com>
Johnsonms pushed a commit to Johnsonms/sglang that referenced this pull request Feb 14, 2026
Co-authored-by: qiuxuan.lzw <qiuxuan.lzw@alibaba-inc.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation run-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants