okami.mom/strata

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

Niko1221Merge f-ds-out ac306afb2 into f-own-intaff3a132f

main
4.2 KiB81 linesraw
1"""Round 0214: Unsloth's v3.1 Qwen3.8-Flash-Next sets in the Terminal's model names (UD-IQ1_M: the Unsloth set, bare or with --family unsloth)."""
2from __future__ import annotations
3
4import unittest
5from unittest import mock
6
7from strata_cli.launch.catalog import Catalog
8from tests.terminal.launch_support import HW_12, Home, catalog
9
10PC = {**HW_12, "ram_gb": 64.0, "disk_free_gb": 900.0, "engine_vendor": "nvidia"}
11
12
13class Names(unittest.TestCase):
14    def setUp(self):
15        self.home = Home().__enter__()
16        self.addCleanup(self.home.__exit__, None, None, None)
17        p = mock.patch.object(Catalog, "hardware", lambda s, fresh=False: dict(PC))
18        p.start()
19        self.addCleanup(p.stop)
20
21    def test_the_new_names_resolve_to_the_unsloth_family(self):
22        cat = catalog(PC)
23        for m in ("UD-Q2_0", "UD-IQ2_XS", "UD-Q2_K_XL", "UD-IQ3_XXS", "UD-Q3_K_XL", "UD-IQ4_XS-v31"):
24            self.assertEqual(cat.resolve(m.lower()), ("unsloth", m))
25        self.assertEqual(cat.resolve("ud-iq4_xs"), ("unsloth", "UD-IQ4_XS"))
26
27    def test_ud_iq1_m_is_the_unsloth_set(self):
28        cat = catalog(PC)
29        self.assertEqual(cat.resolve("ud-iq1_m"), ("unsloth", "UD-IQ1_M"))
30        self.assertEqual(cat.resolve("ud-iq1_m", "unsloth"), ("unsloth", "UD-IQ1_M"))
31
32
33if __name__ == "__main__":
34    unittest.main()
35
36
37class AdoptUnsloth(unittest.TestCase):
38    """ENG-AMD (round 0214): `strata launch` refused every Unsloth set on an Intel Arc card because adopt.FAMILIES lacked "unsloth"."""
39
40    def _plan(self, tmp, model, hub, n, backend="sycl", family="unsloth"):
41        from pathlib import Path
42        from strata_cli.launch import adopt
43        d = Path(tmp) / "data"
44        m = d / "models" / f"unsloth-{model}"
45        m.mkdir(parents=True)
46        for i in range(1, n + 1):
47            (m / f"Qwen3.8-Flash-Next-{hub}-{i:05d}-of-{n:05d}.gguf").write_bytes(b"GGUF")
48        pack = d / "packs" / f"unsloth-{model.lower()}"
49        (pack / "tokenizer").mkdir(parents=True)
50        (pack / "experts.bin").write_bytes(b"x")
51        src = Path(__file__).resolve().parents[2]
52        cfg, problems = adopt.plan(family=family, model=model, model_dir=m, data_dir=d, src=src, context=32768, kv=None,
53                                   model_name="qwen3.8-flash-next-unsloth-" + model.lower(), family_def={}, log=Path(tmp) / "x.log",
54                                   backend=backend, pack_name=f"unsloth-{model.lower()}")
55        return cfg, problems
56
57    def test_every_new_set_is_written_for_an_arc_card(self):
58        import tempfile
59        from unittest import mock
60        from strata_cli.launch import adopt
61        self.assertIn("unsloth", adopt.FAMILIES)
62        for model, hub, n in (("UD-IQ1_M", "UD-IQ1_M", 3), ("UD-Q2_0", "UD-Q2_0", 3), ("UD-IQ2_XS", "UD-IQ2_XS", 3), ("UD-Q2_K_XL", "UD-Q2_K_XL", 4),
63                              ("UD-IQ3_XXS", "UD-IQ3_XXS", 4), ("UD-Q3_K_XL", "UD-Q3_K_XL", 4), ("UD-IQ4_XS-v31", "UD-IQ4_XS", 4), ("UD-Q4_K_XL", "UD-Q4_K_XL", 4)):
64            with self.subTest(model=model), tempfile.TemporaryDirectory() as t, mock.patch.object(adopt, "intel_driver", return_value="i915"):
65                cfg, problems = self._plan(t, model, hub, n)
66                self.assertEqual(problems, [])
67                a = cfg["args"]
68                self.assertTrue(a[a.index("--native") + 1].endswith(f"{hub}-00001-of-{n:05d}.gguf"))
69                self.assertNotIn("--ple-gguf", a)            # the engine finds the n-gram table by its tensor name (setup.py writes no --ple-gguf for 3+ shards)
70                self.assertEqual(cfg["backend"], "sycl")
71
72    def test_the_other_families_still_pass_the_table_shard(self):
73        import tempfile
74        from strata_cli.launch import adopt
75        with tempfile.TemporaryDirectory() as t:
76            cfg, problems = self._plan(t, "IQ3_XXS", "GSQ-RCO-IQ3_XXS", 2, family="qwen")
77            self.assertEqual(problems, [])
78            self.assertIn("--ple-gguf", cfg["args"])
79        with tempfile.TemporaryDirectory() as t:
80            self.assertEqual(adopt.plan(family="deepseek41", model="x", model_dir=t, data_dir=t, src=t, context=1, kv=None, model_name="x",
81                                        family_def={}, log=t, backend="sycl")[0], None)