Skip to content

Conversation

@byjiang1996
Copy link
Contributor

@byjiang1996 byjiang1996 commented Nov 2, 2025

Motivation

Target Extend: 89us -> 79us: 10us saving
image
->
image

Verify: 3.5us -> 1.4us: 2.1us saving
image
->
image

Accuracy Tests

python3 benchmark/gsm8k/bench_sglang.py 

Accuracy: 0.950

Benchmarking and Profiling

H100 x 4

import sys
from sglang.srt.entrypoints.http_server import launch_server
from sglang.srt.server_args import prepare_server_args
if __name__ == "__main__":
    # Simulate CLI arguments (excluding the script name)
    args = [
        "--model-path",
        "Qwen-SGlang/Qwen3-Next-80B-A3B-Instruct",
        "--tp",
        "4",
        "--speculative-algo",
        "NEXTN",
        "--speculative-num-steps",
        "3",
        "--speculative-eagle-topk",
        "1",
        "--speculative-num-draft-tokens",
        "4",
    ]
    server_args = prepare_server_args(args)
    launch_server(server_args)
python3 -m sglang.test.send_one

from 317 tok/s to 319.7 tok/s

Checklist

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @byjiang1996, 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 the Gated Delta Net (GDN) by consolidating multiple sequential operations into a single, more efficient GPU kernel. By fusing the sigmoid activation, gating mechanism, and unsqueeze operations, the change aims to minimize overhead and improve execution speed. This optimization directly contributes to faster inference times and a higher token generation rate for models utilizing this architecture.

Highlights

  • Kernel Fusion: The pull request fuses the b.sigmoid(), fused_gdn_gating, and unsqueeze operations into a single optimized kernel, reducing computational overhead.
  • End-to-End Speedup: This optimization results in an end-to-end speedup of up to 0.9% for the overall system.
  • Specific Performance Gains: Individual operations show significant improvements: 'Target Extend' latency decreased from 89us to 79us (10us saving), and 'Verify' latency dropped from 3.5us to 1.4us (2.1us saving).
  • Token Generation Rate: The token generation rate increased from 317 tok/s to 319.7 tok/s, indicating improved throughput.
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
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 fuses b.sigmoid(), fused_gdn_gating, and unsqueeze operations into a single Triton kernel to improve performance. The changes look good and align with the goal. I've found a potential issue in the fused_gdn_gating function where the beta_output tensor is created with a hardcoded torch.float32 dtype, which might not match the dtype of the input tensor b. This could lead to incorrect results. I've suggested a fix to use b.dtype instead.

@byjiang1996 byjiang1996 changed the title [GDN] Fuse b.sigmoid(), fused_gdn_gating and unsqueeze into one kernel: up to 0.9% e2e speedup [GDN] Fuse b.sigmoid(), fused_gdn_gating and unsqueeze into one kernel: up to 0.85% e2e speedup Nov 2, 2025
@b8zhong b8zhong added the run-ci label Nov 2, 2025
@hebiao064
Copy link
Collaborator

@Fridge003 small pr, ready to merge

@zhyncs zhyncs merged commit fbbe16f into sgl-project:main Nov 6, 2025
65 of 73 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