执行摘要
修复 chat 测试的 n 参数 flaky 问题
PR body 指出测试断言 len(set(contents)) > 1 在低熵 prompt 和短输出下可能全部相同(见 Buildkite #63256),需要使 n 个样本的多样性变为确定性。
值得合并以提升 CI 稳定性。
gemini-code-assist[bot] 建议恢复或更新注释以反映确定性种子逻辑,但实际未采纳。DarkLight1337 直接批准。
PR body 指出测试断言 len(set(contents)) > 1 在低熵 prompt 和短输出下可能全部相同(见 Buildkite #63256),需要使 n 个样本的多样性变为确定性。
值得合并以提升 CI 稳定性。
gemini-code-assist[bot] 建议恢复或更新注释以反映确定性种子逻辑,但实际未采纳。DarkLight1337 直接批准。
仅修改 tests/entrypoints/openai/chat_completion/test_chat.py 中 test_chat_completion_n_parameter_non_streaming 函数的三处参数:
seed=42 使采样确定性,vLLM 自动为 n=3 衍生子种子 42/43/44,保证不同。temperature 从 0.7 提高到 1.0 使采样分布更均匀,减少偶然雷同。max_completion_tokens 从 20 扩大到 50,提高文本长度丰富度。# Verify all responses are different (highly likely with temperature > 0),但未补充新注释。| 文件 | 模块 | 状态 | 重要度 |
|---|---|---|---|
tests/entrypoints/openai/chat_completion/test_chat.py |
测试 | modified | 3.71 |
tests/entrypoints/openai/chat_completion/test_chat.py
test-coverage
唯一修改的文件,修复 flaky 测试的三个参数和移除注释。
# Test with n=3
chat_completion = await client.chat.completions.create(
model=model_name,
messages=messages,
max_completion_tokens=50, # Changed from 20 to 50
temperature=1.0, # Changed from 0.7 to 1.0
n=3,
seed=42, # Added seed for deterministic diversity
stream=False,
)
assert len(chat_completion.choices) == 3
# Verify each choice has content and correct index
for i, choice in enumerate(chat_completion.choices):
assert choice.index == i
assert choice.message.content is not None
assert len(choice.message.content) > 0
# Removed previous comment "Verify all responses are different (highly likely with temperature > 0)"
contents = [choice.message.content for choice in chat_completion.choices]
assert len(set(contents)) > 1, "Expected different responses with n=3"
gemini-code-assist[bot] 建议恢复或更新注释说明确定性种子逻辑,但作者未采纳。
结论:注释被移除,未重新添加。 · 待处理
仅修改测试参数,无生产代码风险。但若模型内部种子衍生产生改变,此测试可能仍然失败——不过 vLLM 的种子逻辑较稳定。
直接影响 CI 可靠性,消除一个已知 flaky 测试。对其他模块无影响。
当前没有检测到明确关联的 Issue 链接,后续同步到相关引用后会出现在这里。
参与讨论