[MODEL] Adding Support for Qwen3.5 Models#18489
Conversation
use rope_parameters rather than rope_scaling
1. multimodal inputs for mtp 2. dense model tie embedding for mtp
1. rename Qwen3_vl_next to Qwen3_5 in config 2. merge qwen3_5.py and qwen3_5_moe.py
2. rename Qwen3_5LLMModel to Qwen3_5ForCausalLM
use rope_parameters rather than rope_scaling
1. multimodal inputs for mtp 2. dense model tie embedding for mtp
1. rename Qwen3_vl_next to Qwen3_5 in config 2. merge qwen3_5.py and qwen3_5_moe.py
2. rename Qwen3_5LLMModel to Qwen3_5ForCausalLM
Summary of ChangesHello @zju-stu-lizheng, 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 support for the Qwen3.5 series of models, encompassing both dense and MoE variants. It includes a new attention layer, configuration updates, and code modifications to ensure seamless integration and optimized performance within the existing framework. The changes enhance the system's ability to handle advanced language models and improve overall processing efficiency. 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
|
There was a problem hiding this comment.
Code Review
This pull request adds support for the new Qwen3.5 models, including both dense and MoE variants. The changes are extensive, introducing new model and configuration files, and updating various parts of the system to accommodate these new models. The implementation appears to be well-integrated with the existing codebase. My review focuses on a few opportunities for code simplification and correctness improvements.
| if hasattr(config, "rope_parameters"): | ||
| self.rope_scaling = getattr(config, "rope_parameters", None) | ||
| else: | ||
| self.rope_scaling = getattr(config, "rope_scaling", None) |
| forward_batch=forward_batch, | ||
| ) | ||
| else: | ||
| raise ("not implementation for other mtp layers[self.num_mtp_layers > 1]") |
There was a problem hiding this comment.
Raising a string literal does not raise a proper exception. It's better to raise a specific exception type like NotImplementedError for unimplemented features.
| raise ("not implementation for other mtp layers[self.num_mtp_layers > 1]") | |
| raise NotImplementedError("not implementation for other mtp layers[self.num_mtp_layers > 1]") |
| if "rope_parameters" in config: | ||
| self.rope_scaling = getattr(config, "rope_parameters", None) | ||
| else: | ||
| self.rope_scaling = getattr(config, "rope_scaling", None) |
There was a problem hiding this comment.
This logic for setting self.rope_scaling can be simplified. Using getattr with a default value is more concise. Also, using hasattr is generally preferred over the in operator for checking attributes on an object.
self.rope_scaling = getattr(config, "rope_parameters", getattr(config, "rope_scaling", None))|
/tag-and-rerun-ci |
|
/rerun-failed-ci |
2 similar comments
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
8 similar comments
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
Co-authored-by: 瑀澈 <yuche.lz@alibaba-inc.com>
|
Emm, may I ask why qwen3.5's moe sparse block reuse qwen2's not qwen3's? @zju-stu-lizheng |
for shared_expert |
|
Which tool call paser should be used for qwen3.5 series model? |
Seems qwen3_coder from https://www.modelscope.cn/models/Qwen/Qwen3.5-35B-A3B |
|
And why is expert parallelism not suggested for this model? |
Co-authored-by: 瑀澈 <yuche.lz@alibaba-inc.com>
Purpose
This PR adds model support for the upcoming Qwen3.5 models, including both dense and MoE variants.
Special thanks to @cao1zhg, @yizhang2077, and @attack204 for their review, and to @hnyls2002 and @mickqian from the SGLang team for their valuable review and support.
Reference HF implementation - huggingface/transformers#43830
Main Changes
Model Support: Added support for two new model classes:
Qwen3_5MoeForConditionalGenerationQwen3_5ForConditionalGenerationAttention Layer: Introduced a new linear attention layer
Qwen3_5GatedDeltaNetto optimize thefix_qkvzreordering operation.Launch Server
Hardware setup: 8 × H200 GPUs
Without MTP
With MTP
Add the following arguments to the above command:
Check our cookbook for detailed deployment instruction: https://cookbook.sglang.io/autoregressive/Qwen/Qwen3.5