Prhub

#42700 [Bugfix] Replace deprecated Qwen2VLImageProcessorFast with Qwen2VLImageProcessor

原始 PR 作者 abinggo 合并时间 2026-06-13 12:04 文件变更 1 提交数 2 评论 1 代码增减 +3 / -3

执行摘要

修复 Qwen3VL 导入弃用类警告

关闭 Issue #42688:用户报告每次加载 qwen3_vl.py 都会触发 Qwen2VLImageProcessorFast 弃用警告,且 transformers 未来版本可能彻底移除该别名,届时将引发 ImportError。PR body 明确说明:“This is not a cosmetic cleanup: the deprecated re-export is on track to be removed in a follow-up transformers release, at which point this becomes an ImportError rather than a warning.”

可直接合并。该 PR 属于常规维护,改动微小但必要,值得快速合入以避免后续 transformers 升级时出现问题。

讨论亮点

维护者 DarkLight1337 批准了 PR,并评论:“Yeah this should be fine since we dropped transformers v4”,表明 vllm 已放弃对 transformers v4 的支持,因此采用新类名是安全且及时的。Issue 评论中 wangxiyuan 也催促合并,因为团队也遇到了该警告。

实现拆解

  1. 修改导入语句:将 from transformers.models.qwen2_vl import Qwen2VLImageProcessorFast 替换为 from transformers.models.qwen2_vl import Qwen2VLImageProcessor
  2. 更新类型注解:在 Qwen3VLProcessingInfo 类的 get_image_processor 方法中,返回值类型从 Qwen2VLImageProcessorFast 改为 Qwen2VLImageProcessor
  3. 更新参数类型注解:在 _get_vision_info 方法的 image_processor 参数类型联合中,将 Qwen2VLImageProcessorFast 替换为 Qwen2VLImageProcessor
文件 模块 状态 重要度
vllm/model_executor/models/qwen3_vl.py 模型执行器 modified 6.53

关键符号

get_image_processor _get_vision_info

关键源码片段

vllm/model_executor/models/qwen3_vl.py data-contract

唯一修改文件。替换了已弃用的 `Qwen2VLImageProcessorFast` 导入和所有类型注解,共 3 处替换(+3/-3)。

# 第 37 行:导入语句变更
# 旧:from transformers.models.qwen2_vl import Qwen2VLImageProcessorFast
# 新:使用不带 Fast 后缀的标准类名,消除 deprecation 警告
from transformers.models.qwen2_vl import Qwen2VLImageProcessor# 第 874 行:get_image_processor 返回值类型注解变更
class Qwen3VLProcessingInfo(Qwen2VLProcessingInfo):
    def get_image_processor(self, **kwargs: object) -> Qwen2VLImageProcessor: # 原返回类型为 Qwen2VLImageProcessorFast
        return self.get_hf_processor(**kwargs).image_processor
​
    # 第 894 行:_get_vision_info 参数类型注解变更
    def _get_vision_info(
        self,
        *,
        image_width: int,
        image_height: int,
        num_frames: int = 2,
        do_resize: bool = True,
        # 原类型为 Qwen2VLImageProcessorFast | Qwen3VLVideoProcessor
        image_processor: Qwen2VLImageProcessor | Qwen3VLVideoProcessor,
        mm_kwargs: Mapping[str, object],
    ) -> tuple[ImageSize, int]:
        is_video = isinstance(image_processor, Qwen3VLVideoProcessor)
        # ... 其余逻辑不变

评论区精华

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

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

风险与影响

风险极低。Qwen2VLImageProcessor 是原 Fast 类的直接纯重导出(pure re-export),行为完全一致。但需确认 vllm 支持的最低 transformers 版本是否包含 Qwen2VLImageProcessor 符号。从 DarkLight1337 的评论“we dropped transformers v4”推断,当前依赖已跳过旧版本,因此无需担心兼容性。

  • 用户:消除 deprecation 警告,提升用户体验。
  • 系统:无运行时行为变更,仅影响导入时的日志输出。
  • 团队:低维护成本,为未来 transformers 升级扫清障碍。

关联 Issue

#42688 [Bug]: forced to hit `Fast` suffix deprecation from `qwen3_vl` import
#43514 [Bugfix] Reject non-positive block_size in CacheConfig

完整报告

参与讨论