Fix gpt_oss_common import path and migrate core tests (#16426)
This commit is contained in:
@@ -9,11 +9,14 @@ test into unit tests so that's easily reproducible in CI.
|
||||
|
||||
import unittest
|
||||
|
||||
from sglang.test.ci.ci_register import register_cuda_ci
|
||||
from sglang.test.test_deterministic_utils import (
|
||||
COMMON_SERVER_ARGS,
|
||||
TestDeterministicBase,
|
||||
)
|
||||
|
||||
register_cuda_ci(est_time=228, suite="stage-b-test-small-1-gpu")
|
||||
|
||||
|
||||
class TestFlashinferDeterministic(TestDeterministicBase):
|
||||
# Test with flashinfer attention backend
|
||||
@@ -1,6 +1,10 @@
|
||||
import unittest
|
||||
|
||||
from test_gpt_oss_common import BaseTestGptOss
|
||||
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
|
||||
from sglang.test.gpt_oss_common import BaseTestGptOss
|
||||
|
||||
register_cuda_ci(est_time=402, suite="stage-b-test-small-1-gpu")
|
||||
register_amd_ci(est_time=750, suite="stage-b-test-small-1-gpu-amd")
|
||||
|
||||
|
||||
class TestGptOss1Gpu(BaseTestGptOss):
|
||||
@@ -4,8 +4,11 @@ import torch
|
||||
from transformers import AutoModelForCausalLM, AutoTokenizer
|
||||
|
||||
import sglang as sgl
|
||||
from sglang.test.ci.ci_register import register_cuda_ci
|
||||
from sglang.test.test_utils import DEFAULT_SMALL_MODEL_NAME_FOR_TEST, CustomTestCase
|
||||
|
||||
register_cuda_ci(est_time=55, suite="stage-b-test-small-1-gpu")
|
||||
|
||||
|
||||
class TestHiddenState(CustomTestCase):
|
||||
def test_return_hidden_states(self):
|
||||
@@ -7,6 +7,7 @@ import requests
|
||||
from transformers import AutoModelForCausalLM, AutoTokenizer
|
||||
|
||||
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,
|
||||
@@ -15,6 +16,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=38, suite="stage-b-test-small-1-gpu-amd")
|
||||
|
||||
|
||||
class TestInputEmbeds(CustomTestCase):
|
||||
@classmethod
|
||||
@@ -2,12 +2,16 @@ import copy
|
||||
import unittest
|
||||
|
||||
from sglang.srt.managers.io_struct import GenerateReqInput
|
||||
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_URL_FOR_TEST,
|
||||
CustomTestCase,
|
||||
)
|
||||
|
||||
register_cuda_ci(est_time=8, suite="stage-b-test-small-1-gpu")
|
||||
register_amd_ci(est_time=8, suite="stage-b-test-small-1-gpu-amd")
|
||||
|
||||
|
||||
class TestGenerateReqInputNormalization(CustomTestCase):
|
||||
"""Test the normalization of GenerateReqInput for batch processing and different input formats."""
|
||||
@@ -6,8 +6,12 @@ import torch.nn as nn
|
||||
|
||||
from sglang.srt.model_executor.hook_manager import register_forward_hooks
|
||||
from sglang.srt.server_args import ServerArgs
|
||||
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
|
||||
from sglang.test.test_utils import CustomTestCase
|
||||
|
||||
register_cuda_ci(est_time=6, suite="stage-b-test-small-1-gpu")
|
||||
register_amd_ci(est_time=10, suite="stage-b-test-small-1-gpu-amd")
|
||||
|
||||
HOOK_CALLS = []
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import unittest
|
||||
from types import SimpleNamespace
|
||||
|
||||
from sglang.srt.utils import kill_process_tree
|
||||
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
|
||||
from sglang.test.run_eval import run_eval
|
||||
from sglang.test.test_utils import (
|
||||
DEFAULT_MODEL_NAME_FOR_TEST,
|
||||
@@ -12,6 +13,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=60, suite="stage-b-test-small-1-gpu-amd")
|
||||
|
||||
|
||||
class TestPageSize(CustomTestCase):
|
||||
@classmethod
|
||||
+4
@@ -4,6 +4,7 @@ import re
|
||||
import unittest
|
||||
|
||||
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,
|
||||
@@ -16,6 +17,9 @@ from sglang.test.test_utils import (
|
||||
send_generate_requests,
|
||||
)
|
||||
|
||||
register_cuda_ci(est_time=47, suite="stage-b-test-small-1-gpu")
|
||||
register_amd_ci(est_time=70, suite="stage-b-test-small-1-gpu-amd")
|
||||
|
||||
|
||||
class TestMaxQueuedRequests(CustomTestCase):
|
||||
@classmethod
|
||||
@@ -4,8 +4,11 @@ import torch
|
||||
from transformers import AutoModelForCausalLM, AutoTokenizer
|
||||
|
||||
from sglang.srt.entrypoints.engine import Engine
|
||||
from sglang.test.ci.ci_register import register_cuda_ci
|
||||
from sglang.test.test_utils import DEFAULT_SMALL_MODEL_NAME_FOR_TEST, CustomTestCase
|
||||
|
||||
register_cuda_ci(est_time=260, suite="stage-b-test-small-1-gpu")
|
||||
|
||||
TEST_MODEL_NAME = DEFAULT_SMALL_MODEL_NAME_FOR_TEST
|
||||
|
||||
|
||||
@@ -3,8 +3,12 @@ import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from sglang.srt.server_args import PortArgs, ServerArgs, prepare_server_args
|
||||
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
|
||||
from sglang.test.test_utils import CustomTestCase
|
||||
|
||||
register_cuda_ci(est_time=9, suite="stage-b-test-small-1-gpu")
|
||||
register_amd_ci(est_time=1, suite="stage-b-test-small-1-gpu-amd")
|
||||
|
||||
|
||||
class TestPrepareServerArgs(CustomTestCase):
|
||||
def test_prepare_server_args(self):
|
||||
@@ -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.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,
|
||||
@@ -26,6 +27,9 @@ from sglang.test.test_utils import (
|
||||
run_logprob_check,
|
||||
)
|
||||
|
||||
register_cuda_ci(est_time=127, suite="stage-b-test-small-1-gpu")
|
||||
register_amd_ci(est_time=130, suite="stage-b-test-small-1-gpu-amd")
|
||||
|
||||
|
||||
class TestSRTEndpoint(CustomTestCase):
|
||||
@classmethod
|
||||
@@ -14,6 +14,7 @@ import sglang as sgl
|
||||
from sglang.bench_offline_throughput import BenchArgs, throughput_test
|
||||
from sglang.srt.server_args import ServerArgs
|
||||
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.few_shot_gsm8k_engine import run_eval
|
||||
from sglang.test.test_utils import (
|
||||
DEFAULT_SMALL_EMBEDDING_MODEL_NAME_FOR_TEST,
|
||||
@@ -21,6 +22,9 @@ from sglang.test.test_utils import (
|
||||
CustomTestCase,
|
||||
)
|
||||
|
||||
register_cuda_ci(est_time=252, suite="stage-b-test-small-1-gpu")
|
||||
register_amd_ci(est_time=261, suite="stage-b-test-small-1-gpu-amd")
|
||||
|
||||
|
||||
class TestSRTEngine(CustomTestCase):
|
||||
|
||||
+1
-24
@@ -9,24 +9,12 @@ from sglang.test.ci.ci_utils import TestFile, run_unittest_files
|
||||
# NOTE: please sort the test cases alphabetically by the test file name
|
||||
suites = {
|
||||
"per-commit-1-gpu": [
|
||||
TestFile("test_deterministic.py", 228),
|
||||
TestFile("test_evs.py", 20),
|
||||
TestFile("test_external_models.py", 30),
|
||||
TestFile("test_gpt_oss_1gpu.py", 402),
|
||||
TestFile("test_hidden_states.py", 55),
|
||||
TestFile("test_input_embeddings.py", 38),
|
||||
TestFile("test_io_struct.py", 8),
|
||||
TestFile("test_jinja_template_utils.py", 7),
|
||||
TestFile("test_model_hooks.py", 6),
|
||||
TestFile("test_modelopt_loader.py", 11),
|
||||
TestFile("test_multi_tokenizer.py", 230),
|
||||
TestFile("test_page_size.py", 60),
|
||||
TestFile("test_request_queue_validation.py", 47),
|
||||
TestFile("test_score_api.py", 260),
|
||||
TestFile("test_server_args.py", 9),
|
||||
TestFile("test_skip_tokenizer_init.py", 77),
|
||||
TestFile("test_srt_endpoint.py", 127),
|
||||
TestFile("test_srt_engine.py", 252),
|
||||
TestFile("test_utils_update_weights.py", 29),
|
||||
TestFile("test_video_utils.py", 5),
|
||||
TestFile("test_modelopt_export.py", 9),
|
||||
@@ -98,7 +86,6 @@ suites = {
|
||||
TestFile("test_bench_one_batch.py"),
|
||||
TestFile("test_bench_serving.py"),
|
||||
TestFile("test_eval_accuracy_large.py"),
|
||||
TestFile("test_gpt_oss_common.py"),
|
||||
TestFile("test_moe_eval_accuracy_large.py"),
|
||||
TestFile("test_profile_v2.py"),
|
||||
TestFile("models/test_ministral3_models.py"),
|
||||
@@ -120,18 +107,10 @@ suite_amd = {
|
||||
# TestFile("lora/test_lora_qwen3.py", 97), # Disabled temporarily, see https://github.com/sgl-project/sglang/issues/13107
|
||||
TestFile("test_bench_typebaseddispatcher.py", 10),
|
||||
TestFile("test_external_models.py", 45),
|
||||
TestFile("test_input_embeddings.py", 38),
|
||||
TestFile("test_io_struct.py", 8),
|
||||
TestFile("test_jinja_template_utils.py", 1),
|
||||
TestFile("test_model_hooks.py", 10),
|
||||
TestFile("test_multi_tokenizer.py", 345),
|
||||
TestFile("test_page_size.py", 60),
|
||||
TestFile("test_request_queue_validation.py", 70),
|
||||
TestFile("test_rope_rocm.py", 3),
|
||||
TestFile("test_server_args.py", 1),
|
||||
TestFile("test_skip_tokenizer_init.py", 117),
|
||||
TestFile("test_srt_endpoint.py", 130),
|
||||
TestFile("test_srt_engine.py", 261),
|
||||
# TestFile("test_torch_compile_moe.py", 210), # Disabled temporarily, see https://github.com/sgl-project/sglang/issues/13107
|
||||
TestFile("test_type_based_dispatcher.py", 10),
|
||||
TestFile("test_video_utils.py", 8),
|
||||
@@ -143,9 +122,7 @@ suite_amd = {
|
||||
# TestFile("test_vision_chunked_prefill.py", 175), # Disabled temporarily and track in #7701
|
||||
# TestFile("test_wave_attention_backend.py", 150), # Disabled temporarily, see https://github.com/sgl-project/sglang/issues/11127
|
||||
],
|
||||
"per-commit-amd-mi35x": [
|
||||
TestFile("test_gpt_oss_1gpu.py", 750),
|
||||
],
|
||||
"per-commit-amd-mi35x": [],
|
||||
"per-commit-2-gpu-amd": [
|
||||
TestFile("test_data_parallelism.py", 73),
|
||||
TestFile("test_load_weights_from_remote_instance.py", 72),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import unittest
|
||||
|
||||
from test_gpt_oss_common import BaseTestGptOss
|
||||
from sglang.test.gpt_oss_common import BaseTestGptOss
|
||||
|
||||
|
||||
class TestGptOss4Gpu(BaseTestGptOss):
|
||||
|
||||
@@ -1,152 +0,0 @@
|
||||
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 (
|
||||
DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
|
||||
DEFAULT_URL_FOR_TEST,
|
||||
CustomTestCase,
|
||||
is_in_ci,
|
||||
popen_launch_server,
|
||||
write_github_step_summary,
|
||||
)
|
||||
|
||||
_base_url = DEFAULT_URL_FOR_TEST
|
||||
_is_hip = is_hip()
|
||||
|
||||
|
||||
class BaseTestGptOss(CustomTestCase):
|
||||
def run_test(
|
||||
self,
|
||||
model_variant: Literal["20b", "120b"],
|
||||
quantization: Literal["mxfp4", "bf16"],
|
||||
expected_score_of_reasoning_effort: Dict[str, float],
|
||||
other_args: Optional[List[str]] = None,
|
||||
):
|
||||
if other_args is None:
|
||||
other_args = []
|
||||
|
||||
model = {
|
||||
("20b", "bf16"): "lmsys/gpt-oss-20b-bf16",
|
||||
("120b", "bf16"): "lmsys/gpt-oss-120b-bf16",
|
||||
("20b", "mxfp4"): "openai/gpt-oss-20b",
|
||||
("120b", "mxfp4"): "openai/gpt-oss-120b",
|
||||
}[(model_variant, quantization)]
|
||||
|
||||
if model_variant == "20b":
|
||||
other_args += ["--cuda-graph-max-bs", "600"]
|
||||
if _is_hip:
|
||||
os.environ["SGLANG_USE_AITER"] = "0"
|
||||
self._run_test_raw(
|
||||
model=model,
|
||||
expected_score_of_reasoning_effort=expected_score_of_reasoning_effort,
|
||||
other_args=other_args,
|
||||
)
|
||||
|
||||
def _run_test_raw(
|
||||
self,
|
||||
model: str,
|
||||
expected_score_of_reasoning_effort: Dict[str, float],
|
||||
other_args: List[str],
|
||||
):
|
||||
process = popen_launch_server(
|
||||
model,
|
||||
_base_url,
|
||||
timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
|
||||
other_args=other_args,
|
||||
)
|
||||
|
||||
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:
|
||||
list(
|
||||
executor.map(
|
||||
lambda d: self._run_one_eval(**d),
|
||||
[
|
||||
dict(
|
||||
model=model,
|
||||
reasoning_effort=reasoning_effort,
|
||||
expected_score=expected_score,
|
||||
)
|
||||
for reasoning_effort, expected_score in expected_score_of_reasoning_effort.items()
|
||||
],
|
||||
)
|
||||
)
|
||||
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,
|
||||
model=model,
|
||||
eval_name="gpqa",
|
||||
num_examples=198,
|
||||
# use enough threads to allow parallelism
|
||||
num_threads=198,
|
||||
# TODO 4k is still not enough, we need e.g. 64k token, but that is super slow
|
||||
# otherwise a lot of questions are not answered
|
||||
max_tokens=4096,
|
||||
# simple-evals by default use 0.5 and is better than 0.0 temperature
|
||||
# but here for reproducibility, we use 0.1
|
||||
temperature=0.1,
|
||||
reasoning_effort=reasoning_effort,
|
||||
)
|
||||
|
||||
setup = f"model={model} reasoning_effort={reasoning_effort} expected_score={expected_score}"
|
||||
|
||||
print(f"Evaluation start: {setup}")
|
||||
metrics = run_eval(args)
|
||||
print(f"Evaluation end: {setup} {metrics=}")
|
||||
self.assertGreaterEqual(metrics["score"], expected_score)
|
||||
|
||||
if is_in_ci():
|
||||
write_github_step_summary(
|
||||
f"### test_gpt_oss_common\n"
|
||||
f"Setup: {setup}\n"
|
||||
f"Score: {metrics['score']:.2f}\n"
|
||||
)
|
||||
Reference in New Issue
Block a user