执行摘要
支持 Intern-S2-Preview 多模态模型
根据 PR 描述,支持 HuggingFace 上的 internlm/Intern-S2-Preview 多模态 MoE 模型,使得 SGLang 能够以分布式方式推理该模型。
该 PR 是 SGLang 添加新模型的典型范例,结构清晰(继承+注册),推荐开发者阅读以了解模型集成流程。可重点关注配置文件、路由注册和多模态处理器的修改模式。
无实质性讨论,PR 获得维护者 ispobock 的批准,未产生 review 评论。
根据 PR 描述,支持 HuggingFace 上的 internlm/Intern-S2-Preview 多模态 MoE 模型,使得 SGLang 能够以分布式方式推理该模型。
该 PR 是 SGLang 添加新模型的典型范例,结构清晰(继承+注册),推荐开发者阅读以了解模型集成流程。可重点关注配置文件、路由注册和多模态处理器的修改模式。
无实质性讨论,PR 获得维护者 ispobock 的批准,未产生 review 评论。
| 文件 | 模块 | 状态 | 重要度 |
|---|---|---|---|
python/sglang/srt/configs/interns2preview.py |
配置层 | added | 7.85 |
python/sglang/srt/models/interns2preview.py |
模型定义 | added | 7.01 |
python/sglang/srt/multimodal/processors/qwen_vl.py |
多模态处理 | modified | 5.8 |
python/sglang/srt/disaggregation/encode_server.py |
解聚编码器 | modified | 5.1 |
python/sglang/srt/configs/model_config.py |
模型注册 | modified | 5.33 |
python/sglang/srt/configs/interns2preview.py
core-logic
定义模型配置类,继承 Qwen3.5 MoE 配置,指定 model_type 和子配置映射,是架构核心。
# 继承自 Qwen3.5 MoE 配置
from sglang.srt.configs.qwen3_5 import (
Qwen3_5MoeConfig,
Qwen3_5MoeTextConfig,
Qwen3_5MoeVisionConfig,
)
# 视觉配置,直接复用父类逻辑
class InternS2PreviewVisionConfig(Qwen3_5MoeVisionConfig):
model_type = "intern_s2_preview"
def __init__(self, **kwargs):
super().__init__(**kwargs)
# 整体模型配置,指定子配置的映射关系
class InternS2PreviewConfig(Qwen3_5MoeConfig):
model_type = "intern_s2_preview"
sub_configs = {
"vision_config": InternS2PreviewVisionConfig,
"text_config": Qwen3_5MoeTextConfig,
}
def __init__(self, **kwargs):
super().__init__(**kwargs)
python/sglang/srt/multimodal/processors/qwen_vl.py
dependency-wiring
多模态处理器注册新模型,使其能复用 QwenVL 的图像 / 视频处理流程,并扩展视频时间戳分支。
# 导入新模型
from sglang.srt.models.interns2preview import InternS2PreviewForConditionalGeneration
# 在 QwenVLImageProcessor 的 models 注册列表中增加
class QwenVLImageProcessor(SGLangBaseProcessor):
supports_transformers_backend = True
models = [
Qwen2VLForConditionalGeneration,
Qwen2_5_VLForConditionalGeneration,
Qwen3VLForConditionalGeneration,
Qwen3VLMoeForConditionalGeneration,
Qwen3_5ForConditionalGeneration,
Qwen3_5MoeForConditionalGeneration,
InternS2PreviewForConditionalGeneration, # 新增 Intern-S2-Preview
Qwen3OmniMoeForConditionalGeneration,
]
# 在 get_mm_data 中添加 model_type 分支
if (self.model_type in [
"qwen3_vl",
"qwen3_vl_moe",
"qwen3_5",
"qwen3_5_moe",
"intern_s2_preview", # 新增模型类型
] and video_timestamps is not None):
input_ids, offsets, modality_list = self.build_input_ids_with_timestamps(...)
python/sglang/srt/configs/model_config.py
data-contract
将 InternS2PreviewForConditionalGeneration 注册为生成模型和草稿模型候选,是模型发现和调度路由的关键。
# 在 is_generation_model 中注册为生成模型
"Qwen3VLMoeForConditionalGeneration",
"Qwen3_5ForConditionalGeneration",
"Qwen3_5MoeForConditionalGeneration",
"InternS2PreviewForConditionalGeneration", # 新增
# 在 _config_draft_model 中添加草稿模型支持
if is_draft_model and self.hf_config.architectures[0] in [
"Qwen3_5ForConditionalGeneration",
"Qwen3_5MoeForConditionalGeneration",
"InternS2PreviewForConditionalGeneration", # 新增,允许作为草稿模型
]:
self.hf_config.architectures[0] = "Qwen3_5ForCausalLMMTP"
self.hf_config.num_nextn_predict_layers = 1
当前评论区没有形成足够清晰的争议点或结论,后续有更多讨论时会体现在这里。
主要风险包括:未添加单元测试验证模型精度和功能;新模型依赖 Qwen3.5 MoE 的稳定性,若基类存在 bug 会直接影响 Intern-S2-Preview;多处路由修改可能遗漏某些场景(如 TD 解聚、多模态处理流程);模型需要 trust_remote_code 且可能需要特定的 CUDA 版本和 attention backend。由于继承了成熟架构,风险较低,但仍建议补充测试。
对用户:新增 Intern-S2-Preview 模型可用,启动命令已给出。对系统:对现有模型无影响,代码改动集中在新增文件,修改均添加条件分支或列表元素。对团队:后续需补充该模型的 CI 测试和精度基准,以保障质量。
当前没有检测到明确关联的 Issue 链接,后续同步到相关引用后会出现在这里。
参与讨论