Prhub

#44002 [Bugfix] Reject negative values for max_logprobs and long_prefill_token_threshold

原始 PR 作者 jwzheng96 合并时间 2026-06-30 20:01 文件变更 1 提交数 9 评论 4 代码增减 +1 / -1

执行摘要

更新 long_prefill_token_threshold 文档说明 0 禁用

Issue #43985 报告了两个 CLI 整数字段 max_logprobslong_prefill_token_threshold 缺少非负验证,导致负值被静默接受或传递错误信息。此 PR 旨在收紧 admission 并消除歧义。最终实现聚焦于 long_prefill_token_threshold 的文档澄清,使 '0 disables the cap' 显式化。

这是一个小型文档改进 PR,适合快速回顾了解配置验证模式和文档最佳实践。建议阅读关联 issue #43985 和类似 PR #43794 以了解 vLLM 配置验证的整体模式。

讨论亮点

Reviewer @yewentao256 评论:'For this small update, we don't need specific unit tests',建议删除测试。作者 @jwzheng96 同意了并删除了测试。最终只保留 docstring 变更。

实现拆解

实现仅包含一行 docstring 更改:

  1. 查看 issue 后,作者发现 SchedulerConfig.long_prefill_token_threshold 已有 ge=0 约束,但文档未明确 0 的含义。
  2. 将 docstring 从 'longer than this number of tokens.' 扩展为 'longer than this number of tokens. 0 disables the cap (default).'
  3. 根据 reviewer 建议,删除了最初为测试添加的单元测试文件(tests/test_config.py 中的测试函数)。
  4. 合并到 main 仅包含 scheduler.py 的改动。
    注意:ModelConfig.max_logprobs 的约束原计划添加,但最终未包含在合并代码中;可能已在其他 PR 中处理或发现已有 ge=-1 约束。
文件 模块 状态 重要度
vllm/config/scheduler.py 配置 modified 4.08

关键源码片段

vllm/config/scheduler.py documentation

唯一修改的文件,通过对 docstring 添加 '0 disables the cap (default)' 消除配置参数意义的歧义,避免用户误用负值。

# vllm/config/scheduler.py
class SchedulerConfig:
    # ... ( 其他字段 )
​
    long_prefill_token_threshold: int = Field(default=0, ge=0)
    """
    For chunked prefill, a request is considered long if the prompt is
    longer than this number of tokens.
    0 disables the cap (default).  # <-- 本次新增的说明行
    """

评论区精华

移除单元测试 测试

Reviewer @yewentao256 建议删除测试,因为这个小更新不需要特定单元测试。作者 @jwzheng96 同意并删除了测试。

结论:删除了 tests/test_config.py 中新增的测试函数。 · 已解决

风险与影响

无代码逻辑变更,仅文档改进。因此无回归、性能或安全问题。但可能用户之前依赖未记录的负值行为(虽然已隐含拒绝),文档澄清可能略微改变用户预期,但风险极低。

影响范围:仅 SchedulerConfig.long_prefill_token_threshold 的文档字符串。无功能变化。用户通过 --long-prefill-token-threshold 0 或配置文件设置后,行为不变,但文档明确。影响程度:低。

无风险

关联 Issue

#43496 [Bug]: --block-size 0 silently passes validation, crashes engine init with ZeroDivisionError
#43521 [Bug]: --hash-block-size 0 silently passes validation, crashes resolve_kv_cache_block_sizes with ZeroDivisionError
#43532 [Bug]: --max-model-len 0 silently accepted; engine starts cleanly, requests scheduled with negative num_new_tokens
#43985 [Bug]: --max-logprobs and --long-prefill-token-threshold silently accept negative values (config-validation gap)

完整报告

参与讨论