test_chunked_prefill.py 1.29 KB
Newer Older
1
2
3
4
5
import unittest
from types import SimpleNamespace

from sglang.srt.utils import kill_child_process
from sglang.test.run_eval import run_eval
6
7
from sglang.test.test_utils import (
    DEFAULT_MODEL_NAME_FOR_TEST,
Yineng Zhang's avatar
Yineng Zhang committed
8
    DEFAULT_URL_FOR_UNIT_TEST,
9
10
    popen_launch_server,
)
11
12


13
14
15
16
17
18
19
class TestChunkedPrefill(unittest.TestCase):
    def run_mmlu(self, disable_radix_cache):
        other_args = ["--chunked-prefill-size", "32"]
        if disable_radix_cache:
            other_args += ["--disable-radix-cache"]

        model = DEFAULT_MODEL_NAME_FOR_TEST
Yineng Zhang's avatar
Yineng Zhang committed
20
        base_url = DEFAULT_URL_FOR_UNIT_TEST
21
22
23
        process = popen_launch_server(
            model,
            base_url,
24
            timeout=300,
25
            other_args=other_args,
26
27
28
        )

        args = SimpleNamespace(
29
30
            base_url=base_url,
            model=model,
31
            eval_name="mmlu",
32
33
            num_examples=32,
            num_threads=32,
34
35
        )

36
37
38
39
40
41
42
43
44
45
46
        try:
            metrics = run_eval(args)
            assert metrics["score"] >= 0.6
        finally:
            kill_child_process(process.pid)

    def test_chunked_prefill(self):
        self.run_mmlu(disable_radix_cache=False)

    def test_chunked_prefill_without_radix_cache(self):
        self.run_mmlu(disable_radix_cache=True)
47
48
49


if __name__ == "__main__":
Lianmin Zheng's avatar
Lianmin Zheng committed
50
    unittest.main()