test_hicache.py 1.32 KB
Newer Older
1
2
3
import unittest
from types import SimpleNamespace

4
from sglang.srt.utils import is_hip, kill_process_tree
5
6
from sglang.test.run_eval import run_eval
from sglang.test.test_utils import (
7
    DEFAULT_MODEL_NAME_FOR_TEST,
8
9
    DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
    DEFAULT_URL_FOR_TEST,
10
    CustomTestCase,
11
12
13
    popen_launch_server,
)

14
15
_is_hip = is_hip()

16

17
class TestHiCache(CustomTestCase):
18
19
    @classmethod
    def setUpClass(cls):
20
        cls.model = DEFAULT_MODEL_NAME_FOR_TEST
21
22
23
24
25
        cls.base_url = DEFAULT_URL_FOR_TEST
        cls.process = popen_launch_server(
            cls.model,
            cls.base_url,
            timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
26
27
            other_args=[
                "--enable-hierarchical-cache",
Zhiqiang Xie's avatar
Zhiqiang Xie committed
28
29
30
                "--mem-fraction-static",
                0.7,
                "--hicache-size",
31
                100 if not _is_hip else 200,
32
            ],
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
        )

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

    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)
49
        self.assertGreaterEqual(metrics["score"], 0.65)
50
51
52
53


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