From 543d62d11a54756e0e310e10dc2a1b8e7ecd43bf Mon Sep 17 00:00:00 2001 From: Liangsheng Yin Date: Thu, 11 Dec 2025 22:30:33 +0900 Subject: [PATCH] Introduce `server_fixtures` in `sglang.test` (#14899) --- .../disaggregation_fixture.py} | 2 +- test/manual/ep/test_mooncake_ep_small.py | 2 +- test/manual/hicache/test_disaggregation_hicache.py | 6 ++++-- .../test_disaggregation_piecewise_cuda_graph.py | 6 ++++-- test/srt/test_disaggregation_basic.py | 12 +++++++----- test/srt/test_disaggregation_different_tp.py | 12 +++++++----- test/srt/test_disaggregation_dp_attention.py | 6 ++++-- test/srt/test_disaggregation_hybrid_attention.py | 6 ++++-- test/srt/test_disaggregation_pp.py | 6 ++++-- 9 files changed, 36 insertions(+), 22 deletions(-) rename python/sglang/test/{test_disaggregation_utils.py => server_fixtures/disaggregation_fixture.py} (99%) diff --git a/python/sglang/test/test_disaggregation_utils.py b/python/sglang/test/server_fixtures/disaggregation_fixture.py similarity index 99% rename from python/sglang/test/test_disaggregation_utils.py rename to python/sglang/test/server_fixtures/disaggregation_fixture.py index e4396170f..d5d8a6143 100644 --- a/python/sglang/test/test_disaggregation_utils.py +++ b/python/sglang/test/server_fixtures/disaggregation_fixture.py @@ -19,7 +19,7 @@ from sglang.test.test_utils import ( logger = logging.getLogger(__name__) -class TestDisaggregationBase(CustomTestCase): +class PDDisaggregationServerBase(CustomTestCase): @classmethod def setUpClass(cls): parsed_url = urlparse(DEFAULT_URL_FOR_TEST) diff --git a/test/manual/ep/test_mooncake_ep_small.py b/test/manual/ep/test_mooncake_ep_small.py index 391cdc4c6..6e680041d 100644 --- a/test/manual/ep/test_mooncake_ep_small.py +++ b/test/manual/ep/test_mooncake_ep_small.py @@ -3,7 +3,7 @@ from types import SimpleNamespace from sglang.srt.utils import kill_process_tree from sglang.test.few_shot_gsm8k import run_eval as run_eval_few_shot_gsm8k -from sglang.test.test_disaggregation_utils import get_rdma_devices_args +from sglang.test.server_fixtures.disaggregation_fixture import get_rdma_devices_args from sglang.test.test_utils import ( DEFAULT_MODEL_NAME_FOR_TEST_MLA, DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH, diff --git a/test/manual/hicache/test_disaggregation_hicache.py b/test/manual/hicache/test_disaggregation_hicache.py index 6f9c6a3c2..651dfd7eb 100644 --- a/test/manual/hicache/test_disaggregation_hicache.py +++ b/test/manual/hicache/test_disaggregation_hicache.py @@ -8,7 +8,9 @@ from typing import Dict import requests from sglang.bench_serving import get_tokenizer -from sglang.test.test_disaggregation_utils import TestDisaggregationBase +from sglang.test.server_fixtures.disaggregation_fixture import ( + PDDisaggregationServerBase, +) from sglang.test.test_utils import ( DEFAULT_MODEL_NAME_FOR_TEST, DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH, @@ -16,7 +18,7 @@ from sglang.test.test_utils import ( ) -class DisaggregationHiCacheBase(TestDisaggregationBase): +class DisaggregationHiCacheBase(PDDisaggregationServerBase): """Base class for disaggregation with HiCache tests""" @classmethod diff --git a/test/manual/piecewise_cudagraph/test_disaggregation_piecewise_cuda_graph.py b/test/manual/piecewise_cudagraph/test_disaggregation_piecewise_cuda_graph.py index cc75cb9d3..a54a97846 100644 --- a/test/manual/piecewise_cudagraph/test_disaggregation_piecewise_cuda_graph.py +++ b/test/manual/piecewise_cudagraph/test_disaggregation_piecewise_cuda_graph.py @@ -2,7 +2,9 @@ import unittest from types import SimpleNamespace from sglang.test.few_shot_gsm8k import run_eval as run_eval_few_shot_gsm8k -from sglang.test.test_disaggregation_utils import TestDisaggregationBase +from sglang.test.server_fixtures.disaggregation_fixture import ( + PDDisaggregationServerBase, +) from sglang.test.test_utils import ( DEFAULT_MODEL_NAME_FOR_TEST, DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH, @@ -10,7 +12,7 @@ from sglang.test.test_utils import ( ) -class TestDisaggregationPiecewiseCudaGraph(TestDisaggregationBase): +class TestDisaggregationPiecewiseCudaGraph(PDDisaggregationServerBase): """Test piecewise CUDA graph support in disaggregation prefill server""" @classmethod diff --git a/test/srt/test_disaggregation_basic.py b/test/srt/test_disaggregation_basic.py index 5d2ee1477..2e94a739f 100644 --- a/test/srt/test_disaggregation_basic.py +++ b/test/srt/test_disaggregation_basic.py @@ -8,7 +8,9 @@ import requests from transformers import AutoTokenizer from sglang.test.few_shot_gsm8k import run_eval as run_eval_few_shot_gsm8k -from sglang.test.test_disaggregation_utils import TestDisaggregationBase +from sglang.test.server_fixtures.disaggregation_fixture import ( + PDDisaggregationServerBase, +) from sglang.test.test_utils import ( DEFAULT_EAGLE_DRAFT_MODEL_FOR_TEST, DEFAULT_EAGLE_TARGET_MODEL_FOR_TEST, @@ -18,7 +20,7 @@ from sglang.test.test_utils import ( ) -class TestDisaggregationAccuracy(TestDisaggregationBase): +class TestDisaggregationAccuracy(PDDisaggregationServerBase): @classmethod def setUpClass(cls): super().setUpClass() @@ -185,7 +187,7 @@ class TestDisaggregationAccuracy(TestDisaggregationBase): ) -class TestDisaggregationMooncakeFailure(TestDisaggregationBase): +class TestDisaggregationMooncakeFailure(PDDisaggregationServerBase): @classmethod def setUpClass(cls): super().setUpClass() @@ -273,7 +275,7 @@ class TestDisaggregationMooncakeFailure(TestDisaggregationBase): raise e from health_check_error -class TestDisaggregationMooncakeSpec(TestDisaggregationBase): +class TestDisaggregationMooncakeSpec(PDDisaggregationServerBase): @classmethod def setUpClass(cls): @@ -358,7 +360,7 @@ class TestDisaggregationMooncakeSpec(TestDisaggregationBase): self.assertGreater(metrics["accuracy"], 0.20) -class TestDisaggregationSimulatedRetract(TestDisaggregationBase): +class TestDisaggregationSimulatedRetract(PDDisaggregationServerBase): @classmethod def setUpClass(cls): super().setUpClass() diff --git a/test/srt/test_disaggregation_different_tp.py b/test/srt/test_disaggregation_different_tp.py index 2cb058422..e8a26b558 100644 --- a/test/srt/test_disaggregation_different_tp.py +++ b/test/srt/test_disaggregation_different_tp.py @@ -3,7 +3,9 @@ from types import SimpleNamespace from sglang.srt.environ import envs from sglang.test.few_shot_gsm8k import run_eval as run_eval_few_shot_gsm8k -from sglang.test.test_disaggregation_utils import TestDisaggregationBase +from sglang.test.server_fixtures.disaggregation_fixture import ( + PDDisaggregationServerBase, +) from sglang.test.test_utils import ( DEFAULT_MODEL_NAME_FOR_TEST, DEFAULT_MODEL_NAME_FOR_TEST_MLA, @@ -13,7 +15,7 @@ from sglang.test.test_utils import ( ) -class TestDisaggregationMooncakePrefillLargerTP(TestDisaggregationBase): +class TestDisaggregationMooncakePrefillLargerTP(PDDisaggregationServerBase): @classmethod def setUpClass(cls): super().setUpClass() @@ -84,7 +86,7 @@ class TestDisaggregationMooncakePrefillLargerTP(TestDisaggregationBase): self.assertGreater(metrics["accuracy"], 0.60) -class TestDisaggregationMooncakeDecodeLargerTP(TestDisaggregationBase): +class TestDisaggregationMooncakeDecodeLargerTP(PDDisaggregationServerBase): @classmethod def setUpClass(cls): super().setUpClass() @@ -155,7 +157,7 @@ class TestDisaggregationMooncakeDecodeLargerTP(TestDisaggregationBase): self.assertGreater(metrics["accuracy"], 0.60) -class TestDisaggregationMooncakeMHAPrefillLargerTP(TestDisaggregationBase): +class TestDisaggregationMooncakeMHAPrefillLargerTP(PDDisaggregationServerBase): @classmethod def setUpClass(cls): super().setUpClass() @@ -226,7 +228,7 @@ class TestDisaggregationMooncakeMHAPrefillLargerTP(TestDisaggregationBase): self.assertGreater(metrics["accuracy"], 0.60) -class TestDisaggregationMooncakeMHADecodeLargerTP(TestDisaggregationBase): +class TestDisaggregationMooncakeMHADecodeLargerTP(PDDisaggregationServerBase): @classmethod def setUpClass(cls): super().setUpClass() diff --git a/test/srt/test_disaggregation_dp_attention.py b/test/srt/test_disaggregation_dp_attention.py index f1f02ad60..9025fcd51 100644 --- a/test/srt/test_disaggregation_dp_attention.py +++ b/test/srt/test_disaggregation_dp_attention.py @@ -3,7 +3,9 @@ from types import SimpleNamespace from sglang.srt.environ import envs from sglang.test.few_shot_gsm8k import run_eval as run_eval_few_shot_gsm8k -from sglang.test.test_disaggregation_utils import TestDisaggregationBase +from sglang.test.server_fixtures.disaggregation_fixture import ( + PDDisaggregationServerBase, +) from sglang.test.test_utils import ( DEFAULT_MODEL_NAME_FOR_TEST_MLA, DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH, @@ -12,7 +14,7 @@ from sglang.test.test_utils import ( ) -class TestDisaggregationDPAttention(TestDisaggregationBase): +class TestDisaggregationDPAttention(PDDisaggregationServerBase): PREFILL_DP_SIZE = 4 DECODE_DP_SIZE = 4 diff --git a/test/srt/test_disaggregation_hybrid_attention.py b/test/srt/test_disaggregation_hybrid_attention.py index 83ebed93f..792a6df05 100644 --- a/test/srt/test_disaggregation_hybrid_attention.py +++ b/test/srt/test_disaggregation_hybrid_attention.py @@ -2,14 +2,16 @@ import unittest from types import SimpleNamespace from sglang.test.few_shot_gsm8k import run_eval as run_eval_few_shot_gsm8k -from sglang.test.test_disaggregation_utils import TestDisaggregationBase +from sglang.test.server_fixtures.disaggregation_fixture import ( + PDDisaggregationServerBase, +) from sglang.test.test_utils import ( DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH, popen_launch_pd_server, ) -class TestDisaggregationHybridAttentionMamba(TestDisaggregationBase): +class TestDisaggregationHybridAttentionMamba(PDDisaggregationServerBase): @classmethod def setUpClass(cls): super().setUpClass() diff --git a/test/srt/test_disaggregation_pp.py b/test/srt/test_disaggregation_pp.py index 29df8b070..0a1fb4e8c 100644 --- a/test/srt/test_disaggregation_pp.py +++ b/test/srt/test_disaggregation_pp.py @@ -3,7 +3,9 @@ import unittest from types import SimpleNamespace from sglang.test.few_shot_gsm8k import run_eval -from sglang.test.test_disaggregation_utils import TestDisaggregationBase +from sglang.test.server_fixtures.disaggregation_fixture import ( + PDDisaggregationServerBase, +) from sglang.test.test_utils import ( DEFAULT_MODEL_NAME_FOR_TEST, DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH, @@ -12,7 +14,7 @@ from sglang.test.test_utils import ( ) -class TestDisaggregationPPAccuracy(TestDisaggregationBase): +class TestDisaggregationPPAccuracy(PDDisaggregationServerBase): @classmethod def setUpClass(cls): super().setUpClass()