Prhub

#25143 bench: fix wrong flag names in bench_one_batch{,_server} docstrings

原始 PR 作者 ch-wan 合并时间 2026-05-13 14:46 文件变更 2 提交数 1 评论 1 代码增减 +5 / -5

执行摘要

修复 bench 脚本 docstring 中错误的 flag 名称

PR body 指出, bench_one_batch.pybench_one_batch_server.py 的 docstring 中使用的 flag 名称与 argparse 实际定义的参数名不符(例如 --batch 应为 --batch-size),直接复制粘贴这些示例会导致错误: bench_one_batch.py: error: unrecognized arguments: --batch

这是一个琐碎但有用的文档修正,建议合并以提升开发者体验。无需深入审查。

讨论亮点

没有 review 讨论。

实现拆解

  1. bench_one_batch.py 的 docstring 中,将所有 4 处 --batch 替换为 --batch-size
  2. bench_one_batch_server.py 的 docstring 中,将 --output-path results.json 替换为 --result-filename results.jsonl(实际参数名并修正扩展名为 .jsonl)。
  3. 无其他代码变更,argparse 本身已支持正确的 flag 名称。
文件 模块 状态 重要度
python/sglang/bench_one_batch.py bench 工具 modified 4.28
python/sglang/bench_one_batch_server.py bench 工具 modified 3.83

关键源码片段

python/sglang/bench_one_batch.py docs

文件级 docstring 中存在 4 处 `--batch` 错误,已全部修正为 `--batch-size`。

"""
...
## sweep through multiple data points and store (append) the results in a jsonl file:
python -m sglang.bench_one_batch --model-path meta-llama/Meta-Llama-3-8B-Instruct --batch-size 1 12 14 --input-len 256 512 --output-len 32 256 --run-name test_run
## run with profiling:
python -m sglang.bench_one_batch --model-path meta-llama/Meta-Llama-3-8B-Instruct --batch-size 1 12 14 --input-len 256 512 --profile
## run with profiling to custom directory:
export SGLANG_TORCH_PROFILER_DIR=/root/sglang/profile_log
python -m sglang.bench_one_batch --model-path meta-llama/Meta-Llama-3-8B-Instruct --batch-size 1 --input-len 256 --profile
## run with CUDA profiler (nsys):
nsys profile --force-overwrite=true -o bench_one_batch python -m sglang.bench_one_batch --model-path meta-llama/Meta-Llama-3-8B-Instruct --batch-size 1 --input-len 256 --profile --profile-activities CUDA_PROFILER
...
"""

评论区精华

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

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

风险与影响

无风险。仅修改 docstring,不影响任何运行时行为。

影响范围:极小。仅影响阅读 docstring 并尝试复制命令的用户,修复后示例命令可以正常工作。

关联 Issue

未识别关联 Issue

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

完整报告

参与讨论