okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge main c1ff07f1a into f-own-intfefaa985c

main
3.4 KiB62 linesraw
1"""serve/test_q36_config.py - what the server hands the Qwen3.6-35B-A3B engine (arch qwen35moe): the config's pictures
2("vision" section -> --vision) and parallel requests ("parallel": N -> --batch N), as for Flash-Next's engine.
3
4    python -m unittest serve.test_q36_config
5"""
6from __future__ import annotations
7
8import unittest
9from unittest import mock
10
11from serve.server import engine_args, parallel_args
12
13
14def cfg(**kw):
15    base = {"arch": "qwen35moe", "exe": "strata", "args": ["--native", "/m/Qwen3.6-35B-A3B-UD-Q4_K_XL.gguf",
16                                                           "--max-context", "32768", "--prefill", "auto", "--mtp", "2"]}
17    base.update(kw)
18    return base
19
20
21class Q36Config(unittest.TestCase):
22    def test_parallel_becomes_batch(self):
23        a = engine_args(cfg(parallel=4))
24        self.assertEqual(a[a.index("--batch") + 1], "4")
25        self.assertNotIn("--batch", engine_args(cfg()))
26        self.assertNotIn("--batch", engine_args(cfg(parallel=1)))
27
28    def test_more_than_the_window_is_said(self):
29        with mock.patch("builtins.print") as pr:
30            a = engine_args(cfg(parallel=12))
31        self.assertEqual(a[a.index("--batch") + 1], "12")          # the engine caps it at 8 and says so
32        self.assertTrue(any("at most 8" in str(c) for c in pr.call_args_list))
33
34    def test_a_vision_section_starts_the_engine_with_pictures(self):
35        v = {"exe": "strata-vision", "mmproj": "/m/mmproj-F16.gguf", "model": "/m/Qwen3.6-35B-A3B-UD-Q4_K_XL.gguf",
36             "gpu": False, "max_tokens": 300}
37        self.assertIn("--vision", engine_args(cfg(vision=v)))
38        self.assertIn("--vision", engine_args(cfg(vision=v, args=cfg()["args"] + ["--vision"])))
39        self.assertEqual(engine_args(cfg(vision=v, args=cfg()["args"] + ["--vision"])).count("--vision"), 1)
40        self.assertNotIn("--vision", engine_args(cfg()))
41
42    def test_a_context_the_card_cannot_hold_is_said_before_the_start(self):
43        # #5715: RTX 5070 12 GB (12227 MiB), UD-Q4_K_XL; the start goes on with the context as written
44        big = cfg(model_name="qwen3.6-35b-a3b-ud-q4_k_xl", args=["--native", "/m/Qwen3.6-35B-A3B-UD-Q4_K_XL.gguf", "--max-context", "131072"])
45        for c, vram, said in ((big, 12227.0, True), (cfg(model_name="qwen3.6-35b-a3b-ud-q4_k_xl"), 12227.0, False),
46                              (big, 16311.0, False), (big, None, False), ({**big, "model_name": "qwen3.8-flash-next-iq3_s"}, 12227.0, False)):
47            with mock.patch("serve.server.drafting_vram_mib", lambda *a, _v=vram: _v), mock.patch("builtins.print") as pr:
48                a = engine_args(c)
49            lines = [str(x) for x in pr.call_args_list if "will probably not start" in str(x)]
50            self.assertEqual(len(lines), 1 if said else 0, (c.get("model_name"), vram))
51            self.assertEqual(a[a.index("--max-context") + 1], c["args"][c["args"].index("--max-context") + 1])
52            if said:
53                self.assertIn("[strata] At 128K, this model's conversation memory needs about 5.8 GB of graphics memory. With the model itself that "
54                              "is more than this card's 12 GB, so it will probably not start. 32K fits on this card: choose 32K or less.", lines[0])
55
56    def test_an_explicit_batch_in_the_args_wins(self):
57        c = cfg(parallel=4, args=cfg()["args"] + ["--batch", "2"])
58        self.assertEqual(parallel_args(c, c["args"]), [])
59
60
61if __name__ == "__main__":
62    unittest.main()