执行摘要
修复 Qwen3VLMoe encoder_only 模式属性错误
PR body 指出:如果启用 encoder_only 模式,'Qwen3VLMoeForConditionalGeneration' 对象没有 'model' 属性,会抛出 AttributeError。
本次变更是典型的防御性编程修复,变更极小,逻辑清晰,可以快速合入。
无 review 讨论。
PR body 指出:如果启用 encoder_only 模式,'Qwen3VLMoeForConditionalGeneration' 对象没有 'model' 属性,会抛出 AttributeError。
本次变更是典型的防御性编程修复,变更极小,逻辑清晰,可以快速合入。
无 review 讨论。
在 python/sglang/srt/models/qwen3_vl_moe.py 的 load_weights 方法中,第 238 行的条件判断前增加 hasattr(self, 'model') 检查,确保只有在 self.model 存在时才访问其 start_layer 属性。
| 文件 | 模块 | 状态 | 重要度 |
|---|---|---|---|
python/sglang/srt/models/qwen3_vl_moe.py |
模型加载 | modified | 4.65 |
python/sglang/srt/models/qwen3_vl_moe.py
data-contract
加载权重时缺少对 self.model 存在性的检查,导致 encoder_only 模式 AttributeError。
# python/sglang/srt/models/qwen3_vl_moe.py, load_weights 方法中
# 原代码直接访问 self.model.start_layer,当 encoder_only 模式时 self.model 不存在
# 修复:增加 hasattr(self, "model") 检查
if (
"visual" not in name
and layer_id is not None
and hasattr(self, "model") # 新增防御性检查
and hasattr(self.model, "start_layer")
and (
layer_id < self.model.start_layer
or layer_id >= self.model.end_layer
)
):
continue
当前评论区没有形成足够清晰的争议点或结论,后续有更多讨论时会体现在这里。
变更极简单(一行),仅增加防御性检查,无引入新风险的可能。但如果存在其他路径未加类似保护,可能仍有隐患,但本 PR 范围明确。
影响范围限定在 Qwen3VLMoeForConditionalGeneration 模型加载流程,仅修复 encoder_only 模式下的异常情况,对其他模式无影响。
当前没有检测到明确关联的 Issue 链接,后续同步到相关引用后会出现在这里。
参与讨论