okami.mom/strata

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

Niko1221Merge f-strix-c4 00807c9b3 into f-p4-int (with two or more requests at once on Windows integrated AMD, the pinned RAM copy of experts is capped so every slot fits)47d46ccce

main
2.9 KiB61 linesraw
1"""A Strix Halo start with --batch N that ended with the engine's own line "N requests at once do not fit in this PC's memory": the Terminal's sentence
2must name the way out in the words of the app and the Terminal (Concurrent requests / --parallel), not the generic "run it again" and not the shared-memory
3advice about the expert cache. Nothing here starts an engine."""
4from __future__ import annotations
5
6import json
7import unittest
8from pathlib import Path
9
10from strata_cli.launch import runner as R
11from tests.terminal.launch_support import Home
12
13ENGINE_LINE = "strata: 4 requests at once do not fit in this PC's memory: start with --batch 3"
14STEP = ("This PC's memory cannot hold that many requests at once. Lower Concurrent requests in the app (or `--parallel` in the Terminal) "
15        "by one and start again.")
16FAILED = {"state": "failed", "error": "server_exited", "engine_exit_code": 1}
17
18
19class BatchMemoryWords(unittest.TestCase):
20    def config(self, home: Home, log_lines: list[str], args: list[str] | None = None) -> Path:
21        log = home.base / "engine.log"
22        log.write_text("\n".join(log_lines) + "\n", encoding="utf-8")
23        path = home.base / "run.json"
24        path.write_text(json.dumps({"exe": "e", "args": args or [], "log": str(log)}), encoding="utf-8")
25        return path
26
27    def test_the_step_says_to_lower_the_concurrent_requests(self):
28        with Home() as h:
29            cfg = self.config(h, ["strata serve: prefill: copy stream", ENGINE_LINE])
30            text, nxt = R.explain_engine_exit(FAILED, cfg)
31        self.assertIn(ENGINE_LINE, text)
32        self.assertTrue(nxt.startswith(STEP), nxt)
33        self.assertNotIn("Run it again", nxt)
34
35    def test_the_step_beats_the_shared_memory_advice_on_a_strix_halo(self):
36        args = ["--expert-cache", "8000", "--resident-budget-gib", "38"]
37        with Home() as h:
38            other = self.config(h, ["strata serve: something odd"], args)
39            _, control = R.explain_engine_exit(FAILED, other, shared_memory=True)
40            self.assertIn("shares its memory with the RAM", control)        # the control: this config does get the advice for another failure
41            cfg = self.config(h, [ENGINE_LINE], args)
42            _, nxt = R.explain_engine_exit(FAILED, cfg, shared_memory=True)
43        self.assertTrue(nxt.startswith(STEP), nxt)
44        self.assertNotIn("shares its memory with the RAM", nxt)
45
46    def test_another_failure_keeps_its_own_step(self):
47        with Home() as h:
48            cfg = self.config(h, ["strata serve: something odd"])
49            _, nxt = R.explain_engine_exit(FAILED, cfg)
50        self.assertTrue(nxt.startswith("Run it again; if it repeats, report the log."), nxt)
51
52    def test_the_new_cause_is_the_last_entry(self):
53        self.assertIn("requests at once do not fit", KNOWN_PATTERN_LAST())
54
55
56def KNOWN_PATTERN_LAST() -> str:
57    return R.KNOWN_CAUSES[-1][0].pattern
58
59
60if __name__ == "__main__":
61    unittest.main()