Prhub

#23434 [Model] Qwen3ForPooledOutput: forward get_input_embeddings to inner model

原始 PR 作者 fortunecookiee 合并时间 2026-04-30 03:25 文件变更 1 提交数 3 评论 2 代码增减 +3 / -0

执行摘要

修复 Qwen3PooledOutput 缺少 get_input_embeddings

修复 score API 中 embedding 覆盖注入路径的 AttributeError:当调度器解析覆盖占位符 token 为实际 embedding 张量时,调用 model.get_input_embeddings()(input_ids),该调用在 Qwen3ForCausalLM 路径正常,但对 Qwen3ForSequenceClassification 等 pooled-output 变体失败。

推荐合并,这是一个简单的修复,应尽快合入以解除 score API 对 Qwen3 分类模型的阻塞。

讨论亮点

无 review 评论,审核者 Qiaolin-Yu 直接批准。

实现拆解

  1. 在基类 Qwen3ForPooledOutput 中新增 get_input_embeddings 方法(文件:python/sglang/srt/models/qwen3_classification.py,第 58-59 行),直接转发到 self.model.get_input_embeddings()
  2. 利用继承自动覆盖Qwen3ForSequenceClassification 和 reward 模型变体无需额外修改,自动继承基类的新方法。
  3. 无测试配套变更:本 PR 仅 3 行新增,且无新增测试文件,但 PR body 的 checklist 中勾选了“添加单元测试”,可能为疏忽或已在其他 PR 中覆盖。
文件 模块 状态 重要度
python/sglang/srt/models/qwen3_classification.py 模型 modified 5.03

关键符号

get_input_embeddings

分析完成后,这里会展示 LLM 生成的相对完整源码片段和详细注释。

评论区精华

没有提炼出高价值讨论线程

当前评论区没有形成足够清晰的争议点或结论,后续有更多讨论时会体现在这里。

风险与影响

风险极低:仅新增一个转发方法,不修改任何现有逻辑,不会引入回归。但缺少直接单元测试覆盖该转发路径。

影响范围:仅影响 Qwen3 的 pooled-output 变体(seq-cls 和 reward)。用户影响:修复了使用 score API 加载 Qwen3-Reranker-seq-cls 等模型时的 AttributeError。系统影响:无性能或兼容性影响。

缺少测试覆盖

关联 Issue

未识别关联 Issue

当前没有检测到明确关联的 Issue 链接,后续同步到相关引用后会出现在这里。

完整报告

参与讨论