okami.mom/strata

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

Niko1221Merge f-0213-fixux (82d3a0345): user screenshots - a data folder on an external drive under /run/media is no longer refused as a system folder (real system folders still are; the doubled sentence is gone); one fit label everywhere (owner 11-08): 'fits' when the model files without the n-gram/PLE/Engram table fit graphics memory plus RAM, else 'may run slower' (the Unsloth sets were measured against RAM only; DeepSeek Needs shows the whole size; no-card PCs and small Macs say 'may run slower'; NVFP4-QAD sized by its 76.8 GB pack)b7bcbcde9

main
7.2 KiB122 linesraw
1"""The Gyro entries of setup's catalog (agentionai/Qwen3.8-Flash-Next-Gyro-GGUF): sizes, pins, the VRAM + RAM memory rule,
2never a default, and the MCP server's recommendation naming them only where nothing else fits.  Offline."""
3import pathlib
4import sys
5import unittest
6
7ROOT = pathlib.Path(__file__).resolve().parent.parent
8sys.path.insert(0, str(ROOT))
9sys.path.insert(0, str(ROOT / "tools"))
10import setup  # noqa: E402
11import strata_mcp as M  # noqa: E402
12
13
14def hardware(ram, vram):
15    return {"ram_gb": ram, "gpus": [{"usable": True, "vram_gb": vram, "vendor": "nvidia", "index": 0, "name": "RTX"}],
16            "cpu": {"avx2": True}}
17
18
19class GyroCatalog(unittest.TestCase):
20    def test_the_two_sizes_and_their_numbers(self):
21        self.assertEqual(setup.FAMILIES["gyro"]["file"].format(q="Gyro-S"), "Qwen3.8-Flash-Next-Gyro-S.gguf")
22        for model, name, download, memory in (("Gyro-S", "Qwen3.8-Flash-Next-Gyro-S-TQ1_0.gguf", 58.5, 27.6),
23                                              ("Gyro-M", "Qwen3.8-Flash-Next-Gyro-M-TQ2_0.gguf", 92.0, 35.0)):
24            d = setup.MODELS[model]
25            self.assertEqual(setup.model_file(setup.FAMILIES["gyro"], model, 1), name)
26            self.assertEqual((d["download_gb"], d["ram_gb"]), (download, memory))
27            size, sha = setup.GYRO_FILES[name]
28            self.assertAlmostEqual(size / 1e9, download, delta=0.05)
29            self.assertEqual(len(sha), 64)
30            self.assertEqual(setup.model_shards(setup.FAMILIES["gyro"], model), 1)
31            self.assertIs(d.get("vision"), True)
32            self.assertTrue(d["mem_total"])
33            self.assertEqual(d["families"], ("gyro",))
34
35    def test_pinned_revision_and_license(self):
36        repo = "agentionai/Qwen3.8-Flash-Next-Gyro-GGUF"
37        self.assertEqual(len(setup.HF_REVISIONS[repo]), 40)
38        self.assertIn(setup.HF_REVISIONS[repo], setup.FAMILIES["gyro"]["hf"])
39        self.assertIn("Qwen Community License 1.0", setup.FAMILIES["gyro"]["license"])
40
41    def test_never_the_default_family(self):
42        self.assertEqual(setup.menu_families(False)[0], "qwen")
43        self.assertNotIn("gyro", setup.RECOMMENDED_SIZES)
44
45    def test_memory_is_vram_plus_ram(self):
46        self.assertEqual(setup.mem_have("Gyro-S", 16.0, 12.0), 28.0)
47        self.assertEqual(setup.mem_have("Q2_0", 16.0, 12.0), 16.0)
48        names = ["Gyro-S", "Gyro-M"]
49        self.assertEqual(setup.recommended_size("gyro", names, 24.0, 12.0), "Gyro-M")     # 36 GB
50        self.assertEqual(setup.recommended_size("gyro", names, 16.0, 12.0), "Gyro-S")     # 28 GB
51        self.assertEqual(setup.recommended_size("gyro", names, 8.0, 8.0), "Gyro-S")       # nothing fits: the first
52
53    def test_mcp_table_matches(self):
54        for m in ("Gyro-S", "Gyro-M"):
55            for k in ("download_gb", "ram_gb", "arena_gb", "mem_total", "vision", "engine"):
56                self.assertEqual(setup.MODELS[m][k], M.FALLBACK_MODELS[m][k], (m, k))
57        self.assertEqual(setup.FAMILIES["gyro"]["tag"], M.FALLBACK_FAMILIES["gyro"]["tag"])
58
59    def test_mcp_recommends_gyro_only_where_nothing_else_fits(self):
60        s = M.Strata(ROOT)
61        for ram, vram, family in ((64.0, 12.0, "qwen"), (48.0, 12.0, "qwen"), (32.0, 12.0, "swift"), (28.0, 8.0, "coder")):
62            self.assertEqual(s.recommend(hardware(ram, vram))["family"], family, (ram, vram))
63        got = s.recommend(hardware(20.0, 12.0))                  # 32 GB in total, the Coder's 32 GB of RAM missing
64        self.assertEqual((got["family"], got["model"]), ("gyro", "Gyro-S"))
65        got = s.recommend(hardware(28.0, 16.0))                  # 44 GB in total, 39 after the 5 GB for the system (#3425): the owner's 40 GB tier, Swift 1.5's IQ2_XS
66        self.assertEqual((got["family"], got["model"]), ("swift", "IQ2_XS"))
67        self.assertIn("Gyro-M", got["why"])                      # named as the other choice (NVIDIA, AMD and Intel Arc)
68        intel = hardware(28.0, 16.0)
69        intel["gpus"] = [{**g, "vendor": "intel"} for g in intel["gpus"]]
70        self.assertIn("Gyro-M", s.recommend(intel)["why"])       # the SYCL engine has the trellis kernels (0.2.2)
71        self.assertIsNone(s.recommend(hardware(12.0, 8.0))["family"])
72        self.assertIsNone(s.recommend(hardware(16.0, 11.0))["family"])   # 27 GB: below Gyro-S's 27.6 + room
73
74    def test_mcp_table_verdict_counts_vram(self):
75        s = M.Strata(ROOT)
76        fam = next(f for f in s.model_table(hardware(16.0, 16.0)) if f["family"] == "gyro")
77        by = {x["model"]: x for x in fam["sizes"]}
78        self.assertEqual(by["Gyro-S"]["on_this_pc"], "fits")
79        self.assertEqual(by["Gyro-M"]["on_this_pc"], "may run slower")           # 35 GB of VRAM + RAM together, this PC has 32
80        self.assertTrue(by["Gyro-S"]["images"])
81
82    def test_mcp_table_gives_ram_plus_vram_without_the_ngram_table(self):
83        """The Models page shows what a version needs of RAM + VRAM together, the n-gram table (on the SSD) not counted."""
84        s = M.Strata(ROOT)
85        table = s.model_table(hardware(64.0, 12.0))
86        gyro = {x["model"]: x for x in next(f for f in table if f["family"] == "gyro")["sizes"]}
87        self.assertEqual(gyro["Gyro-S"]["memory_gb"], 27.6)           # stated in total (mem_total), not the 58.5 GB download
88        self.assertTrue(gyro["Gyro-S"]["mem_total"])
89        swift = {x["model"]: x for x in next(f for f in table if f["family"] == "swift")["sizes"]}
90        self.assertEqual(swift["IQ2_XS"]["memory_gb"], 36.5)          # 35.5 GB of experts + ~1 GB dense
91        self.assertFalse(swift["IQ2_XS"]["mem_total"])
92
93
94class GyroEngineVersionTest(unittest.TestCase):
95    """Gyro's expert files are native_experts.txt v5 (Hadamard-folded). The released 0.1.45 engine reads only up to v4, so the
96    minimum is 0.1.45.1, the first engine package built after the v5 reader (APR port, f47b0385f) was merged."""
97
98    def test_gyro_needs_an_engine_that_reads_v5_files(self):
99        self.assertEqual(setup.GYRO_ENGINE, (0, 1, 45, 1))
100        self.assertGreater(setup.GYRO_ENGINE, (0, 1, 45))            # the released 0.1.45 is not enough
101        sizes = [m for m in setup.MODELS.values() if "gyro" in str(m.get("file", "")).lower()]
102        self.assertEqual(len(sizes), 2)
103        self.assertTrue(all(m["engine"] == (0, 1, 45, 1) for m in sizes))
104
105    def test_every_catalog_agrees(self):
106        for m in ("Gyro-S", "Gyro-M"):
107            self.assertEqual(setup.MODELS[m]["engine"], M.FALLBACK_MODELS[m]["engine"], m)
108
109    def test_the_catalog_tells_the_app_the_minimum(self):
110        table = M.Strata(ROOT).model_table(hardware(64.0, 12.0))
111        gyro = {x["model"]: x for x in next(f for f in table if f["family"] == "gyro")["sizes"]}
112        self.assertEqual({k: v["engine_min"] for k, v in gyro.items()}, {"Gyro-S": "0.1.45.1", "Gyro-M": "0.1.45.1"})
113        qwen = {x["model"]: x for x in next(f for f in table if f["family"] == "qwen")["sizes"]}
114        self.assertIsNone(qwen["Q2_0"]["engine_min"])                # a size with no minimum of its own says so
115
116    def test_the_pack_reader_is_in_the_source_this_minimum_describes(self):
117        text = (ROOT / "src" / "kernels" / "cpu" / "expert_layout.cpp").read_text(encoding="utf-8")
118        self.assertIn("native_experts.txt v5 declares Hadamard-folded experts", text)
119
120
121if __name__ == "__main__":
122    unittest.main()