Skip to content

[DeepGemm] Add a flag for fast warmup#18111

Merged
Fridge003 merged 5 commits into
mainfrom
baizhou/deepgemm
Feb 4, 2026
Merged

[DeepGemm] Add a flag for fast warmup#18111
Fridge003 merged 5 commits into
mainfrom
baizhou/deepgemm

Conversation

@Fridge003
Copy link
Copy Markdown
Collaborator

Motivation

Add a flag SGLANG_JIT_DEEPGEMM_FAST_WARMUP, which reduce the number of kernels to precompile during warmup

Modifications

Accuracy Tests

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 Feb 2, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @Fridge003, 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 introduces a new configuration option to optimize the DeepGEMM kernel precompilation process. By enabling a 'fast warmup' flag, users can significantly reduce the initial startup time of the system, which is particularly beneficial for development or testing environments where quick iteration is desired. While this optimization comes with a potential compromise in peak runtime performance, it offers a valuable trade-off for specific use cases, allowing for quicker system readiness at the cost of potential runtime efficiency.

Highlights

  • New Environment Variable: A new environment variable, SGLANG_JIT_DEEPGEMM_FAST_WARMUP, has been introduced to control the DeepGEMM kernel precompilation process.
  • Fast Warmup Mode: Enabling SGLANG_JIT_DEEPGEMM_FAST_WARMUP significantly reduces the number of kernels precompiled during warmup, cutting down warmup time from approximately 30 minutes to less than 3 minutes.
  • Performance Trade-off: While fast warmup speeds up initialization, it might lead to performance degradation during runtime due to fewer precompiled kernels.
  • Environment Variable Renaming: Existing DeepGEMM-related environment variables, SGL_DG_USE_NVRTC and SGL_USE_DEEPGEMM_BMM, have been renamed to SGLANG_DG_USE_NVRTC and SGLANG_USE_DEEPGEMM_BMM respectively for consistency.

🧠 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.

@Fridge003
Copy link
Copy Markdown
Collaborator Author

cc @ishandhanani @alisonshao

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 introduces a new flag SGLANG_JIT_DEEPGEMM_FAST_WARMUP to significantly reduce the warmup time for DeepGEMM by precompiling a smaller, sampled set of kernels. The changes include adding the environment variable, updating documentation, and implementing the fast warmup logic. The implementation is mostly correct, but I have a couple of suggestions to improve robustness and user experience. I've also noted a minor documentation fix for other environment variables. Overall, this is a valuable addition for improving developer iteration speed.

Comment thread python/sglang/srt/layers/deep_gemm_wrapper/compile_utils.py
Comment thread python/sglang/srt/layers/deep_gemm_wrapper/compile_utils.py Outdated
Fridge003 and others added 2 commits February 2, 2026 20:50
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@Fridge003
Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ci

@Fridge003 Fridge003 closed this Feb 3, 2026
@Fridge003 Fridge003 reopened this Feb 3, 2026
@github-actions github-actions Bot added the run-ci label Feb 3, 2026
@Fridge003
Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ci

@Fridge003 Fridge003 merged commit d279520 into main Feb 4, 2026
141 of 160 checks passed
@Fridge003 Fridge003 deleted the baizhou/deepgemm branch February 4, 2026 06:12
Fridge003 added a commit that referenced this pull request Feb 5, 2026
RubiaCx pushed a commit to RubiaCx/sglang that referenced this pull request Feb 8, 2026
Johnsonms pushed a commit to Johnsonms/sglang that referenced this pull request Feb 14, 2026
Wangzheee pushed a commit to Wangzheee/sglang that referenced this pull request Mar 21, 2026
parrot18 pushed a commit to parrot18/sglang that referenced this pull request Apr 26, 2026
## Background

When deploying DeepSeek-V4-Flash with TP>=2 and CUDA graph enabled,
the server fails to start due to NCCL timeout. The root cause:

1. During CUDA graph capture warmup, Rank 0 blocks for minutes
   compiling all M values (1..16384) via DeepGEMM JIT, while other
   ranks finish their GEMM quickly and wait at all-reduce.
2. NCCL has a default 30-minute timeout. With the full M list,
   Rank 0 compilation takes 5-10+ minutes per kernel type, easily
   exceeding the timeout when 6 kernel types are compiled sequentially.

Without CUDA graph, single-request decode TPOT is ~133ms/tok regardless
of context length (kernel launch overhead dominates). With CUDA graph,
single-request decode TPOT drops to ~22ms/tok (~6x improvement).
So enabling CUDA graph is critical for decode performance.

## What FAST_WARMUP does

Ported from main branch (PR sgl-project#18111), this feature reduces the M list
from ~16384 to ~2560 values:

- M=1..1024: all compiled (covers decode batch sizes completely)
- M=1025..max_prefill_bs: logarithmic sampling (step doubles each range)
  e.g. step 2 for [1024,2048), step 4 for [2048,4096), etc.

This reduces Rank 0 compilation time from ~5-10min to ~90s, avoiding
the NCCL timeout. Total cold start with CUDA graph: ~5.5min.

Tradeoff: some prefill M values may not be pre-compiled, causing
one-time JIT delay on first encounter. Decode is unaffected since
all M<=1024 are always compiled.

## Changes

- compile_utils.py: Add _FAST_WARMUP path in update_deep_gemm_config()
  with sampled M list generation; add nullcontext/is_musa imports;
  refactor deep_gemm_execution_hook to plain function returning
  context manager (MUSA compat); add hasattr guards for
  get_compile_mode/set_compile_mode (older DeepGEMM compat);
  defer _BUILTIN_M_LIST init to update_deep_gemm_config()
- environ.py: Add SGLANG_JIT_DEEPGEMM_FAST_WARMUP (EnvBool, default
  False) and SGLANG_DEEPGEMM_SANITY_CHECK (EnvBool, default False)
- entrypoint.py: Use envs.SGLANG_DEEPGEMM_SANITY_CHECK instead of
  get_bool_env_var; add ENABLE_JIT_DEEPGEMM guard in
  configure_deep_gemm_num_sms

## Usage

SGLANG_JIT_DEEPGEMM_FAST_WARMUP=True python3 -m sglang.launch_server \
  --model-path <model> --tp-size 4 --moe-runner-backend deep_gemm ...

Signed-off-by: ruying.bupt <yingru@baidu.com>
0826joyce pushed a commit to 0826joyce/sglang-perf-opt that referenced this pull request May 19, 2026
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.

3 participants