okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
c7d11f789
main
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 ): 14return subprocess .run ([sys .executable ,str (TOOL ),"--nm" ,"" ,"--cuobjdump" ,"" ,* files ],capture_output = True ,text = True ) 15 16 17class CheckNoMmq (unittest .TestCase ): 18def setUp (self ): 19self .tmp = tempfile .TemporaryDirectory () 20self .dir = self .tmp .name 21 22def tearDown (self ): 23self .tmp .cleanup () 24 25def write (self ,name ,data ): 26p = os .path .join (self .dir ,name ) 27with open (p ,"wb" )as f : 28f .write (data ) 29return p 30 31def test_a_kernel_name_is_found (self ): 32p = self .write ("eng" ,b"\x7fELF...._Z9mul_mat_qIL9ggml_type23ELi8ELb0EEvPKcPKiS4_..." ) 33r = run (p ) 34self .assertEqual (r .returncode ,1 ,r .stdout ) 35self .assertIn ("mul_mat_q x1" ,r .stdout ) 36 37def test_the_host_glue_is_found (self ): 38p = self .write ("eng.exe" ,b"MZ....ggml-cuda (strata mmq): %s: %s\n...." ) 39self .assertEqual (run (p ).returncode ,1 ) 40 41def test_strata_helpers_in_the_mmq_namespace_are_not_markers (self ): 42p = self .write ("eng" ,b"_ZN6strata7prefill3mmq13gather_nativeEPKvS3_mS3_mPvS4_S4_S3_S4_m strata::prefill::mmq::iota prefill mmq: swiglu" ) 43r = run (p ) 44self .assertEqual (r .returncode ,0 ,r .stdout ) 45self .assertIn ("no MMQ symbol in 1 of 1 files" ,r .stdout ) 46 47def test_a_missing_file_is_a_usage_error (self ): 48self .assertEqual (run (os .path .join (self .dir ,"nothing" )).returncode ,2 ) 49 50 51if __name__ == "__main__" : 52unittest .main ()