okami.mom/strata

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

Niko1221Merge f-p4-split e22f397d0 into f-p4-intc7d11f789

main
1.8 KiB52 linesraw
1"""P4-SPLIT: tools/check_no_mmq.py finds llama.cpp's MMQ names in a file and passes a file without them (the bytes look; nm and
2cuobjdump are left out here, the ctest no_mmq_symbols runs them on a real -DSTRATA_MMQ=OFF build)."""
3import os
4import subprocess
5import sys
6import tempfile
7import unittest
8from pathlib import Path
9
10TOOL = Path(__file__).resolve().parent / "check_no_mmq.py"
11
12
13def run(*files):
14    return subprocess.run([sys.executable, str(TOOL), "--nm", "", "--cuobjdump", "", *files], capture_output=True, text=True)
15
16
17class CheckNoMmq(unittest.TestCase):
18    def setUp(self):
19        self.tmp = tempfile.TemporaryDirectory()
20        self.dir = self.tmp.name
21
22    def tearDown(self):
23        self.tmp.cleanup()
24
25    def write(self, name, data):
26        p = os.path.join(self.dir, name)
27        with open(p, "wb") as f:
28            f.write(data)
29        return p
30
31    def test_a_kernel_name_is_found(self):
32        p = self.write("eng", b"\x7fELF...._Z9mul_mat_qIL9ggml_type23ELi8ELb0EEvPKcPKiS4_...")
33        r = run(p)
34        self.assertEqual(r.returncode, 1, r.stdout)
35        self.assertIn("mul_mat_q x1", r.stdout)
36
37    def test_the_host_glue_is_found(self):
38        p = self.write("eng.exe", b"MZ....ggml-cuda (strata mmq): %s: %s\n....")
39        self.assertEqual(run(p).returncode, 1)
40
41    def test_strata_helpers_in_the_mmq_namespace_are_not_markers(self):
42        p = self.write("eng", b"_ZN6strata7prefill3mmq13gather_nativeEPKvS3_mS3_mPvS4_S4_S3_S4_m strata::prefill::mmq::iota prefill mmq: swiglu")
43        r = run(p)
44        self.assertEqual(r.returncode, 0, r.stdout)
45        self.assertIn("no MMQ symbol in 1 of 1 files", r.stdout)
46
47    def test_a_missing_file_is_a_usage_error(self):
48        self.assertEqual(run(os.path.join(self.dir, "nothing")).returncode, 2)
49
50
51if __name__ == "__main__":
52    unittest.main()