Prhub

#43358 [Deprecation] Deprecate functions as scheduled for v0.21.0

原始 PR 作者 yewentao256 合并时间 2026-05-27 10:56 文件变更 4 提交数 5 评论 5 代码增减 +21 / -131

执行摘要

移除已废弃的 cprofile 模块和 logit_bias/scale 配置

在 v0.21.0 版本中,按计划移除早前标记废弃的 profiling 辅助函数和 logit_bias/logit_scale 配置参数,以保持代码整洁并推动用户迁移到标准方案。

该 PR 是规范的废弃清理实践,适合作为参考案例:所有废弃项在发布前已提前标记,并附有迁移指南,最终按计划移除。团队成员可关注其文档更新的一致性检查,并注意 PR 作者在 review 过程中及时修复了 reviewer 指出的残留 deprecation note,体现了良好的协作。

讨论亮点

Review 过程中 gemini-code-assist[bot] 指出文档 docs/contributing/profiling.md 中还残留一条说明 vllm.utils.profiling 已废弃将在 v0.21 移除的 note,但该模块已被删除,因此该 note 过时且令人困惑。作者 yewentao256 确认并修复了该问题。

实现拆解

  1. 删除废弃的 profiling 模块:移除 vllm/utils/profiling.py 文件,包括 cprofile_context 上下文管理器、cprofile 装饰器及其内部 helper。
  2. 简化 PoolerConfig:在 vllm/config/pooler.pyPoolerConfig 中删除了 logit_biaslogit_scale 字段声明,并移除 __post_init__ 中处理这些字段的兼容逻辑。
  3. 更新 profiling 文档:在 docs/contributing/profiling.md 中将示例从 vllm.utils.profiling 替换为标准 cProfile 调用,并删除过时的 deprecation 说明。
  4. 更新配置文件文档:在 docs/models/pooling_models/classify.md 中移除关于 logit_bias/scale 的迁移说明。
  5. 无测试变更:本次仅清理已废弃代码,未引入新功能,因此未涉及测试修改。
文件 模块 状态 重要度
vllm/utils/profiling.py 工具函数 removed 8.65
vllm/config/pooler.py 配置层 modified 6.82
docs/contributing/profiling.md 贡献指南 modified 3.89
docs/models/pooling_models/classify.md 模型文档 modified 2.18

关键符号

cprofile_context cprofile

关键源码片段

vllm/config/pooler.py core-logic

配置文件:移除已废弃的 logit_bias 和 logit_scale 字段及兼容逻辑。

def __post_init__(self) -> None:
    # @deprecated logit_bias/logit_scale 兼容逻辑已移除(v0.21)
    # 用户需直接使用 logit_mean / logit_sigma(后者等于 1/logit_scale)
    if self.logit_sigma is not None and self.logit_sigma == 0:
        raise ValueError("logit_sigma cannot be 0 (division by zero)")
​
    if pooling_type := self.pooling_type:
        if self.seq_pooling_type is not None:
            raise ValueError(
                "Cannot set both `pooling_type` and `seq_pooling_type`"
            )
        if self.tok_pooling_type is not None:
            raise ValueError(
                "Cannot set both `pooling_type` and `tok_pooling_type`"
            )
​
        if pooling_type in SEQ_POOLING_TYPES:
            logger.debug(
                "Resolved `pooling_type=%r` to `seq_pooling_type=%r`.",
                pooling_type,
                pooling_type,
            )
            self.seq_pooling_type = pooling_type # type: ignore[assignment]
        elif pooling_type in TOK_POOLING_TYPES:
            logger.debug(
                "Resolved `pooling_type=%r` to `tok_pooling_type=%r`.",
                pooling_type,
                pooling_type,
            )
            self.tok_pooling_type = pooling_type # type: ignore[assignment]
        else:
            raise NotImplementedError(pooling_type)

评论区精华

文档中残留过时的 deprecation note documentation

gemini-code-assist[bot] 指出 docs/contributing/profiling.md 中仍有说明 vllm.utils.profiling 将在 v0.21 移除,但模块已删除,此 note 过时。

结论:作者确认并修复。 · 已解决

风险与影响

风险较低,但需确认:

  • vllm.utils.profiling 是否仍在其他模块中被导入?(从删除清单看仅有 profiling.md 引用,已更新)
  • logit_bias/logit_scale 是否被用户代码或其他配置文件用到?该兼容逻辑移除后,若用户仍使用旧字段名会直接报错而非警告
  • 文档更新的完整性:需确保所有提及旧 API 的地方均被清理

影响范围小:

  • 用户:若使用了 vllm.utils.profilingcprofilecprofile_context,需迁移至 Python cProfile;若使用了 PoolerConfig(logit_bias=...) 等,需改为 logit_mean/logit_sigma
  • 系统:无性能影响,代码减少 131 行
  • 团队:维护负担减轻,代码库更整洁
废弃移除可能遗留引用 用户配置兼容性

关联 Issue

未识别关联 Issue

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

完整报告

参与讨论