sgl-project--sglang
94057c3d3e
PR Test (NPU) / check-changes (push) Has been cancelled
PR Test (NPU) / pr-gate (push) Has been cancelled
PR Test (NPU) / set-image-config (push) Has been cancelled
PR Test (NPU) / stage-b-test-1-npu-a2 (0) (push) Has been cancelled
PR Test (NPU) / stage-b-test-1-npu-a2 (1) (push) Has been cancelled
PR Test (NPU) / stage-b-test-2-npu-a2 (0) (push) Has been cancelled
PR Test (NPU) / stage-b-test-2-npu-a2 (1) (push) Has been cancelled
PR Test (NPU) / stage-b-test-4-npu-a3 (push) Has been cancelled
PR Test (NPU) / stage-b-test-16-npu-a3 (push) Has been cancelled
PR Test (NPU) / multimodal-gen-test-1-npu-a3 (push) Has been cancelled
PR Test (NPU) / multimodal-gen-test-2-npu-a3 (push) Has been cancelled
PR Test (Arm64) / pr-gate (push) Has been cancelled
PR Test (Arm64) / check-changes (push) Has been cancelled
PR Test (Arm64) / build-test (push) Has been cancelled
PR Test (sgl-router) / gate (push) Has been cancelled
PR Test (sgl-router) / tier-1 — lint (push) Has been cancelled
PR Test (sgl-router) / tier-2 — build + test (push) Has been cancelled
PR Test (sgl-router) / tier-3 — docker (placeholder) (push) Has been cancelled
PR Test (sgl-router) / tier-3 — k8s integration (push) Has been cancelled
PR Test (sgl-router) / tier-3 — e2e (push) Has been cancelled
PR Test (sgl-router) / finish (push) Has been cancelled
PR Test (NPU) / single-node-poc (map[name:qwen3_6_27b_w8a8_1p_in64k_out1k_50ms runner:linux-aarch64-a3-2 test_case:test/registered/ascend/performance/qwen3_6_27b/test_npu_qwen3_6_27b_w8a8_1p_in64k_out1k_50ms.py test_type:perf]) (push) Has been cancelled
PR Test (NPU) / pr-test-npu-finish (push) Has been cancelled
PR Test (Xeon) / pr-gate (push) Has been cancelled
PR Test (Xeon) / check-changes (push) Has been cancelled
PR Test (Xeon) / build-test (, xeon-gnr, base-b-test-cpu) (push) Has been cancelled
PR Test (XPU) / check-changes (push) Has been cancelled
PR Test (XPU) / pr-gate (push) Has been cancelled
PR Test (XPU) / stage-a-test-1-gpu-xpu (push) Has been cancelled
PR Test (XPU) / wait-for-stage-a (push) Has been cancelled
PR Test (XPU) / stage-b-test-1-gpu-xpu (push) Has been cancelled
PR Test (XPU) / finish (push) Has been cancelled
CI Model Inventory / build-inventory (push) Has been cancelled
Lint / lint (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark Compilation Check (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark - Manual Policy (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark - Request Processing (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark Summary (push) Has been cancelled
PR Test (SMG) / build-wheel (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on windows (x86_64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on macos (x86_64 - auto) (push) Has been cancelled
PR Test (SMG) / python-unit-tests (push) Has been cancelled
PR Test (SMG) / unit-tests (push) Has been cancelled
PR Test (SMG) / benchmarks (push) Has been cancelled
PR Test (SMG) / chat-completions (push) Has been cancelled
PR Test (SMG) / chat-completions-4gpu (push) Has been cancelled
PR Test (SMG) / e2e (push) Has been cancelled
PR Test (SMG) / docker-build-test (push) Has been cancelled
PR Test (SMG) / k8s-integration (push) Has been cancelled
PR Test (SMG) / finish (push) Has been cancelled
PR Test (SMG) / summarize-benchmarks (push) Has been cancelled
Release SGLang Model Gateway Docker Image / publish (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on macos (aarch64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (aarch64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (x86_64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (aarch64 - musllinux_1_1) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (x86_64 - musllinux_1_1) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / Build SDist (push) Has been cancelled
Release SGLang Model Gateway to PyPI / Upload to PyPI (push) Has been cancelled
Release SGLang Kernels / build-cu129-matrix (aarch64, 12.9, 3.10, arm-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / build-cu129-matrix (x86_64, 12.9, 3.10, x64-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / release-cu129 (push) Has been cancelled
Release SGLang Kernels / build-cu130-matrix (aarch64, 13.0, 3.10, arm-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / build-cu130-matrix (x86_64, 13.0, 3.10, x64-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / release-cu130 (push) Has been cancelled
Release SGLang Kernels / build-rocm-matrix (3.10, 700) (push) Has been cancelled
Release SGLang Kernels / build-rocm-matrix (3.10, 720) (push) Has been cancelled
Release SGLang Kernels / release-rocm700 (push) Has been cancelled
Release SGLang Kernels / release-rocm720 (push) Has been cancelled
Release SGLang Kernels / build-musa43 (43, 3.10) (push) Has been cancelled
Release SGLang Kernels / release-musa43 (push) Has been cancelled
127 行
4.7 KiB
Python
127 行
4.7 KiB
Python
"""Tests for ServerArgs CLI argument auto-derivation from A[T, Arg(...)] annotations.
|
|
|
|
Each test covers a distinct edge case in how add_cli_args_from_dataclass
|
|
translates field annotations into argparse arguments.
|
|
"""
|
|
|
|
import argparse
|
|
import unittest
|
|
|
|
from sglang.srt.server_args import ServerArgs
|
|
from sglang.test.ci.ci_register import register_cpu_ci
|
|
from sglang.test.test_utils import CustomTestCase
|
|
|
|
register_cpu_ci(est_time=10, suite="base-a-test-cpu")
|
|
|
|
|
|
class TestServerArgsAnnotatedCli(CustomTestCase):
|
|
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
cls.parser = argparse.ArgumentParser()
|
|
ServerArgs.add_cli_args(cls.parser)
|
|
|
|
def _parse(self, args_list):
|
|
args = self.parser.parse_args(["--model", "dummy"] + args_list)
|
|
return ServerArgs.from_cli_args(args)
|
|
|
|
def test_aliases_and_dest(self):
|
|
"""Field name drives dest; long forms and short aliases both work."""
|
|
cases = [
|
|
("--tp-size", "--tensor-parallel-size", "tp_size"),
|
|
("--pp-size", "--pipeline-parallel-size", "pp_size"),
|
|
("--dp-size", "--data-parallel-size", "dp_size"),
|
|
("--ep-size", "--expert-parallel-size", "ep_size"),
|
|
("--attn-cp-size", "--attention-context-parallel-size", "attn_cp_size"),
|
|
("--moe-dp-size", "--moe-data-parallel-size", "moe_dp_size"),
|
|
]
|
|
for short, long, field in cases:
|
|
with self.subTest(field=field):
|
|
sa_short = self._parse([short, "4"])
|
|
sa_long = self._parse([long, "4"])
|
|
self.assertEqual(getattr(sa_short, field), 4)
|
|
self.assertEqual(getattr(sa_long, field), 4)
|
|
|
|
def test_cli_name_differs_from_field_name(self):
|
|
"""cli_name maps a different CLI flag to the dataclass field via dest."""
|
|
sa = self._parse(
|
|
["--fp8-gemm-backend", "triton", "--fp4-gemm-backend", "cutlass"]
|
|
)
|
|
self.assertEqual(sa.fp8_gemm_runner_backend, "triton")
|
|
self.assertEqual(sa.fp4_gemm_runner_backend, "cutlass")
|
|
|
|
def test_nargs_question_with_const(self):
|
|
"""nargs='?' + const='' for --model-checksum."""
|
|
self.assertIsNone(self._parse([]).model_checksum)
|
|
self.assertEqual(self._parse(["--model-checksum"]).model_checksum, "")
|
|
self.assertEqual(self._parse(["--model-checksum", "abc"]).model_checksum, "abc")
|
|
|
|
def test_boolean_optional_action(self):
|
|
"""BooleanOptionalAction supports --flag and --no-flag."""
|
|
self.assertIsNone(self._parse([]).experts_shared_outer_loras)
|
|
self.assertTrue(
|
|
self._parse(["--experts-shared-outer-loras"]).experts_shared_outer_loras
|
|
)
|
|
self.assertFalse(
|
|
self._parse(["--no-experts-shared-outer-loras"]).experts_shared_outer_loras
|
|
)
|
|
|
|
def test_json_type_parsers(self):
|
|
"""json.loads and json_list_type parse single-string arguments."""
|
|
sa = self._parse(
|
|
[
|
|
"--extra-metric-labels",
|
|
'{"k": "v"}',
|
|
"--forward-hooks",
|
|
'[{"type": "test"}]',
|
|
]
|
|
)
|
|
self.assertEqual(sa.extra_metric_labels, {"k": "v"})
|
|
self.assertEqual(sa.forward_hooks, [{"type": "test"}])
|
|
|
|
def test_literal_auto_derives_choices(self):
|
|
"""Literal type annotations produce argparse choices automatically."""
|
|
sa = self._parse(
|
|
["--deepep-mode", "low_latency", "--elastic-ep-backend", "none"]
|
|
)
|
|
self.assertEqual(sa.deepep_mode, "low_latency")
|
|
self.assertEqual(sa.elastic_ep_backend, "none")
|
|
|
|
def test_deprecated_flags_still_work(self):
|
|
"""Deprecated flags set the correct dest field."""
|
|
sa = self._parse(["--stream-output"])
|
|
self.assertTrue(sa.incremental_streaming_output)
|
|
|
|
def test_combined_parse(self):
|
|
"""Multiple option types parsed together in one invocation."""
|
|
sa = self._parse(
|
|
[
|
|
"--dtype",
|
|
"bfloat16",
|
|
"--tp-size",
|
|
"4",
|
|
"--data-parallel-size",
|
|
"2",
|
|
"--enable-lora",
|
|
"--watchdog-timeout",
|
|
"600",
|
|
"--bucket-time-to-first-token",
|
|
"0.5",
|
|
"1.0",
|
|
"--lora-paths",
|
|
"p1",
|
|
"p2",
|
|
]
|
|
)
|
|
self.assertEqual(sa.dtype, "bfloat16")
|
|
self.assertEqual(sa.tp_size, 4)
|
|
self.assertEqual(sa.dp_size, 2)
|
|
self.assertTrue(sa.enable_lora)
|
|
self.assertEqual(sa.watchdog_timeout, 600.0)
|
|
self.assertEqual(sa.bucket_time_to_first_token, [0.5, 1.0])
|
|
self.assertIsNotNone(sa.lora_paths)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|