test_chunked_prefill.py 1.28 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
8
9
10
from sglang.test.test_utils import (
    DEFAULT_MODEL_NAME_FOR_TEST,
    DEFAULT_URL_FOR_TEST,
    popen_launch_server,
)
11
12


13
14
15
16
17
18
19
20
21
22
23
24
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
        base_url = DEFAULT_URL_FOR_TEST
        process = popen_launch_server(
            model,
            base_url,
25
            timeout=300,
26
            other_args=other_args,
27
28
29
        )

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

37
38
39
40
41
42
43
44
45
46
47
        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)
48
49
50


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