[Feature] Add Qwen3.5 Model Support for DFlash#19952
[Feature] Add Qwen3.5 Model Support for DFlash#19952EanWang211123 wants to merge 58 commits intosgl-project:mainfrom
Conversation
…ock-size to server args
Signed-off-by: EanWang211123 <wangyiheng@sangfor.com.cn>
Signed-off-by: EanWang211123 <wangyiheng@sangfor.com.cn>
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 integrates DFLASH speculative decoding into the SGLang framework, primarily targeting Qwen3.5 models to enhance inference performance. It introduces a dedicated DFLASH draft model, optimizes KV cache operations with a fused Triton kernel, and updates the core speculative decoding logic to manage DFLASH-specific requirements and ensure compatibility with existing features. The changes aim to provide substantial speedups for model generation. 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
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 introduces DFlash speculative decoding support for Qwen3.5 models, which is a significant feature enhancement. The implementation is comprehensive, adding new core components for DFlash (dflash_worker.py, dflash.py, etc.), a new benchmark script, and integrating DFlash support across various parts of the system including the scheduler, model runner, and attention backends. The code quality is high, with robust configuration handling and optimizations like fused Triton kernels. My review includes one suggestion for a minor refactoring to improve code maintainability.
| if self.spec_algorithm.is_dflash() and req.return_logprob: | ||
| req.set_finish_with_abort( | ||
| "DFLASH speculative decoding does not support return_logprob yet." | ||
| ) | ||
| self.init_req_max_new_tokens(req) | ||
| self._add_request_to_queue(req) | ||
| return | ||
| if self.spec_algorithm.is_dflash() and ( | ||
| req.sampling_params.json_schema is not None | ||
| or req.sampling_params.regex is not None | ||
| or req.sampling_params.ebnf is not None | ||
| or req.sampling_params.structural_tag is not None | ||
| ): | ||
| req.set_finish_with_abort( | ||
| "DFLASH speculative decoding does not support grammar-constrained decoding yet." | ||
| ) | ||
| self.init_req_max_new_tokens(req) | ||
| self._add_request_to_queue(req) | ||
| return |
There was a problem hiding this comment.
The two if blocks for checking DFLASH unsupported features are repetitive. They can be combined to reduce code duplication and improve readability.
| if self.spec_algorithm.is_dflash() and req.return_logprob: | |
| req.set_finish_with_abort( | |
| "DFLASH speculative decoding does not support return_logprob yet." | |
| ) | |
| self.init_req_max_new_tokens(req) | |
| self._add_request_to_queue(req) | |
| return | |
| if self.spec_algorithm.is_dflash() and ( | |
| req.sampling_params.json_schema is not None | |
| or req.sampling_params.regex is not None | |
| or req.sampling_params.ebnf is not None | |
| or req.sampling_params.structural_tag is not None | |
| ): | |
| req.set_finish_with_abort( | |
| "DFLASH speculative decoding does not support grammar-constrained decoding yet." | |
| ) | |
| self.init_req_max_new_tokens(req) | |
| self._add_request_to_queue(req) | |
| return | |
| if self.spec_algorithm.is_dflash(): | |
| unsupported_reason = None | |
| if req.return_logprob: | |
| unsupported_reason = "return_logprob" | |
| elif ( | |
| req.sampling_params.json_schema is not None | |
| or req.sampling_params.regex is not None | |
| or req.sampling_params.ebnf is not None | |
| or req.sampling_params.structural_tag is not None | |
| ): | |
| unsupported_reason = "grammar-constrained decoding" | |
| if unsupported_reason: | |
| req.set_finish_with_abort( | |
| f"DFLASH speculative decoding does not support {unsupported_reason} yet." | |
| ) | |
| self.init_req_max_new_tokens(req) | |
| self._add_request_to_queue(req) | |
| return |
|
hi @EanWang211123 yiheng, impressive results. I tried to reproduce the accept len results, but failed with eaglechat & specforge. Does your accept len include the 1 token produced at the end of target extend? |
@liyucheng09 I think so. I only tried training with a small amount of data for verification. |
|
@EanWang211123 how's the |
@liyucheng09 My training dataset was created by sampling the EagleChat subset (English 4k + Chinese 4k), and the model was trained using SGLang as the training backend. |
|
Update on 4.7: Update on 4.8: Reply at first time: use TP=2 to ensure enough kvcache space:
For qwen3.5 35b a3b: |




Motivation
Add DFlash speculative decoding support for Qwen3.5 models, following the implementation approach in #16818
Modifications
Similar to #18387:
dflash_worker.py, save the global server_args before creating the draft worker and restore it afterwardset_dflash_layers_to_captureinterface for better layer managementTests
Successfully trained and tested with Qwen3.5-27B model using DFlash in SpecForge:
Test Environment:
Test Command:
Performance Results
Baseline Output (tok/s)
DFLASH Output (tok/s)
Speedup (DFLASH / Baseline)
DFLASH Acceptance Length
Summary
The implementation shows significant performance improvements with DFlash enabled, achieving up to 2x speedup for single concurrent requests and maintaining good acceleration across different concurrency levels.
Checklist
Review Process
/tag-run-ci-label,/rerun-failed-ci,/tag-and-rerun-ci