okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
c7d11f789
main
1"""#3172 #3271: the gfx906 (HIP wave64 compat) build stays buildable. The real check is a compile for gfx906 (done on a box with ROCm: the 2`strata` target links); these cover what a text check can: the pieces of CMakeLists.txt / cmake/*.cmake a 0.1.44+ gfx906 build was missing.""" 3import re 4import unittest 5from pathlib import Path 6 7ROOT = Path (__file__ ).resolve ().parents [1 ] 8# CMakeLists.txt is cut into cmake/*.cmake macros (cleanup 5.4): the text checks read all of them 9HIP_TEXT = (ROOT / "cmake" / "backends" / "hip.cmake" ).read_text (encoding = "utf-8" ).replace ("\r\n" ,"\n" ) 10TEXT = "\n" .join (p .read_text (encoding = "utf-8" ).replace ("\r\n" ,"\n" ) 11for p in [ROOT / "CMakeLists.txt" ,* sorted ((ROOT / "cmake" ).glob ("*.cmake" )),* sorted ((ROOT / "cmake" / "backends" ).glob ("*.cmake" ))]) 12 13 14class Gfx906CMake (unittest .TestCase ): 15def test_qwen35_is_not_built_for_gfx906 (self ): 16# q36_engine.cu calls cublasSgemm / cublasGemmStridedBatchedEx, which the wave64 compat layer does not map; main() guards every use 17# with STRATA_HAVE_QWEN35, so leaving the library out gives a gfx906 build that links 18block = re .search (r"if\(NOT STRATA_HIP_GFX906\)\n add_library\(strata_qwen35.*?target_compile_definitions\(strata PRIVATE STRATA_HAVE_QWEN35=1\)\n endif\(\)" ,TEXT ,re .S ) 19self .assertIsNotNone (block ) 20self .assertIn ("add_executable(strata-q36 " ,block .group (0 )) 21self .assertIn ("target_link_libraries(strata PRIVATE strata_qwen35)" ,block .group (0 )) 22 23def test_every_use_of_qwen35_in_the_engine_is_guarded (self ): 24text = (ROOT / "src" / "program" / "generate.cpp" ).read_text (encoding = "utf-8" ).replace ("\r\n" ,"\n" ) 25for match in re .finditer (r"qwen35::|strata/qwen35/engine\.hpp" ,text ): 26before = text [:match .start ()] 27self .assertGreater (before .rfind ("#if defined(STRATA_HAVE_QWEN35)" ),before .rfind ("#endif" ),match .group (0 )) 28 29def test_the_w4a4_target_gets_the_hip_definition (self ): 30self .assertRegex (TEXT ,r"if\(TARGET strata_mmq_w4a4\)\n\s+target_compile_definitions\(strata_mmq_w4a4 PRIVATE GGML_USE_HIP\)" ) 31 32def test_overlay_sources_and_the_f16_stub_are_in_the_gfx906_build (self ): 33tail = HIP_TEXT [HIP_TEXT .index ("# HIP gfx906: every CUDA source" ):] 34self .assertIn ("${_strata_tq_overlay_dir}/quantize.cu" ,tail ) 35self .assertIn ("mmq-instance-${_t}.cu" ,tail ) 36# (P4-SPLIT: in strata_pf_own, Strata's own prompt kernels, beside moe_fused_iq.cu that calls it) 37self .assertIn ("target_sources(strata_pf_own PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/prefill/moe_f16_kq.cu)" ,tail ) 38self .assertLess (tail .index ("moe_f16_kq.cu" ),tail .index ("set_source_files_properties(${_strata_cu} PROPERTIES LANGUAGE HIP)" )) 39 40 41if __name__ == "__main__" : 42unittest .main ()