[Test] Consolidate test cleanup and CI taxonomy (net -11.4K lines) (#37436)

Co-authored-by: Mick Qian <mickqian@users.noreply.github.com>
This commit is contained in:
Xiaoyu Zhang
2026-09-07 15:13:59 +08:00
committed by GitHub
co-authored by Mick Qian
parent 6a1ff90f2d
commit 4d23a4fa6d
199 changed files with 1185 additions and 11812 deletions
@@ -17,7 +17,6 @@ import requests
from sglang.srt.utils import kill_process_tree
from sglang.test.ci.ci_register import (
register_amd_ci,
register_cpu_ci,
register_cuda_ci,
)
@@ -29,8 +28,7 @@ from sglang.test.test_utils import (
popen_launch_server,
)
register_cuda_ci(est_time=51, stage="base-b", runner_config="1-gpu-large")
register_amd_ci(est_time=140, suite="stage-b-test-1-gpu-small-amd")
register_cuda_ci(est_time=50, stage="base-b", runner_config="1-gpu-large")
register_cpu_ci(est_time=54, suite="stage-b-test-cpu-intel")
# System message to guide Llama3.2 to produce proper tool call format
@@ -3,9 +3,9 @@ import unittest
import openai
from sglang.srt.utils import kill_process_tree
from sglang.srt.utils import is_npu, kill_process_tree
from sglang.srt.utils.hf_transformers_utils import get_tokenizer
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.ci.ci_register import register_cuda_ci, register_npu_ci
from sglang.test.test_utils import (
DEFAULT_SMALL_MODEL_NAME_FOR_TEST,
DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
@@ -15,8 +15,27 @@ from sglang.test.test_utils import (
popen_launch_server,
)
register_cuda_ci(est_time=210, stage="base-b", runner_config="1-gpu-large")
register_amd_ci(est_time=73, suite="stage-b-test-1-gpu-small-amd")
register_cuda_ci(est_time=100, stage="base-b", runner_config="1-gpu-large")
# Backend-specific: Ascend uses a local model mirror and its native
# attention backend, while sharing the protocol assertions below.
register_npu_ci(est_time=400, suite="full-1-npu-a3", nightly=True)
def _model_path():
if is_npu():
from sglang.test.ascend.test_ascend_utils import (
LLAMA_3_2_1B_INSTRUCT_WEIGHTS_PATH,
)
return LLAMA_3_2_1B_INSTRUCT_WEIGHTS_PATH
return DEFAULT_SMALL_MODEL_NAME_FOR_TEST
def _server_args(parser):
args = ["--tool-call-parser", parser]
if is_npu():
args[:0] = ["--attention-backend", "ascend", "--disable-cuda-graph"]
return args
class TestOpenAIServerFunctionCalling(CustomTestCase):
@@ -36,8 +55,7 @@ class TestOpenAIServerFunctionCalling(CustomTestCase):
@classmethod
def setUpClass(cls):
# Replace with the model name needed for testing; if not required, reuse DEFAULT_SMALL_MODEL_NAME_FOR_TEST
cls.model = DEFAULT_SMALL_MODEL_NAME_FOR_TEST
cls.model = _model_path()
cls.base_url = DEFAULT_URL_FOR_TEST
cls.api_key = "sk-123456"
@@ -47,11 +65,7 @@ class TestOpenAIServerFunctionCalling(CustomTestCase):
cls.base_url,
timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
api_key=cls.api_key,
other_args=[
# If your server needs extra parameters to test function calling, please add them here.
"--tool-call-parser",
"llama3",
],
other_args=_server_args("llama3"),
)
cls.base_url += "/v1"
cls.tokenizer = get_tokenizer(cls.model)
@@ -97,7 +111,7 @@ class TestOpenAIServerFunctionCalling(CustomTestCase):
{"role": "system", "content": self.SYSTEM_MESSAGE},
{"role": "user", "content": "Compute (3+5)"},
]
response = client.chat.completions.create(
request = dict(
model=self.model,
max_tokens=2048,
messages=messages,
@@ -105,8 +119,12 @@ class TestOpenAIServerFunctionCalling(CustomTestCase):
top_p=0.8,
stream=False,
tools=tools,
tool_choice="required",
)
# Ascend keeps the historical auto-choice coverage; CUDA forces the
# call so this assertion never depends on a stochastic model decision.
if not is_npu():
request["tool_choice"] = "required"
response = client.chat.completions.create(**request)
tool_calls = response.choices[0].message.tool_calls
@@ -843,7 +861,7 @@ class TestOpenAIPythonicFunctionCalling(CustomTestCase):
@classmethod
def setUpClass(cls):
cls.model = DEFAULT_SMALL_MODEL_NAME_FOR_TEST
cls.model = _model_path()
cls.base_url = DEFAULT_URL_FOR_TEST
cls.api_key = "sk-123456"
cls.process = popen_launch_server(
@@ -851,10 +869,7 @@ class TestOpenAIPythonicFunctionCalling(CustomTestCase):
cls.base_url,
timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
api_key=cls.api_key,
other_args=[
"--tool-call-parser",
"pythonic",
],
other_args=_server_args("pythonic"),
)
cls.base_url += "/v1"
cls.tokenizer = get_tokenizer(cls.model)
@@ -922,6 +937,7 @@ class TestOpenAIPythonicFunctionCalling(CustomTestCase):
is_rust_server_built(),
"embedded rust server extension not built",
)
@unittest.skipIf(is_npu(), "the embedded Rust server is not an Ascend path")
class TestOpenAIFunctionCallingWithRust(TestOpenAIServerFunctionCalling):
"""Run the registered unary/streaming function-call suite through Rust."""
@@ -946,6 +962,7 @@ class TestOpenAIFunctionCallingWithRust(TestOpenAIServerFunctionCalling):
is_rust_server_built(),
"embedded rust server extension not built",
)
@unittest.skipIf(is_npu(), "the embedded Rust server is not an Ascend path")
class TestOpenAIPythonicFunctionCallingWithRust(TestOpenAIPythonicFunctionCalling):
"""Run Pythonic unary/streaming tool calls through Rust."""