okami.mom/strata

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

Niko1221Merge f-qwen36 into f-144-rel (geometry: #2179's read_geometry guard kept for qwen4exp, Qwen3.6's family guard on top)4cfeaa0f4

main
2.6 KiB71 linesraw
1"""tools/strata_inspect.py's verdict, offline: the fingerprints of the files setup installs (data/gguf_fingerprints.json)
2stand in for headers read from the network.
3
4    python -m unittest tools.test_strata_inspect
5"""
6from __future__ import annotations
7
8import copy
9import sys
10import unittest
11from pathlib import Path
12
13ROOT = Path(__file__).resolve().parents[1]
14sys.path.insert(0, str(ROOT / "tools"))
15import strata_inspect as SI  # noqa: E402
16
17
18class Verdict(unittest.TestCase):
19    @classmethod
20    def setUpClass(cls):
21        cls.table = SI.load_fingerprints()
22
23    def fp(self, key):
24        return copy.deepcopy({k: v for k, v in self.table[key].items() if k not in ("files", "repo")})
25
26    def test_every_installed_file_is_known(self):
27        for key in (k for k in self.table if not k.startswith("_")):
28            kind, sentence = SI.verdict(self.fp(key), self.table)
29            fam, model = key.split("/")
30            self.assertEqual(kind, "known", key)
31            self.assertIn(f"--family {fam} --model {model}", sentence)
32
33    def test_same_layout_other_file(self):
34        fp = self.fp("qwen/Q2_0")
35        fp["bytes"] += 1234                                  # a fine-tune with the same recipe
36        kind, sentence = SI.verdict(fp, self.table)
37        self.assertEqual(kind, "layout")
38        self.assertIn("qwen/Q2_0", sentence)
39
40    def test_other_architecture(self):
41        fp = self.fp("qwen/Q2_0")
42        fp["arch"] = "qwen3moe"
43        self.assertEqual(SI.verdict(fp, self.table)[0], "no")
44
45    def test_qwen36_runs_on_its_own_path(self):
46        fp = self.fp("qwen/Q2_0")
47        fp["arch"] = "qwen35moe"
48        kind, sentence = SI.verdict(fp, self.table)
49        self.assertEqual(kind, "family")
50        self.assertIn("Qwen3.6-35B-A3B", sentence)
51        self.assertIn("--family qwen36", sentence)
52
53    def test_expert_type_without_kernel(self):
54        fp = self.fp("qwen/IQ3_S")
55        fp["expert_bytes"] = {"IQ1_S": 30_000_000_000}
56        kind, sentence = SI.verdict(fp, self.table)
57        self.assertEqual(kind, "no")
58        self.assertIn("IQ1_S", sentence)
59
60    def test_untested_names_the_new_tensors(self):   # Unsloth UD-Q2_K_XL's case: known expert types, a new head type
61        fp = self.fp("qwen/IQ3_XXS")
62        fp["expert_bytes"] = {"IQ2_XS": 1, "IQ3_XXS": 2, "IQ4_NL": 3}
63        fp["roles"] = {"output.weight": ["Q4_K"], "token_embd.weight": ["Q3_K"]}
64        kind, sentence = SI.verdict(fp, self.table)
65        self.assertEqual(kind, "untested")
66        self.assertIn("output.weight Q4_K", sentence)
67        self.assertNotIn("token_embd", sentence)
68
69
70if __name__ == "__main__":
71    unittest.main()