test_chunked_prefill.py 1.69 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
class TestChunkedPrefill(unittest.TestCase):
14
    def run_mmlu(self, disable_radix_cache, enable_mixed_chunk):
15
16
17
18
        other_args = ["--chunked-prefill-size", "32"]
        if disable_radix_cache:
            other_args += ["--disable-radix-cache"]

19
20
21
        if enable_mixed_chunk:
            other_args += ["--enable-mixed-chunk"]

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

        args = SimpleNamespace(
32
33
            base_url=base_url,
            model=model,
34
            eval_name="mmlu",
35
36
            num_examples=32,
            num_threads=32,
37
38
        )

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

    def test_chunked_prefill(self):
46
47
48
49
        self.run_mmlu(disable_radix_cache=False, enable_mixed_chunk=False)

    def test_mixed_chunked_prefill(self):
        self.run_mmlu(disable_radix_cache=False, enable_mixed_chunk=True)
50
51

    def test_chunked_prefill_without_radix_cache(self):
52
53
54
55
        self.run_mmlu(disable_radix_cache=True, enable_mixed_chunk=False)

    def test_mixed_chunked_prefill_without_radix_cache(self):
        self.run_mmlu(disable_radix_cache=True, enable_mixed_chunk=True)
56
57
58


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