Skip to content

[Qwen3Next] Optimize fused_sigmoid_gating_delta_rule_update_kernel#18271

Merged
Fridge003 merged 1 commit intosgl-project:mainfrom
hlu1:gdn
Feb 7, 2026
Merged

[Qwen3Next] Optimize fused_sigmoid_gating_delta_rule_update_kernel#18271
Fridge003 merged 1 commit intosgl-project:mainfrom
hlu1:gdn

Conversation

@hlu1
Copy link
Copy Markdown
Collaborator

@hlu1 hlu1 commented Feb 4, 2026

Motivation

Apply the same optimization in #17094 to fused_sigmoid_gating_delta_rule_update_kernel which is actually used in the model code.

Accuracy Tests

gpqa with the thinking checkpoint

Repeat: 8, mean: 0.772
Scores: ['0.747', '0.783', '0.747', '0.763', '0.808', '0.753', '0.793', '0.783']

Benchmarking and Profiling

TP4, 1k/1k, bs = 512, on 4xB200

The kernel time is reduced from 121 us to 76, and we can see that the grid size is also smaller [1, 16, 4k] to [1, 4, 4k] while the block size is the same. The TPOT is reduced from 35.79 ms to 34.64.

Before:

image

After:

image

Before:
image

After:
image

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.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @hlu1, 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 focuses on enhancing the performance of a critical kernel, fused_sigmoid_gating_delta_rule_update_kernel, by applying an optimization strategy previously proven effective. The change involves a targeted adjustment of a kernel parameter to leverage GPU resources more efficiently. The impact of this modification is a measurable improvement in execution speed and overall processing time, contributing to a more performant model.

Highlights

  • Performance Optimization: Applied an optimization to the fused_sigmoid_gating_delta_rule_update_kernel to improve its efficiency, specifically targeting its usage within the Qwen3Next model.
  • Kernel Parameter Adjustment: Increased the BV block size limit within the Triton kernel from 8 to 32, which is a key change enabling the performance gains.
  • Benchmarked Improvements: Demonstrated significant performance improvements, including a reduction in kernel time from 121 us to 76 us and a decrease in Total Processing Output Time (TPOT) from 35.79 ms to 34.64 ms, along with a smaller grid size.

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

Changelog
  • python/sglang/srt/layers/attention/fla/fused_sigmoid_gating_recurrent.py
    • Modified the fused_sigmoid_gating_delta_rule_update function to update the BV block size calculation, changing min(triton.next_power_of_2(V), 8) to min(triton.next_power_of_2(V), 32).
Activity
  • The author hlu1 provided a clear motivation for the optimization, referencing a similar successful PR.
  • Detailed benchmarking results, including visual comparisons of 'Before' and 'After' states, were provided to substantiate the performance improvements.
  • A standard checklist for code quality, testing, and documentation was included in the PR description, though its completion status is not indicated.
  • The pull request outlines a clear review and merge process for maintainers to follow.
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.

@hlu1 hlu1 requested a review from Fridge003 February 4, 2026 23:41
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 performance optimization for the fused_sigmoid_gating_delta_rule_update_kernel by increasing the block size for the V dimension. This is a sound change, and the provided benchmarks confirm its effectiveness in reducing kernel execution time. The change is well-targeted and improves performance. I have no specific comments on the code change itself, as it is a clear improvement. For future consideration, a similar optimization might be applicable to fused_recurrent_gated_delta_rule_update_fwd in python/sglang/srt/layers/attention/fla/fused_recurrent.py, which currently appears to use a smaller block size limit.

@hlu1
Copy link
Copy Markdown
Collaborator Author

hlu1 commented Feb 4, 2026

cc @samuellees

@hlu1
Copy link
Copy Markdown
Collaborator Author

hlu1 commented Feb 4, 2026

/tag-and-rerun-ci

@github-actions github-actions bot added the run-ci label Feb 4, 2026
@hlu1 hlu1 changed the title [Qwen3Next] Optimize def fused_sigmoid_gating_delta_rule_update_kernel [Qwen3Next] Optimize fused_sigmoid_gating_delta_rule_update_kernel Feb 6, 2026
@Fridge003
Copy link
Copy Markdown
Collaborator

/rerun-stage stage-c-test-4-gpu-h100

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 7, 2026

✅ Triggered stage-c-test-4-gpu-h100 to run independently (skipping dependencies).

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 7, 2026

🔗 View workflow run

@Fridge003
Copy link
Copy Markdown
Collaborator

🔗 View workflow run

Qwen3 next tests passed

@Fridge003 Fridge003 merged commit 4637970 into sgl-project:main Feb 7, 2026
286 of 309 checks passed
@samuellees samuellees mentioned this pull request Feb 11, 2026
12 tasks
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.

3 participants