test_dp_attention.py 1.76 KB
Newer Older
Ke Bao's avatar
Ke Bao committed
1
2
3
import unittest
from types import SimpleNamespace

4
from sglang.srt.utils import kill_process_tree
Ke Bao's avatar
Ke Bao committed
5
6
7
8
9
from sglang.test.run_eval import run_eval
from sglang.test.test_utils import (
    DEFAULT_MLA_MODEL_NAME_FOR_TEST,
    DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
    DEFAULT_URL_FOR_TEST,
10
    CustomTestCase,
Ke Bao's avatar
Ke Bao committed
11
12
13
14
    popen_launch_server,
)


15
class TestDPAttentionDP2TP2(CustomTestCase):
Ke Bao's avatar
Ke Bao committed
16
17
18
19
20
21
22
23
24
25
26
27
28
    @classmethod
    def setUpClass(cls):
        cls.model = DEFAULT_MLA_MODEL_NAME_FOR_TEST
        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",
                "2",
                "--enable-dp-attention",
Lianmin Zheng's avatar
Lianmin Zheng committed
29
30
                "--dp",
                "2",
31
32
33
                "--enable-torch-compile",
                "--torch-compile-max-bs",
                "2",
Ke Bao's avatar
Ke Bao committed
34
35
36
37
38
            ],
        )

    @classmethod
    def tearDownClass(cls):
39
        kill_process_tree(cls.process.pid)
Ke Bao's avatar
Ke Bao committed
40
41
42
43
44
45
46
47
48
49
50

    def test_mmlu(self):
        args = SimpleNamespace(
            base_url=self.base_url,
            model=self.model,
            eval_name="mmlu",
            num_examples=64,
            num_threads=32,
        )

        metrics = run_eval(args)
Lianmin Zheng's avatar
Lianmin Zheng committed
51
52
        print(f"{metrics=}")
        self.assertGreater(metrics["score"], 0.5)
Ke Bao's avatar
Ke Bao committed
53
54
55
56
57
58
59
60
61
62
63

    def test_mgsm_en(self):
        args = SimpleNamespace(
            base_url=self.base_url,
            model=self.model,
            eval_name="mgsm_en",
            num_examples=None,
            num_threads=1024,
        )

        metrics = run_eval(args)
Lianmin Zheng's avatar
Lianmin Zheng committed
64
65
        print(f"{metrics=}")
        self.assertGreater(metrics["score"], 0.8)
66
67
68
69


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