A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 6, 14:30 UTC
[CI] Fix flaky tool_use chat completion tests with deterministic seed (#37027)
Signed-off-by: sfeng33 <4florafeng@gmail.com>
Flora Feng committed
Mar 16, 2026 at 23:24 UTC
f04d5226f837ae76daf442a2a3f2b161c4287242
4 files changed
+19
tests/tool_use/test_chat_completions.py
+5
@@ -6,6 +6,7 @@ import pytest
6
7
from .utils import (
8
MESSAGES_WITHOUT_TOOLS,
9
+ SEED,
10
WEATHER_TOOL,
11
ServerConfig,
12
ensure_system_prompt,
@@ -27,6 +28,7 @@ async def test_chat_completion_without_tools(
28
max_completion_tokens=150,
29
model=model_name,
30
logprobs=False,
31
+ seed=SEED,
32
)
33
choice = chat_completion.choices[0]
34
stop_reason = chat_completion.choices[0].finish_reason
@@ -47,6 +49,7 @@ async def test_chat_completion_without_tools(
49
max_completion_tokens=150,
50
model=model_name,
51
logprobs=False,
52
+ seed=SEED,
53
stream=True,
54
)
55
chunks: list[str] = []
@@ -97,6 +100,7 @@ async def test_chat_completion_with_tools(
100
model=model_name,
101
tools=[WEATHER_TOOL],
102
logprobs=False,
103
+ seed=SEED,
104
)
105
choice = chat_completion.choices[0]
106
stop_reason = chat_completion.choices[0].finish_reason
@@ -118,6 +122,7 @@ async def test_chat_completion_with_tools(
122
model=model_name,
123
logprobs=False,
124
tools=[WEATHER_TOOL],
125
+ seed=SEED,
126
stream=True,
127
)
128
tests/tool_use/test_parallel_tool_calls.py
+7
@@ -10,6 +10,7 @@ from .utils import (
10
MESSAGES_ASKING_FOR_PARALLEL_TOOLS,
11
MESSAGES_WITH_PARALLEL_TOOL_RESPONSE,
12
SEARCH_TOOL,
13
+ SEED,
14
WEATHER_TOOL,
15
ServerConfig,
16
)
@@ -39,6 +40,7 @@ async def test_parallel_tool_calls(
40
model=model_name,
41
tools=[WEATHER_TOOL, SEARCH_TOOL],
42
logprobs=False,
43
+ seed=SEED,
44
)
45
46
choice = chat_completion.choices[0]
@@ -76,6 +78,7 @@ async def test_parallel_tool_calls(
78
max_completion_tokens=200,
79
tools=[WEATHER_TOOL, SEARCH_TOOL],
80
logprobs=False,
81
+ seed=SEED,
82
stream=True,
83
)
84
@@ -166,6 +169,7 @@ async def test_parallel_tool_calls_with_results(
169
model=model_name,
170
tools=[WEATHER_TOOL, SEARCH_TOOL],
171
logprobs=False,
172
+ seed=SEED,
173
)
174
175
choice = chat_completion.choices[0]
@@ -184,6 +188,7 @@ async def test_parallel_tool_calls_with_results(
188
model=model_name,
189
tools=[WEATHER_TOOL, SEARCH_TOOL],
190
logprobs=False,
191
+ seed=SEED,
192
stream=True,
193
)
194
@@ -229,6 +234,7 @@ async def test_parallel_tool_calls_false(client: openai.AsyncOpenAI):
234
model=model_name,
235
tools=[WEATHER_TOOL, SEARCH_TOOL],
236
logprobs=False,
237
+ seed=SEED,
238
parallel_tool_calls=False,
239
)
240
@@ -247,6 +253,7 @@ async def test_parallel_tool_calls_false(client: openai.AsyncOpenAI):
253
max_completion_tokens=200,
254
tools=[WEATHER_TOOL, SEARCH_TOOL],
255
logprobs=False,
256
+ seed=SEED,
257
parallel_tool_calls=False,
258
stream=True,
259
)
tests/tool_use/test_tool_calls.py
+5
@@ -10,6 +10,7 @@ from .utils import (
10
MESSAGES_ASKING_FOR_TOOLS,
11
MESSAGES_WITH_TOOL_RESPONSE,
12
SEARCH_TOOL,
13
+ SEED,
14
WEATHER_TOOL,
15
)
16
@@ -27,6 +28,7 @@ async def test_tool_call_and_choice(client: openai.AsyncOpenAI):
28
model=model_name,
29
tools=[WEATHER_TOOL, SEARCH_TOOL],
30
logprobs=False,
31
+ seed=SEED,
32
)
33
34
choice = chat_completion.choices[0]
@@ -71,6 +73,7 @@ async def test_tool_call_and_choice(client: openai.AsyncOpenAI):
73
max_completion_tokens=100,
74
tools=[WEATHER_TOOL, SEARCH_TOOL],
75
logprobs=False,
76
+ seed=SEED,
77
stream=True,
78
)
79
@@ -154,6 +157,7 @@ async def test_tool_call_with_results(client: openai.AsyncOpenAI):
157
model=model_name,
158
tools=[WEATHER_TOOL, SEARCH_TOOL],
159
logprobs=False,
160
+ seed=SEED,
161
)
162
163
choice = chat_completion.choices[0]
@@ -171,6 +175,7 @@ async def test_tool_call_with_results(client: openai.AsyncOpenAI):
175
model=model_name,
176
tools=[WEATHER_TOOL, SEARCH_TOOL],
177
logprobs=False,
178
+ seed=SEED,
179
stream=True,
180
)
181
tests/tool_use/utils.py
+2
@@ -42,6 +42,8 @@ def ensure_system_prompt(
42
43
# universal args for all models go here. also good if you need to test locally
44
# and change type or KV cache quantization or something.
45
+SEED = 42
46
+
47
ARGS: list[str] = [
48
"--enable-auto-tool-choice",
49
"--max-model-len",