Prhub

#6540 [veomni] fix: VeOmniEngineWithValueHead token-cls lookup default value for transformers v5

原始 PR 作者 Luosuu 合并时间 2026-06-01 10:29 文件变更 1 提交数 1 评论 0 代码增减 +1 / -1

执行摘要

修复 VeOmni value model 初始化崩溃

transformers 5.x 中 _LazyAutoMapping.get(key, default)default 变为强制位置参数,与旧版 dict.get(key) 行为不同,导致 value model critic 初始化时抛出 TypeError: _LazyAutoMapping.get() missing 1 required positional argument

可快速合入。该 PR 属于常规适配修复,无需深入精读。

讨论亮点

无 review 讨论。自动化机器人 gemini-code-assist[bot] 仅确认变更无问题,wuxibin89 直接批准。

实现拆解

verl/workers/engine/veomni/transformer_impl.pyVeOmniEngineWithValueHead._get_model_config_path 方法中,将 AutoModelForTokenClassification._model_mapping.get(type(config)) 改为 AutoModelForTokenClassification._model_mapping.get(type(config), None),显式提供默认值 None。该行后的 if token_cls is None 守卫逻辑保持不变,因此行为等价。

文件 模块 状态 重要度
verl/workers/engine/veomni/transformer_impl.py 引擎 modified 4.7

关键符号

VeOmniEngineWithValueHead._get_model_config_path

关键源码片段

verl/workers/engine/veomni/transformer_impl.py core-logic

修复 transformers 5.x 中 _LazyAutoMapping.get 缺少默认参数导致的崩溃

# verl/workers/engine/veomni/transformer_impl.py
# 修复:transformers 5.x 中 _LazyAutoMapping.get(key, default) 将 default 变为强制参数
# 显式传入 None 以兼容新版 transformers,后续 None 检查保持不变
config.tie_word_embeddings = False
token_cls = AutoModelForTokenClassification._model_mapping.get(type(config), None)
if token_cls is None:
    raise ValueError(f"No ForTokenClassification class in transformers for {type(config).__name__}.")
config.architectures = [token_cls.__name__]
return config

评论区精华

缺少默认参数的兼容性修复 正确性

自动化机器人 gemini-code-assist[bot] 指出变更显式提供 None 默认值,无其他评论。

结论:PR 获得批准,无需讨论。 · 已解决

风险与影响

风险极低。仅 1 行改动,显式指定 None 作为默认值,与后续 None 检查完全兼容。不影响旧版 transformers 行为。

影响范围仅限于 VeOmni 后端的 value model (critic) 初始化流程,修复 transformers 5.x 兼容性。对训练稳定性无其他影响。

兼容性修复

关联 Issue

未识别关联 Issue

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

完整报告

参与讨论