[GDN] Support GDN packed decode#20627
Conversation
Summary of ChangesHello, 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 significant optimization to the GDN decode process by refactoring the existing multi-step decode path into a more efficient, fused 'packed decode' operation. The change aims to reduce overhead associated with memory copies and multiple kernel launches, leading to substantial improvements in inference speed and token throughput. The new approach consolidates several operations into a single Triton kernel, streamlining the computation for better performance. 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. Changelog
Activity
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
|
|
/tag-and-rerun-ci |
There was a problem hiding this comment.
Code Review
This pull request introduces a significant optimization for the GDN decode path by implementing a packed decode kernel. The new fused Triton kernel avoids overhead from memory copies and multiple kernel launches, resulting in a notable performance improvement as demonstrated by the benchmarks. The changes are well-structured, with clear feature flagging and a fallback to the old path, ensuring robustness. The code is adapted from the vllm project, and proper attribution is given. I have a couple of minor suggestions to improve code readability and maintainability.
b4659f2 to
f4346f0
Compare
|
/rerun-failed-ci |
1 similar comment
|
/rerun-failed-ci |
Motivation
This PR optimized GDN decode path with packed decode. Here goes the details.
Current decode path
Has 6 steps, with lots of overhead in memory copy and small kernel launch/compute.
Packed decode path
Refactored to 3 steps with single kernel handling qkv, gate/beta compute as well as output write.
Explanation
The reason HV is listed separately is that in GDN's recurrent state (SSM state), the shape is [HV, V, K], and the gating parameters a and b have shape [B, HV] — they all follow the V head count, not the QK head count. Inside the packed decode kernel, both H and HV must be handled simultaneously to split mixed_qkv:
Modifications
Accuracy Tests
GSM8K no drop:
➜ sglang_dev2 git:(support_gdn_packed_decode) ✗ lm_eval --model local-completions --tasks gsm8k --model_args base_url=http://localhost:30000/v1/completions,model=Qwen/Qwen3.5-35B-A3B,num_concurrent=109;
2026-03-15:12:54:49 INFO [_cli.run:376] Selected Tasks: ['gsm8k']
2026-03-15:12:54:49 INFO [evaluator:211] Setting random seed to 0 | Setting numpy seed to 1234 | Setting torch manual seed to 1234 | Setting fewshot manual seed to 1234
2026-03-15:12:54:49 INFO [evaluator:236] Initializing local-completions model, with arguments: {'base_url': 'http://localhost:30000/v1/completions', 'model': 'Qwen/Qwen3.5-35B-A3B', 'num_concurrent': 109}
2026-03-15:12:54:49 INFO [models.openai_completions:42] Remote tokenizer not supported. Using huggingface tokenizer backend.
2026-03-15:12:54:49 INFO [models.api_models:172] Using max length 2048 - 1
2026-03-15:12:54:49 INFO [models.api_models:193] Using tokenizer huggingface
2026-03-15:12:54:53 INFO [tasks:700] Selected tasks:
2026-03-15:12:54:53 INFO [tasks:691] Task: gsm8k (gsm8k/gsm8k.yaml)
2026-03-15:12:54:53 INFO [evaluator:314] gsm8k: Using gen_kwargs: {'until': ['Question:', '', '<|im_end|>'], 'do_sample': False, 'temperature': 0.0}
2026-03-15:12:54:53 INFO [api.task:311] Building contexts for gsm8k on rank 0...
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1319/1319 [00:04<00:00, 299.62it/s]
2026-03-15:12:54:57 INFO [evaluator:584] Running generate_until requests
Requesting API: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1319/1319 [02:15<00:00, 9.71it/s]
2026-03-15:12:57:22 INFO [loggers.evaluation_tracker:316] Output path not provided, skipping saving results aggregated
local-completions ({'base_url': 'http://localhost:30000/v1/completions', 'model': 'Qwen/Qwen3.5-35B-A3B', 'num_concurrent': 109}), gen_kwargs: ({}), limit: None, num_fewshot: None, batch_size: 1
Benchmarking and Profiling
Checklist
Review Process
/tag-run-ci-label,/rerun-failed-ci,/tag-and-rerun-ci