test_chunked_prefill.py 1.75 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,
8
9
    DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
    DEFAULT_URL_FOR_TEST,
10
11
    popen_launch_server,
)
12
13


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

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

23
        model = DEFAULT_MODEL_NAME_FOR_TEST
24
        base_url = DEFAULT_URL_FOR_TEST
25
26
27
        process = popen_launch_server(
            model,
            base_url,
28
            timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
29
            other_args=other_args,
30
31
32
        )

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

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

    def test_chunked_prefill(self):
47
48
49
50
        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)
51
52

    def test_chunked_prefill_without_radix_cache(self):
53
54
55
56
        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)
57
58
59


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