test_disaggregation_different_tp.py 8.38 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
    DEFAULT_MODEL_NAME_FOR_TEST_MLA,
    DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
    popen_launch_pd_server,
12
    try_cached_model,
13
14
15
)


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

23
        cls.model = try_cached_model(DEFAULT_MODEL_NAME_FOR_TEST_MLA)
24

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

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

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

    @classmethod
    def start_prefill(cls):
        prefill_args = [
            "--trust-remote-code",
            "--disaggregation-mode",
            "prefill",
            "--tp",
42
            "4",
43
        ]
44
        prefill_args += cls.transfer_backend + cls.rdma_devices
45
46
47
48
49
50
51
52
53
54
55
56
57
        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",
58
59
            "--tp",
            "2",
60
61
            "--base-gpu-id",
            "4",
62
        ]
63
        decode_args += cls.transfer_backend + cls.rdma_devices
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
        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)


87
class TestDisaggregationMooncakeDecodeLargerTP(TestDisaggregationBase):
88
89
    @classmethod
    def setUpClass(cls):
90
        super().setUpClass()
91
        # Temporarily disable JIT DeepGEMM
92
        envs.SGLANG_ENABLE_JIT_DEEPGEMM.set(False)
93

94
        cls.model = try_cached_model(DEFAULT_MODEL_NAME_FOR_TEST_MLA)
95
96
97
98
99
100
101
102
103

        # 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")

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

    @classmethod
    def start_prefill(cls):
        prefill_args = [
            "--trust-remote-code",
            "--disaggregation-mode",
            "prefill",
            "--tp",
113
114
            "2",
        ]
115
        prefill_args += cls.transfer_backend + cls.rdma_devices
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
        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",
        ]
134
        decode_args += cls.transfer_backend + cls.rdma_devices
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
162
        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
163
        envs.SGLANG_ENABLE_JIT_DEEPGEMM.set(False)
164

165
        cls.model = try_cached_model(DEFAULT_MODEL_NAME_FOR_TEST)
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184

        # 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",
185
        ]
186
        prefill_args += cls.transfer_backend + cls.rdma_devices
187
188
189
190
191
192
193
194
195
196
197
198
199
        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",
200
201
202
            "--tp",
            "2",
            "--base-gpu-id",
203
204
            "4",
        ]
205
        decode_args += cls.transfer_backend + cls.rdma_devices
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
233
        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
234
        envs.SGLANG_ENABLE_JIT_DEEPGEMM.set(False)
235

236
        cls.model = try_cached_model(DEFAULT_MODEL_NAME_FOR_TEST)
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256

        # 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",
        ]
257
        prefill_args += cls.transfer_backend + cls.rdma_devices
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
        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",
275
        ]
276
        decode_args += cls.transfer_backend + cls.rdma_devices
277
278
279
280
281
282
283
284
285
286
287
288
289
290
        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,
291
292
            host=f"http://{self.base_host}",
            port=int(self.lb_port),
293
294
295
296
297
298
299
300
301
        )
        metrics = run_eval_few_shot_gsm8k(args)
        print(f"Evaluation metrics: {metrics}")

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


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