test_mooncake_ep_small.py 3.25 KB
Newer Older
1
2
3
4
5
import unittest
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
6
from sglang.test.test_disaggregation_utils import get_rdma_devices_args
7
8
9
10
11
12
13
14
from sglang.test.test_utils import (
    DEFAULT_MODEL_NAME_FOR_TEST_MLA,
    DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
    DEFAULT_URL_FOR_TEST,
    CustomTestCase,
    popen_launch_server,
)

15
ib_devices = get_rdma_devices_args()
16
17
18


class TestTP(CustomTestCase):
19
    extra_args = []
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

    @classmethod
    def setUpClass(cls):
        cls.model = DEFAULT_MODEL_NAME_FOR_TEST_MLA
        cls.base_url = DEFAULT_URL_FOR_TEST
        cls.process = popen_launch_server(
            cls.model,
            cls.base_url,
            timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
            other_args=[
                "--trust-remote-code",
                "--tp",
                "4",
                "--elastic-ep-backend",
                "mooncake",
                "--mooncake-ib-device",
36
                ib_devices,
37
38
39
40
41
42
43
                "--moe-a2a-backend",
                "deepep",
                "--deepep-mode",
                "low_latency",
                "--chunked-prefill-size",
                "512",
                "--cuda-graph-max-bs",
44
                "128",
45
46
                "--max-running-requests",
                "512",
47
48
49
                "--mem-fraction-static",
                "0.5",
                *cls.extra_args,
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
            ],
        )

    @classmethod
    def tearDownClass(cls):
        kill_process_tree(cls.process.pid)

    def test_gsm8k(self):
        args = SimpleNamespace(
            num_shots=5,
            data_path=None,
            num_questions=200,
            max_new_tokens=512,
            parallel=128,
            host="http://127.0.0.1",
            port=int(self.base_url.split(":")[-1]),
        )
        metrics = run_eval_few_shot_gsm8k(args)
        print(metrics)

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


73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
class TestPureDP(TestTP):
    extra_args = [
        "--tp",
        "4",
        "--enable-dp-attention",
        "--dp",
        "4",
    ]


class TestHybridDPTP(TestTP):
    extra_args = [
        "--tp",
        "4",
        "--enable-dp-attention",
        "--dp",
        "2",
    ]


class TestNoGatherdBuffer(TestTP):
    extra_args = [
        "--tp",
        "4",
        "--enable-dp-attention",
        "--dp",
        "4",
        "--moe-dense-tp-size",
        "1",
    ]


class TestTBO(TestTP):
    extra_args = [
        "--tp",
        "4",
        "--enable-dp-attention",
        "--dp",
        "4",
        "--moe-dense-tp-size",
        "1",
        "--enable-two-batch-overlap",
    ]


class TestMooncakeWitchEPLB(TestTP):
    extra_args = [
        "--tp",
        "4",
        "--enable-dp-attention",
        "--dp",
        "4",
        "--moe-dense-tp-size",
        "1",
        "--enable-two-batch-overlap",
        "--enable-eplb",
        "--ep-num-redundant-experts",
        "4",
        "--eplb-rebalance-num-iterations",
        "50",
        "--expert-distribution-recorder-buffer-size",
        "50",
        "--expert-distribution-recorder-mode",
        "stat",
        "--ep-dispatch-algorithm",
        "static",
    ]
140
141
142
143


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