Fix condition for streaming output_ids in tokenizer manager (#13759)

Signed-off-by: Xinyuan Tong <xinyuantong.cs@gmail.com>
Co-authored-by: Chang Su <chang.s.su\n@oracle.com>
Co-authored-by: Xinyuan Tong <115166877+JustinTong0323@users.noreply.github.com>
Co-authored-by: Xinyuan Tong <xinyuantong.cs@gmail.com>
This commit is contained in:
Lianmin Zheng
2025-11-29 13:56:15 -08:00
committed by GitHub
co-authored by Chang Su <chang.s.su\n@oracle.com> Xinyuan Tong Xinyuan Tong
parent d7cb08c5be
commit 155a9e7237
6 changed files with 72 additions and 30 deletions
+41
View File
@@ -1,8 +1,11 @@
import json
import os
from concurrent.futures import ThreadPoolExecutor
from types import SimpleNamespace
from typing import Dict, List, Literal, Optional
import requests
from sglang.srt.utils import is_hip, kill_process_tree
from sglang.test.run_eval import run_eval
from sglang.test.test_utils import (
@@ -60,6 +63,8 @@ class BaseTestGptOss(CustomTestCase):
)
try:
self._check_streaming_responses_api_request(model)
# run multiple tests in parallel since we are mostly bound by the longest generate sequence
# instead of the number of questions
with ThreadPoolExecutor(max_workers=4) as executor:
@@ -79,6 +84,42 @@ class BaseTestGptOss(CustomTestCase):
finally:
kill_process_tree(process.pid)
def _check_streaming_responses_api_request(self, model):
# Use requests to verify /v1/responses streaming
url = f"{_base_url}/v1/responses"
payload = {
"model": model,
"input": "What is 1 + 1?",
"stream": True,
"temperature": 0,
}
response = requests.post(url, json=payload, stream=True)
if response.status_code != 200:
print(f"Response API failed: {response.text}")
response.raise_for_status()
content = ""
for line in response.iter_lines():
if line:
decoded_line = line.decode("utf-8")
if decoded_line.startswith("data: "):
data_str = decoded_line[6:]
if data_str.strip() == "[DONE]":
break
try:
data = json.loads(data_str)
if data.get("type") == "response.output_text.delta":
delta = data.get("delta", "")
content += delta
except json.JSONDecodeError:
pass
print(f"Streaming check response: {content}")
self.assertTrue(len(content) > 0)
self.assertIn("2", content)
def _run_one_eval(self, model, reasoning_effort, expected_score):
args = SimpleNamespace(
base_url=_base_url,