ci(test): migrate OpenAI server tests to registered CI system (#16326)

Co-authored-by: Kangyan-Zhou <zky314343421@gmail.com>
This commit is contained in:
Alison Shao
2026-01-06 11:09:37 -08:00
committed by GitHub
parent 6e3fff1352
commit 0cbd8f3247
24 changed files with 86 additions and 35 deletions

View File

@@ -3,7 +3,6 @@ import tempfile
from contextlib import nullcontext
import torch
import torch.utils.cpp_extension
from packaging import version
from torch.cuda.memory import CUDAPluggableAllocator
@@ -90,6 +89,8 @@ def restore_symmetric_memory_context(saved_context):
def get_nccl_mem_pool():
global _allocator, _mem_pool, _cur_device
if _mem_pool is None:
import torch.utils.cpp_extension
out_dir = tempfile.gettempdir()
nccl_allocator_libname = "nccl_allocator"
torch.utils.cpp_extension.load_inline(

View File

@@ -4,6 +4,7 @@ import unittest
import openai
from sglang.srt.utils import kill_process_tree
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.test_utils import (
DEFAULT_SMALL_EMBEDDING_MODEL_NAME_FOR_TEST,
DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
@@ -12,6 +13,9 @@ from sglang.test.test_utils import (
popen_launch_server,
)
register_cuda_ci(est_time=70, suite="stage-b-test-small-1-gpu")
register_amd_ci(est_time=141, suite="stage-b-test-small-1-gpu")
class TestOpenAIEmbedding(CustomTestCase):
@classmethod
@@ -69,7 +73,6 @@ class TestOpenAIEmbedding(CustomTestCase):
self.assertEqual(len(response.data), 1)
self.assertTrue(len(response.data[0].embedding) > 0)
client = openai.Client(api_key=self.api_key, base_url=self.base_url)
response = client.embeddings.create(
model=self.model,
input=[15339, 314, 703, 284, 612, 262, 10658, 10188, 286, 2061],

View File

@@ -17,6 +17,7 @@ import requests
from sglang.srt.sampling.custom_logit_processor import CustomLogitProcessor
from sglang.srt.utils import 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.runners import TEST_RERANK_QUERY_DOCS
from sglang.test.test_utils import (
DEFAULT_SMALL_CROSS_ENCODER_MODEL_NAME_FOR_TEST,
@@ -27,6 +28,9 @@ from sglang.test.test_utils import (
popen_launch_server,
)
register_cuda_ci(est_time=184, suite="stage-b-test-small-1-gpu")
register_amd_ci(est_time=149, suite="stage-b-test-small-1-gpu")
class TestOpenAIServer(CustomTestCase):
@classmethod

View File

@@ -28,6 +28,10 @@ from sglang.srt.entrypoints.openai.protocol import (
ModelList,
UsageInfo,
)
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
register_cuda_ci(est_time=3, suite="stage-b-test-small-1-gpu")
register_amd_ci(est_time=10, suite="stage-b-test-small-1-gpu")
class TestModelCard(unittest.TestCase):

View File

@@ -21,6 +21,10 @@ from sglang.srt.entrypoints.openai.protocol import (
from sglang.srt.entrypoints.openai.serving_chat import OpenAIServingChat
from sglang.srt.managers.io_struct import GenerateReqInput
from sglang.srt.utils import get_or_create_event_loop
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
register_cuda_ci(est_time=10, suite="stage-b-test-small-1-gpu")
register_amd_ci(est_time=10, suite="stage-b-test-small-1-gpu")
class _MockTokenizerManager:

View File

@@ -11,6 +11,10 @@ from unittest.mock import AsyncMock, Mock
from sglang.srt.entrypoints.openai.protocol import CompletionRequest
from sglang.srt.entrypoints.openai.serving_completions import OpenAIServingCompletion
from sglang.srt.managers.tokenizer_manager import TokenizerManager
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
register_cuda_ci(est_time=10, suite="stage-b-test-small-1-gpu")
register_amd_ci(est_time=10, suite="stage-b-test-small-1-gpu")
class _MockTemplateManager:

View File

@@ -14,6 +14,10 @@ from sglang.srt.entrypoints.openai.protocol import (
)
from sglang.srt.entrypoints.openai.serving_embedding import OpenAIServingEmbedding
from sglang.srt.managers.io_struct import EmbeddingReqInput
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
register_cuda_ci(est_time=10, suite="stage-b-test-small-1-gpu")
register_amd_ci(est_time=10, suite="stage-b-test-small-1-gpu")
# Mock TokenizerManager for embedding tests

View File

@@ -12,6 +12,7 @@ import unittest
import requests
from sglang.srt.utils import kill_process_tree
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.test_utils import (
DEFAULT_ENABLE_THINKING_MODEL_NAME_FOR_TEST,
DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
@@ -20,6 +21,9 @@ from sglang.test.test_utils import (
popen_launch_server,
)
register_cuda_ci(est_time=70, suite="stage-b-test-small-1-gpu")
register_amd_ci(est_time=70, suite="stage-b-test-small-1-gpu")
class TestEnableThinking(CustomTestCase):
@classmethod

View File

@@ -4,6 +4,7 @@ import unittest
import openai
from sglang.srt.utils import kill_process_tree
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.test_utils import (
DEFAULT_SMALL_MODEL_NAME_FOR_TEST,
DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
@@ -12,6 +13,9 @@ from sglang.test.test_utils import (
popen_launch_server,
)
register_cuda_ci(est_time=109, suite="stage-b-test-small-1-gpu")
register_amd_ci(est_time=120, suite="stage-b-test-small-1-gpu")
class TestJSONModeMixin:
"""Mixin class containing JSON mode test methods"""

View File

@@ -4,6 +4,7 @@ import openai
from sglang.srt.utils import 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.test_utils import (
DEFAULT_SMALL_MODEL_NAME_FOR_TEST,
DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
@@ -12,6 +13,9 @@ from sglang.test.test_utils import (
popen_launch_server,
)
register_cuda_ci(est_time=7, suite="stage-b-test-small-1-gpu")
register_amd_ci(est_time=20, suite="stage-b-test-small-1-gpu")
# -------------------------------------------------------------------------
# EBNF Test Class: TestOpenAIServerEBNF
@@ -96,3 +100,9 @@ class TestOpenAIServerEBNF(CustomTestCase):
self.assertRegex(
text, pattern, f"Text '{text}' not matching the EBNF strict JSON shape"
)
if __name__ == "__main__":
import unittest
unittest.main()

View File

@@ -5,6 +5,7 @@ import openai
from sglang.srt.utils import 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.test_utils import (
DEFAULT_DRAFT_MODEL_EAGLE,
DEFAULT_SMALL_MODEL_NAME_FOR_TEST,
@@ -15,6 +16,13 @@ from sglang.test.test_utils import (
popen_launch_server,
)
register_cuda_ci(est_time=186, suite="stage-b-test-small-1-gpu")
register_amd_ci(
est_time=186,
suite="stage-b-test-small-1-gpu",
disabled="see https://github.com/sgl-project/sglang/issues/11127",
)
class BaseTestOpenAIServerWithHiddenStates(ABC):

View File

@@ -14,6 +14,7 @@ import unittest
import openai
from sglang.srt.utils import kill_process_tree
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.test_utils import (
DEFAULT_REASONING_MODEL_NAME_FOR_TEST,
DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
@@ -22,6 +23,9 @@ from sglang.test.test_utils import (
popen_launch_server,
)
register_cuda_ci(est_time=89, suite="stage-b-test-small-1-gpu")
register_amd_ci(est_time=89, suite="stage-b-test-small-1-gpu")
class TestReasoningContentAPI(CustomTestCase):
@classmethod

View File

@@ -5,6 +5,7 @@ import openai
from sglang.srt.utils import 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.test_utils import (
DEFAULT_SMALL_MODEL_NAME_FOR_TEST,
DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
@@ -13,6 +14,9 @@ from sglang.test.test_utils import (
popen_launch_server,
)
register_cuda_ci(est_time=60, suite="stage-b-test-small-1-gpu")
register_amd_ci(est_time=73, suite="stage-b-test-small-1-gpu")
class TestOpenAIServerFunctionCalling(CustomTestCase):
# NOTE: this system_message is for Llama3.2 system prompt. Without this,

View File

@@ -14,6 +14,7 @@ import openai
from sglang.srt.utils import 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.test_utils import (
DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
DEFAULT_URL_FOR_TEST,
@@ -21,6 +22,9 @@ from sglang.test.test_utils import (
popen_launch_server,
)
register_cuda_ci(est_time=120, suite="stage-b-test-small-1-gpu")
register_amd_ci(est_time=258, suite="stage-b-test-small-1-gpu")
class TestToolChoiceLlama32(CustomTestCase):

View File

@@ -11,6 +11,7 @@ import openai
from sglang.srt.utils import 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.test_utils import (
DEFAULT_SMALL_MODEL_NAME_FOR_TEST,
DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
@@ -21,6 +22,9 @@ from sglang.test.test_utils import (
popen_launch_server,
)
register_cuda_ci(est_time=41, suite="stage-b-test-small-1-gpu")
register_amd_ci(est_time=41, suite="stage-b-test-small-1-gpu")
class TestLargeMaxNewTokens(CustomTestCase):
@classmethod

View File

@@ -2,6 +2,7 @@ import unittest
from sglang.srt.sampling.sampling_params import MAX_LEN, get_max_seq_length
from sglang.srt.utils import kill_process_tree
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.kits.matched_stop_kit import MatchedStopMixin
from sglang.test.test_utils import (
DEFAULT_MODEL_NAME_FOR_TEST,
@@ -10,6 +11,9 @@ from sglang.test.test_utils import (
popen_launch_server,
)
register_cuda_ci(est_time=40, suite="stage-b-test-small-1-gpu")
register_amd_ci(est_time=60, suite="stage-b-test-small-1-gpu")
class TestMatchedStop(CustomTestCase, MatchedStopMixin):
@classmethod

View File

@@ -2,6 +2,7 @@ import openai
from sglang.srt.utils import 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.test_utils import (
DEFAULT_SMALL_MODEL_NAME_FOR_TEST,
DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
@@ -10,6 +11,9 @@ from sglang.test.test_utils import (
popen_launch_server,
)
register_cuda_ci(est_time=6, suite="stage-b-test-small-1-gpu")
register_amd_ci(est_time=47, suite="stage-b-test-small-1-gpu")
class TestOpenAIServerIgnoreEOS(CustomTestCase):
@classmethod
@@ -82,3 +86,9 @@ class TestOpenAIServerIgnoreEOS(CustomTestCase):
"length",
f"Expected finish_reason='length' for ignore_eos=True, got {response_ignore_eos.choices[0].finish_reason}",
)
if __name__ == "__main__":
import unittest
unittest.main()

View File

@@ -3,6 +3,7 @@ import unittest
import openai
from sglang.srt.utils import kill_process_tree
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.test_utils import (
DEFAULT_SMALL_MODEL_NAME_FOR_TEST,
DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
@@ -11,6 +12,9 @@ from sglang.test.test_utils import (
popen_launch_server,
)
register_cuda_ci(est_time=38, suite="stage-b-test-small-1-gpu")
register_amd_ci(est_time=31, suite="stage-b-test-small-1-gpu")
class TestRequestLengthValidation(CustomTestCase):
@classmethod

View File

@@ -10,23 +10,6 @@ from sglang.test.ci.ci_utils import TestFile, run_unittest_files
suites = {
"per-commit-1-gpu": [
TestFile("debug_utils/test_tensor_dump_forward_hook.py", 9),
TestFile("openai_server/basic/test_openai_embedding.py", 70),
TestFile("openai_server/basic/test_openai_server.py", 184),
TestFile("openai_server/basic/test_protocol.py", 3),
TestFile("openai_server/basic/test_serving_chat.py", 10),
TestFile("openai_server/basic/test_serving_completions.py", 10),
TestFile("openai_server/basic/test_serving_embedding.py", 10),
TestFile("openai_server/features/test_enable_thinking.py", 70),
TestFile("openai_server/features/test_json_mode.py", 109),
TestFile("openai_server/features/test_openai_server_ebnf.py", 7),
TestFile("openai_server/features/test_openai_server_hidden_states.py", 186),
TestFile("openai_server/features/test_reasoning_content.py", 89),
TestFile("openai_server/function_call/test_openai_function_calling.py", 60),
TestFile("openai_server/function_call/test_tool_choice.py", 120),
TestFile("openai_server/validation/test_large_max_new_tokens.py", 41),
TestFile("openai_server/validation/test_matched_stop.py", 40),
TestFile("openai_server/validation/test_openai_server_ignore_eos.py", 6),
TestFile("openai_server/validation/test_request_length_validation.py", 38),
TestFile("ops/test_repeat_interleave.py", 60),
TestFile("test_abort.py", 131),
TestFile("test_chunked_prefill.py", 312),
@@ -155,22 +138,6 @@ suite_amd = {
# TestFile("lora/test_lora_backend.py", 99), # Disabled temporarily, see https://github.com/sgl-project/sglang/issues/13107
# TestFile("lora/test_lora_cuda_graph.py", 250), # Disabled temporarily, see https://github.com/sgl-project/sglang/issues/13107
# TestFile("lora/test_lora_qwen3.py", 97), # Disabled temporarily, see https://github.com/sgl-project/sglang/issues/13107
TestFile("openai_server/basic/test_openai_embedding.py", 141),
TestFile("openai_server/basic/test_openai_server.py", 149),
TestFile("openai_server/basic/test_protocol.py", 10),
TestFile("openai_server/basic/test_serving_chat.py", 10),
TestFile("openai_server/basic/test_serving_completions.py", 10),
TestFile("openai_server/basic/test_serving_embedding.py", 10),
TestFile("openai_server/features/test_enable_thinking.py", 70),
TestFile("openai_server/features/test_json_mode.py", 120),
TestFile("openai_server/features/test_openai_server_ebnf.py", 20),
TestFile("openai_server/features/test_reasoning_content.py", 89),
TestFile("openai_server/function_call/test_openai_function_calling.py", 73),
TestFile("openai_server/function_call/test_tool_choice.py", 120),
TestFile("openai_server/validation/test_large_max_new_tokens.py", 41),
TestFile("openai_server/validation/test_matched_stop.py", 60),
TestFile("openai_server/validation/test_openai_server_ignore_eos.py", 85),
TestFile("openai_server/validation/test_request_length_validation.py", 31),
TestFile("ops/test_repeat_interleave.py", 75),
TestFile("rotary_embedding/test_mrope.py", 15),
TestFile("test_abort.py", 51),