test_bench_serving.py 3.88 KB
Newer Older
1
2
3
import unittest

from sglang.test.test_utils import (
4
    DEFAULT_FP8_MODEL_NAME_FOR_TEST,
5
6
    DEFAULT_MODEL_NAME_FOR_TEST,
    DEFAULT_MOE_MODEL_NAME_FOR_TEST,
7
    is_in_ci,
8
9
10
11
12
13
14
15
16
17
18
19
20
21
    run_bench_serving,
)


class TestBenchServing(unittest.TestCase):

    def test_offline_throughput_default(self):
        res = run_bench_serving(
            model=DEFAULT_MODEL_NAME_FOR_TEST,
            num_prompts=500,
            request_rate=float("inf"),
            other_server_args=[],
        )

22
        if is_in_ci():
23
            self.assertGreater(res["output_throughput"], 3350)
24
25
26
27
28
29

    def test_offline_throughput_non_stream_small_batch_size(self):
        res = run_bench_serving(
            model=DEFAULT_MODEL_NAME_FOR_TEST,
            num_prompts=200,
            request_rate=float("inf"),
30
            other_server_args=["--max-running-requests", "10"],
31
32
33
34
            dataset_name="sharegpt",
            random_input_len=None,
            random_output_len=None,
            disable_stream=True,
35
            need_warmup=True,
36
37
38
        )

        if is_in_ci():
Lianmin Zheng's avatar
Lianmin Zheng committed
39
40
41
            # There is a regression with torch 2.5
            # This number was 950 for torch 2.4
            self.assertGreater(res["output_throughput"], 800)
42
43
44
45
46
47
48
49
50

    def test_offline_throughput_without_radix_cache(self):
        res = run_bench_serving(
            model=DEFAULT_MODEL_NAME_FOR_TEST,
            num_prompts=500,
            request_rate=float("inf"),
            other_server_args=["--disable-radix-cache"],
        )

51
        if is_in_ci():
52
            self.assertGreater(res["output_throughput"], 3350)
53
54
55
56
57
58
59
60
61

    def test_offline_throughput_without_chunked_prefill(self):
        res = run_bench_serving(
            model=DEFAULT_MODEL_NAME_FOR_TEST,
            num_prompts=500,
            request_rate=float("inf"),
            other_server_args=["--chunked-prefill-size", "-1"],
        )

62
        if is_in_ci():
63
            self.assertGreater(res["output_throughput"], 2600)
64
65
66
67
68
69
70
71
72
73
74
75
76
77

    def test_offline_throughput_with_triton_attention_backend(self):
        res = run_bench_serving(
            model=DEFAULT_MODEL_NAME_FOR_TEST,
            num_prompts=500,
            request_rate=float("inf"),
            other_server_args=[
                "--attention-backend",
                "triton",
                "--context-length",
                "8192",
            ],
        )

78
        if is_in_ci():
79
            self.assertGreater(res["output_throughput"], 3450)
80

81
82
83
84
85
86
87
88
89
    def test_offline_throughput_default_fp8(self):
        res = run_bench_serving(
            model=DEFAULT_FP8_MODEL_NAME_FOR_TEST,
            num_prompts=500,
            request_rate=float("inf"),
            other_server_args=[],
        )

        if is_in_ci():
90
            self.assertGreater(res["output_throughput"], 3850)
91

92
93
94
95
96
97
98
99
    def test_online_latency_default(self):
        res = run_bench_serving(
            model=DEFAULT_MODEL_NAME_FOR_TEST,
            num_prompts=100,
            request_rate=1,
            other_server_args=[],
        )

100
        if is_in_ci():
101
            self.assertLess(res["median_e2e_latency_ms"], 12000)
102
103
            self.assertLess(res["median_ttft_ms"], 86)
            self.assertLess(res["median_itl_ms"], 10)
104
105
106
107
108
109
110
111
112

    def test_moe_offline_throughput_default(self):
        res = run_bench_serving(
            model=DEFAULT_MOE_MODEL_NAME_FOR_TEST,
            num_prompts=300,
            request_rate=float("inf"),
            other_server_args=["--tp", "2"],
        )

113
        if is_in_ci():
114
            self.assertGreater(res["output_throughput"], 2150)
115
116
117
118
119
120
121
122
123

    def test_moe_offline_throughput_without_radix_cache(self):
        res = run_bench_serving(
            model=DEFAULT_MOE_MODEL_NAME_FOR_TEST,
            num_prompts=300,
            request_rate=float("inf"),
            other_server_args=["--tp", "2", "--disable-radix-cache"],
        )

124
        if is_in_ci():
125
            self.assertGreater(res["output_throughput"], 2150)
126
127
128
129


if __name__ == "__main__":
    unittest.main()