test_disaggregation_different_tp.py 8.29 KB
Newer Older
1
2
3
import unittest
from types import SimpleNamespace

4
from sglang.srt.environ import envs
5
from sglang.test.few_shot_gsm8k import run_eval as run_eval_few_shot_gsm8k
6
from sglang.test.test_disaggregation_utils import TestDisaggregationBase
7
from sglang.test.test_utils import (
8
    DEFAULT_MODEL_NAME_FOR_TEST,
9
10
11
12
13
14
    DEFAULT_MODEL_NAME_FOR_TEST_MLA,
    DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
    popen_launch_pd_server,
)


15
class TestDisaggregationMooncakePrefillLargerTP(TestDisaggregationBase):
16
17
    @classmethod
    def setUpClass(cls):
18
        super().setUpClass()
19
        # Temporarily disable JIT DeepGEMM
20
        envs.SGLANG_ENABLE_JIT_DEEPGEMM.set(False)
21
22
23

        cls.model = DEFAULT_MODEL_NAME_FOR_TEST_MLA

24
25
26
        # Non blocking start servers
        cls.start_prefill()
        cls.start_decode()
27

28
        # Block until both
29
30
31
        cls.wait_server_ready(cls.prefill_url + "/health")
        cls.wait_server_ready(cls.decode_url + "/health")

32
        cls.launch_lb()
33
34
35
36
37
38
39
40

    @classmethod
    def start_prefill(cls):
        prefill_args = [
            "--trust-remote-code",
            "--disaggregation-mode",
            "prefill",
            "--tp",
41
            "4",
42
        ]
43
        prefill_args += cls.transfer_backend + cls.rdma_devices
44
45
46
47
48
49
50
51
52
53
54
55
56
        cls.process_prefill = popen_launch_pd_server(
            cls.model,
            cls.prefill_url,
            timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
            other_args=prefill_args,
        )

    @classmethod
    def start_decode(cls):
        decode_args = [
            "--trust-remote-code",
            "--disaggregation-mode",
            "decode",
57
58
            "--tp",
            "2",
59
60
            "--base-gpu-id",
            "4",
61
        ]
62
        decode_args += cls.transfer_backend + cls.rdma_devices
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
        cls.process_decode = popen_launch_pd_server(
            cls.model,
            cls.decode_url,
            timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
            other_args=decode_args,
        )

    def test_gsm8k(self):
        args = SimpleNamespace(
            num_shots=5,
            data_path=None,
            num_questions=200,
            max_new_tokens=512,
            parallel=128,
            host=f"http://{self.base_host}",
            port=int(self.lb_port),
        )
        metrics = run_eval_few_shot_gsm8k(args)
        print(f"Evaluation metrics: {metrics}")

        self.assertGreater(metrics["accuracy"], 0.60)


86
class TestDisaggregationMooncakeDecodeLargerTP(TestDisaggregationBase):
87
88
    @classmethod
    def setUpClass(cls):
89
        super().setUpClass()
90
        # Temporarily disable JIT DeepGEMM
91
        envs.SGLANG_ENABLE_JIT_DEEPGEMM.set(False)
92
93
94
95
96
97
98
99
100
101
102

        cls.model = DEFAULT_MODEL_NAME_FOR_TEST_MLA

        # Non blocking start servers
        cls.start_prefill()
        cls.start_decode()

        # Block until both
        cls.wait_server_ready(cls.prefill_url + "/health")
        cls.wait_server_ready(cls.decode_url + "/health")

103
        cls.launch_lb()
104
105
106
107
108
109
110
111

    @classmethod
    def start_prefill(cls):
        prefill_args = [
            "--trust-remote-code",
            "--disaggregation-mode",
            "prefill",
            "--tp",
112
113
            "2",
        ]
114
        prefill_args += cls.transfer_backend + cls.rdma_devices
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
        cls.process_prefill = popen_launch_pd_server(
            cls.model,
            cls.prefill_url,
            timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
            other_args=prefill_args,
        )

    @classmethod
    def start_decode(cls):
        decode_args = [
            "--trust-remote-code",
            "--disaggregation-mode",
            "decode",
            "--tp",
            "4",
            "--base-gpu-id",
            "4",
        ]
133
        decode_args += cls.transfer_backend + cls.rdma_devices
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
        cls.process_decode = popen_launch_pd_server(
            cls.model,
            cls.decode_url,
            timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
            other_args=decode_args,
        )

    def test_gsm8k(self):
        args = SimpleNamespace(
            num_shots=5,
            data_path=None,
            num_questions=200,
            max_new_tokens=512,
            parallel=128,
            host=f"http://{self.base_host}",
            port=int(self.lb_port),
        )
        metrics = run_eval_few_shot_gsm8k(args)
        print(f"Evaluation metrics: {metrics}")

        self.assertGreater(metrics["accuracy"], 0.60)


class TestDisaggregationMooncakeMHAPrefillLargerTP(TestDisaggregationBase):
    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        # Temporarily disable JIT DeepGEMM
162
        envs.SGLANG_ENABLE_JIT_DEEPGEMM.set(False)
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183

        cls.model = DEFAULT_MODEL_NAME_FOR_TEST

        # Non blocking start servers
        cls.start_prefill()
        cls.start_decode()

        # Block until both
        cls.wait_server_ready(cls.prefill_url + "/health")
        cls.wait_server_ready(cls.decode_url + "/health")

        cls.launch_lb()

    @classmethod
    def start_prefill(cls):
        prefill_args = [
            "--trust-remote-code",
            "--disaggregation-mode",
            "prefill",
            "--tp",
            "4",
184
        ]
185
        prefill_args += cls.transfer_backend + cls.rdma_devices
186
187
188
189
190
191
192
193
194
195
196
197
198
        cls.process_prefill = popen_launch_pd_server(
            cls.model,
            cls.prefill_url,
            timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
            other_args=prefill_args,
        )

    @classmethod
    def start_decode(cls):
        decode_args = [
            "--trust-remote-code",
            "--disaggregation-mode",
            "decode",
199
200
201
            "--tp",
            "2",
            "--base-gpu-id",
202
203
            "4",
        ]
204
        decode_args += cls.transfer_backend + cls.rdma_devices
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
        cls.process_decode = popen_launch_pd_server(
            cls.model,
            cls.decode_url,
            timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
            other_args=decode_args,
        )

    def test_gsm8k(self):
        args = SimpleNamespace(
            num_shots=5,
            data_path=None,
            num_questions=200,
            max_new_tokens=512,
            parallel=128,
            host=f"http://{self.base_host}",
            port=int(self.lb_port),
        )
        metrics = run_eval_few_shot_gsm8k(args)
        print(f"Evaluation metrics: {metrics}")

        self.assertGreater(metrics["accuracy"], 0.60)


class TestDisaggregationMooncakeMHADecodeLargerTP(TestDisaggregationBase):
    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        # Temporarily disable JIT DeepGEMM
233
        envs.SGLANG_ENABLE_JIT_DEEPGEMM.set(False)
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255

        cls.model = DEFAULT_MODEL_NAME_FOR_TEST

        # Non blocking start servers
        cls.start_prefill()
        cls.start_decode()

        # Block until both
        cls.wait_server_ready(cls.prefill_url + "/health")
        cls.wait_server_ready(cls.decode_url + "/health")

        cls.launch_lb()

    @classmethod
    def start_prefill(cls):
        prefill_args = [
            "--trust-remote-code",
            "--disaggregation-mode",
            "prefill",
            "--tp",
            "2",
        ]
256
        prefill_args += cls.transfer_backend + cls.rdma_devices
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
        cls.process_prefill = popen_launch_pd_server(
            cls.model,
            cls.prefill_url,
            timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
            other_args=prefill_args,
        )

    @classmethod
    def start_decode(cls):
        decode_args = [
            "--trust-remote-code",
            "--disaggregation-mode",
            "decode",
            "--tp",
            "4",
            "--base-gpu-id",
            "4",
274
        ]
275
        decode_args += cls.transfer_backend + cls.rdma_devices
276
277
278
279
280
281
282
283
284
285
286
287
288
289
        cls.process_decode = popen_launch_pd_server(
            cls.model,
            cls.decode_url,
            timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
            other_args=decode_args,
        )

    def test_gsm8k(self):
        args = SimpleNamespace(
            num_shots=5,
            data_path=None,
            num_questions=200,
            max_new_tokens=512,
            parallel=128,
290
291
            host=f"http://{self.base_host}",
            port=int(self.lb_port),
292
293
294
295
296
297
298
299
300
        )
        metrics = run_eval_few_shot_gsm8k(args)
        print(f"Evaluation metrics: {metrics}")

        self.assertGreater(metrics["accuracy"], 0.60)


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