Prhub

#41661 [Benchmark] Add --trust-remote-code flag to multi-turn benchmark

原始 PR 作者 Dao007forever 合并时间 2026-05-05 16:00 文件变更 1 提交数 2 评论 0 代码增减 +9 / -1

执行摘要

新增多轮基准测试的 --trust-remote-code 标志

多轮基准测试脚本无法加载 HuggingFace Hub 上带有自定义 tokenizer 代码的模型(如 Qwen、DeepSeek 等),因为 AutoTokenizer.from_pretrained 默认 trust_remote_code=False。添加该标志可与 vLLM 其他工具的行为保持一致。

此 PR 改动简单直接,可作为基础设施类变更的示例。如需了解 vLLM 基准测试工具链,可精读该文件了解更多标志。

讨论亮点

无实质性代码讨论;仅有自动 bot 评论和三位维护者的 Approval,其中 ivanium、youkaichao、ywang96 均批准。

实现拆解

  1. benchmarks/multi_turn/benchmark_serving_multi_turn.py 的命令行参数解析器中新增 --trust-remote-code 标志(store_true 类型)。
  2. 修改 AutoTokenizer.from_pretrained 调用,传入 trust_remote_code=args.trust_remote_code
  3. 无其他文件变更,改动简洁。
文件 模块 状态 重要度
benchmarks/multi_turn/benchmark_serving_multi_turn.py 基准测试 modified 4.94

关键源码片段

benchmarks/multi_turn/benchmark_serving_multi_turn.py core-logic

唯一变更文件,新增 `--trust-remote-code` 参数并传递给 tokenizer 加载。

# 在参数解析器中新增 --trust-remote-code 标志
parser.add_argument(
    "--trust-remote-code",
    action="store_true",
    help="Trust remote code when loading the tokenizer.",
)# 在加载 tokenizer 时传递该参数
tokenizer = AutoTokenizer.from_pretrained(
    args.model, trust_remote_code=args.trust_remote_code
)

评论区精华

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

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

风险与影响

风险极低。新增参数默认 False,完全向后兼容。trust_remote_code 是 HuggingFace 标准参数,传递后仅在用户显式指定时启用远程代码执行。

影响范围仅限于 multi-turn 基准测试脚本的用户。受益者:需要使用自定义 tokenizer 模型的用户可正常运行基准测试。无性能、安全或兼容性影响。

低风险

关联 Issue

未识别关联 Issue

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

完整报告

参与讨论