Optimize GDN decode for Qwen3 Next#17094
Conversation
Summary of ChangesHello @samuellees, 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 critical optimization to the Gated Delta Rule (GDN) decoding kernel, specifically targeting the Qwen3 Next model. By adjusting a key parameter in the fused recurrent attention mechanism, the PR significantly improves overall inference performance, leading to higher output throughput and reduced latency, addressing a previously identified bottleneck. Highlights
🧠 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 AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request optimizes the Gated Delta Rule (GDR) kernel by increasing the block size BV from 8 to 32 in fused_recurrent_gated_delta_rule_fwd. This is a good performance tuning that, as the benchmarks show, significantly improves throughput.
However, this optimization seems to be applied inconsistently across the codebase. I've found a few other places where BV is still capped at 8. Given the PR's goal is to optimize decoding, these should probably be updated as well to ensure consistent performance improvements across all relevant kernels.
Specifically, please consider applying the same change to:
python/sglang/srt/layers/attention/fla/fused_recurrent.pyat line 543 infused_recurrent_gated_delta_rule_update_fwd.python/sglang/srt/layers/attention/fla/fused_sigmoid_gating_recurrent.pyat line 184 infused_sigmoid_gating_delta_rule_update.python/sglang/srt/layers/attention/fla/kda.pyat line 56 infused_recurrent_kda_fwd.
Applying this optimization consistently would likely yield further performance benefits, especially in decoding scenarios which seems to be the main goal of this PR.
|
/rerun-stage unit-test-backend-4-gpu |
|
✅ Triggered |
|
/rerun-stage unit-test-backend-4-gpu |
|
✅ Triggered |
|
/tag-and-rerun-ci |
|
/rerun-stage unit-test-backend-4-gpu |
|
✅ Triggered |
Motivation
As MoE/FullAttn/GEMM has been optimized, the GDN kernel becomes a bottleneck for Q3N. For example, decode linear attention takes about 15~23% with cc=64/256 with ISL=1k in NVFP4 inference on B200.
This PR apply an optimize on GDN decode kernel, which brings significant benefits e2e.
Ref: vllm-project/vllm#31722
cc @yizhang2077
Modifications
Accuracy Tests and Benchmarking
TEP4, MTP OFF, B200
It gives about 10% e2e improvements on gsm8k dataset.
Benchmarking and Profiling
Checklist
Review Process
/tag-run-ci-label,/rerun-failed-ci,/tag-and-rerun-ci