okami.mom/strata

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

Niko1221Merge f-pkg-nommq f1d2467b5 into the batch 19 candidate (packaging: strata_kq only where the tree has it, the Windows NVIDIA recipe; prefill sizes expert matrices from Strata's own type table)bc09a17e5

main
4.9 KiB78 linesraw
1"""OWN-1B: nothing downloads llama.cpp to build, package or install Strata.
2
3ggml (third_party/strata-ggml), strata-vision's sources (third_party/strata-llama) and gguf-py (third_party/strata-gguf-py) are vendored at the llama.cpp
4pin. This test reads the release scripts, Docker files, CI workflows and setup.py and fails when one of them fetches llama.cpp again or requires a checkout.
5The overrides (STRATA_GGML_DIR, LLAMA, GG, --llama, STRATA_GGUF_PY) stay for two releases and are allowed: they only POINT at a checkout.
6
7    python -m unittest tools.test_no_llama_download -v
8"""
9import re
10import sys
11import unittest
12from pathlib import Path
13
14ROOT = Path(__file__).resolve().parents[1]
15sys.path.insert(0, str(ROOT))
16
17SCRIPTS = ["packaging/build_cuda_linux.sh", "packaging/build_cuda_linux_aarch64.sh", "packaging/build_cuda_windows.py", "packaging/build_hip_linux.sh", "packaging/build_hip_gfx1103.sh",
18           "packaging/build_sycl_linux.sh", "packaging/build_split_cuda.sh", "packaging/build_split_hip.sh",
19           "packaging/build_vision_windows.bat", "packaging/build_vision_mac.sh",
20           "packaging/mac/build_engine.sh", "spark/build_engine.sh",
21           "tools/hip/build_windows.bat", "Dockerfile", "docker/Dockerfile", "docker/entrypoint.sh", ".github/workflows/backends.yml",
22           ".github/workflows/metal-build.yml", "metal/setup_mac.py", "sycl/setup_intel.py"]
23# a download of llama.cpp: its git remote or archive URL, setup's fetch function, the downloaded folder as a requirement
24FETCH = [r"ggml-org/llama\.cpp(\.git|/archive)", r"get_llama_cpp\s*\(", r"LLAMA_CPP_ZIP", r"FETCHCONTENT_SOURCE_DIR_STRATA_LLAMACPP"]
25REQUIRED = [r"third_party[/\\]llama\.cpp", r":\?[^}]*llama\.cpp", r"set STRATA_GGML_DIR to"]
26
27
28class NoLlamaDownload(unittest.TestCase):
29    def test_no_script_dockerfile_or_workflow_fetches_or_requires_a_llama_cpp_tree(self):
30        for rel in SCRIPTS:
31            text = (ROOT / rel).read_text(encoding="utf-8", errors="replace")
32            for pat in FETCH + REQUIRED:
33                self.assertIsNone(re.search(pat, text), f"{rel} still matches /{pat}/")
34
35    def test_setup_has_no_llama_cpp_zip_and_the_vendored_trees_are_the_defaults(self):
36        import setup
37        self.assertFalse(hasattr(setup, "LLAMA_CPP_ZIP"))
38        self.assertIsNone(setup.get_llama_cpp() if not setup.os.environ.get("STRATA_GGML_DIR") else None)
39        self.assertEqual(setup.VENDORED_LLAMA, ROOT / "third_party" / "strata-llama")
40        self.assertEqual(setup.vision_llama(None), ROOT / "third_party" / "strata-llama")
41        self.assertEqual(setup.ggml_defs(None), [])
42        for part in ("third_party/strata-ggml",):
43            self.assertIn(part, setup.ENGINE_SOURCES)
44        self.assertIn("third_party/strata-llama", setup.VISION_SOURCES)
45        self.assertIn("tools/vision", setup.VISION_SOURCES)
46
47    def test_tools_vision_takes_the_vendored_tree_by_default(self):
48        cm = (ROOT / "tools" / "vision" / "CMakeLists.txt").read_text(encoding="utf-8")
49        self.assertIn('set(LLAMA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../third_party/strata-llama"', cm)
50        tree = ROOT / "third_party" / "strata-llama"
51        for rel in ("CMakeLists.txt", "src/llama.cpp", "tools/mtmd/mtmd.cpp", "tools/mtmd/models/qwen3vl.cpp", "ggml/CMakeLists.txt", "ggml/src/ggml-backend-reg.cpp",
52                    "ggml/src/ggml-cuda/ggml-cuda.cu", "ggml/src/ggml-sycl/ggml-sycl.cpp", "ggml/src/ggml-metal/ggml-metal.cpp", "ggml/src/ggml-hip/CMakeLists.txt",
53                    "vendor/miniaudio/miniaudio.h", "vendor/stb/stb_image.h", "LICENSE"):
54            self.assertTrue((tree / rel).is_file(), rel)
55
56    def test_the_nvfp4_tools_take_the_vendored_converter(self):
57        """The NVFP4-local tools import torch and transformers (not on the test boxes), so only the wiring is checked: they compile, name no downloaded tree and
58        find the vendored converter, whose conversion/qwen4exp.py the policy hooks patch."""
59        sys.path.insert(0, str(ROOT / "tools"))
60        import _paths
61        for name in ("nvfp4_convert.py", "nvfp4_verify.py", "nvfp4_verify_gguf.py"):
62            src = (ROOT / "tools" / name).read_text(encoding="utf-8")
63            compile(src, name, "exec")
64            self.assertNotIn("llama.cpp\"", src.replace("llama.cpp's", ""), name)
65            self.assertNotIn('"third_party" / "llama.cpp"', src, name)
66        conv = Path(_paths.converter_dir())
67        self.assertEqual(conv, ROOT / "third_party" / "strata-gguf-py" / "converter")
68        src = (conv / "conversion" / "qwen4exp.py").read_text(encoding="utf-8")
69        self.assertIn("class Qwen4ExpTextModel", src)
70        self.assertIn("_place_ple_shard", src)
71
72    def test_the_terminal_and_control_carry_gguf_py_so_a_model_is_prepared_without_a_download(self):
73        pt = (ROOT / "packaging" / "package_terminal.py").read_text(encoding="utf-8")
74        self.assertIn('INSTALLER_THIRD_PARTY = ("third_party/strata-gguf-py",)', pt)
75
76
77if __name__ == "__main__":
78    unittest.main()