okami.mom/strata

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

Niko1221Merge f-0213-p8merge (b5f5e38a4): the Qwen4 rehearsal's fixes - F1-F5 (make_model_release schema, mmproj KeyError, drafter: none honoured, neutral expert profile for another shape with the owner's line, budget for feed qwen4exp sizes), STRATA_CMAKE_EXTRA in the Linux packaging scripts, G14 plan line, G12 release plan, G10/G3 docs, and G2: a real-file feed-model install gate in tools/check (tools/feed_model_install_gate.py; fails if any of F2-F5 is reverted); version bump left for the release candidateb82a36810

main
2.1 KiB46 linesraw
1"""A feed model of another shape than the shipped expert profile gets a neutral profile (found by the Q4-P8 rehearsal: the engine refused the shipped 48x512 one for a 4x256 model)."""
2import struct
3import sys
4import tempfile
5import unittest
6from pathlib import Path
7
8ROOT = Path(__file__).resolve().parents[1]
9sys.path.insert(0, str(ROOT))
10from strata_control import setup_config  # noqa: E402
11
12
13class Fake:
14    def __init__(self, layers, experts):
15        self.metadata = {"qwen4exp.block_count": layers, "qwen4exp.expert_count": experts, "general.name": "x"}
16
17    def __call__(self, path):
18        return self
19
20
21class NeutralProfile(unittest.TestCase):
22    def test_the_shipped_shape_keeps_the_shipped_profile(self):
23        shipped = ROOT / "data" / "expert-profile.bin"
24        with tempfile.TemporaryDirectory() as d:
25            self.assertEqual(setup_config.neutral_profile_if_other_shape(shipped, "x.gguf", d, Fake(48, 512)), shipped)
26            self.assertEqual(list(Path(d).iterdir()), [])
27
28    def test_another_shape_gets_every_pair_once_in_the_engines_format(self):
29        shipped = ROOT / "data" / "expert-profile.bin"
30        with tempfile.TemporaryDirectory() as d:
31            said = []
32            out = setup_config.neutral_profile_if_other_shape(shipped, "x.gguf", d, Fake(4, 256), said.append)
33            self.assertEqual(out.name, "expert-profile-4x256.bin")
34            blob = out.read_bytes()
35            self.assertEqual(blob[:4], b"STRP")
36            ver, nl, ne, slots, n = struct.unpack_from("<5I", blob, 4)
37            self.assertEqual((ver, nl, ne, slots, n), (1, 4, 256, 1024, 1024))
38            pairs = [struct.unpack_from("<HH", blob, 24 + 4 * i) for i in range(n)]
39            self.assertEqual(len(set(pairs)), 1024)
40            self.assertEqual(pairs[:5], [(0, 0), (1, 0), (2, 0), (3, 0), (0, 1)])          # interleaved across the layers
41            self.assertEqual(len(blob), 24 + 4 * n + 4 * nl * ne)
42            self.assertEqual(said, ["  This model's shape differs from Flash-Next, so a neutral expert profile is used."])      # the owner's wording
43
44
45if __name__ == "__main__":
46    unittest.main()