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 2, 09:45 UTC
[CI] Remove duplicate Harmony test coverage (#44023)
Signed-off-by: sfeng33 <4florafeng@gmail.com>
Flora Feng committed
May 29, 2026 at 18:52 UTC
8c6daf6e2fe8b8e731866700719741def43ca165
2 files changed
+8
-156
tests/entrypoints/openai/chat_completion/test_serving_chat.py
-85
@@ -1449,91 +1449,6 @@ class TestServingChatWithHarmony:
1449
],
1450
)
1451
1452
- @pytest.mark.asyncio
1453
- async def test_tools_and_reasoning(
1454
- self, serving_chat, stream, weather_tools, weather_messages_start
1455
- ):
1456
- tools = weather_tools
1457
- messages = list(weather_messages_start)
1458
-
1459
- # Test the Harmony messages for the first turn's input
1460
- req = ChatCompletionRequest(model=MODEL_NAME, messages=messages, tools=tools)
1461
- input_messages, _ = (
1462
- serving_chat.openai_serving_render._make_request_with_harmony(req)
1463
- )
1464
- verify_harmony_messages(
1465
- input_messages,
1466
- [
1467
- {"role": "system"},
1468
- {"role": "developer", "tool_definitions": ["get_weather"]},
1469
- {"role": "user", "content": messages[0]["content"]},
1470
- ],
1471
- )
1472
-
1473
- # Test the Chat Completion response for the first turn's output
1474
- reasoning_str = "I'll call get_weather."
1475
- tool_args_str = '{"location": "Paris"}'
1476
- response_str = (
1477
- f"<|channel|>analysis<|message|>{reasoning_str}<|end|>"
1478
- "<|start|>assistant to=functions.get_weather<|channel|>commentary"
1479
- f"<|constrain|>json<|message|>{tool_args_str}<|call|>"
1480
- )
1481
- response = await self.generate_response_from_harmony_str(
1482
- serving_chat, req, response_str, stream=stream
1483
- )
1484
- verify_chat_response(
1485
- response,
1486
- reasoning=reasoning_str,
1487
- tool_calls=[("get_weather", tool_args_str)],
1488
- )
1489
-
1490
- tool_call = response.choices[0].message.tool_calls[0]
1491
-
1492
- # Add the output messages from the first turn as input to the second turn
1493
- for choice in response.choices:
1494
- messages.append(choice.message.model_dump(exclude_none=True))
1495
-
1496
- # Add our tool output message
1497
- messages.append(
1498
- {
1499
- "role": "tool",
1500
- "tool_call_id": tool_call.id,
1501
- "content": "20 degrees Celsius",
1502
- },
1503
- )
1504
-
1505
- # Test the Harmony messages for the second turn's input
1506
- req_2 = ChatCompletionRequest(model=MODEL_NAME, messages=messages, tools=tools)
1507
- input_messages_2, _ = (
1508
- serving_chat.openai_serving_render._make_request_with_harmony(req_2)
1509
- )
1510
- verify_harmony_messages(
1511
- input_messages_2,
1512
- [
1513
- {"role": "system"},
1514
- {"role": "developer"},
1515
- {"role": "user"},
1516
- {
1517
- "role": "assistant",
1518
- "channel": "analysis",
1519
- "content": reasoning_str,
1520
- },
1521
- {
1522
- "role": "assistant",
1523
- "channel": "commentary",
1524
- "recipient": "functions.get_weather",
1525
- "content": tool_args_str,
1526
- },
1527
- {
1528
- "role": "tool",
1529
- "author_name": "functions.get_weather",
1530
- "channel": "commentary",
1531
- "recipient": "assistant",
1532
- "content": "20 degrees Celsius",
1533
- },
1534
- ],
1535
- )
1536
-
1452
@pytest.mark.asyncio
1453
async def test_multi_turn_tools_and_reasoning(
1454
self, serving_chat, stream, weather_tools, weather_messages_start
tests/entrypoints/openai/chat_completion/test_serving_chat_stream_harmony.py
+8
-71
@@ -121,7 +121,9 @@ class TestExtractHarmonyStreamingDelta:
121
122
token_states = [
123
TokenState(
124
- channel=channel, recipient="functions.get_weather", text=args_text
124
+ channel=channel,
125
+ recipient="functions.get_weather",
126
+ text=args_text,
127
)
128
]
129
@@ -168,7 +170,11 @@ class TestExtractHarmonyStreamingDelta:
170
parser = MockStreamableParser(messages=messages)
171
172
token_states = [
171
- TokenState(channel="commentary", recipient="functions.tool2", text="args")
173
+ TokenState(
174
+ channel="commentary",
175
+ recipient="functions.tool2",
176
+ text="args",
177
+ )
178
]
179
180
delta_message, _ = extract_harmony_streaming_delta(
@@ -199,75 +205,6 @@ class TestExtractHarmonyStreamingDelta:
205
assert delta_message.content == delta_text
206
assert tools_streamed is False
207
202
- @pytest.mark.parametrize("channel", ["commentary", "analysis"])
203
- @patch("vllm.entrypoints.openai.chat_completion.stream_harmony.make_tool_call_id")
204
- def test_new_tool_call_without_functions_prefix(
205
- self, mock_make_tool_call_id, channel
206
- ):
207
- mock_make_tool_call_id.return_value = "call_bare123"
208
- parser = MockStreamableParser()
209
-
210
- token_states = [TokenState(channel=channel, recipient="get_weather", text="")]
211
-
212
- delta_message, tools_streamed = extract_harmony_streaming_delta(
213
- harmony_parser=parser,
214
- token_states=token_states,
215
- prev_recipient=None,
216
- include_reasoning=False,
217
- )
218
-
219
- assert delta_message is not None
220
- assert len(delta_message.tool_calls) == 1
221
- tool_call = delta_message.tool_calls[0]
222
- assert tool_call.id == "call_bare123"
223
- assert tool_call.type == "function"
224
- assert tool_call.function.name == "get_weather"
225
- assert tool_call.function.arguments == ""
226
- assert tool_call.index == 0
227
- assert tools_streamed is True
228
-
229
- @pytest.mark.parametrize("channel", ["commentary", "analysis"])
230
- def test_tool_call_argument_streaming_without_functions_prefix(self, channel):
231
- parser = MockStreamableParser()
232
- args_text = '{"location": "Paris"}'
233
-
234
- token_states = [
235
- TokenState(channel=channel, recipient="get_weather", text=args_text)
236
- ]
237
-
238
- delta_message, tools_streamed = extract_harmony_streaming_delta(
239
- harmony_parser=parser,
240
- token_states=token_states,
241
- prev_recipient="get_weather",
242
- include_reasoning=False,
243
- )
244
-
245
- assert delta_message is not None
246
- tool_call = delta_message.tool_calls[0]
247
- assert tool_call.id is None
248
- assert tool_call.function.arguments == args_text
249
- assert tool_call.index == 0
250
- assert tools_streamed is True
251
-
252
- def test_tool_call_index_from_previous_messages_without_functions_prefix(self):
253
- messages = [
254
- MockMessage(channel="commentary", recipient="tool1"),
255
- ]
256
- parser = MockStreamableParser(messages=messages)
257
-
258
- token_states = [
259
- TokenState(channel="commentary", recipient="tool2", text="args")
260
- ]
261
-
262
- delta_message, _ = extract_harmony_streaming_delta(
263
- harmony_parser=parser,
264
- token_states=token_states,
265
- prev_recipient="tool2",
266
- include_reasoning=False,
267
- )
268
-
269
- assert delta_message.tool_calls[0].index == 1
270
-
208
@pytest.mark.parametrize("channel", ["commentary", "analysis"])
209
@patch("vllm.entrypoints.openai.chat_completion.stream_harmony.make_tool_call_id")
210
def test_new_tool_call_dotted_function_name(self, mock_make_tool_call_id, channel):