okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
a98e6c551
main
1# Strata Engine - top-level build. 2# 3# One project builds the engine for every backend: CUDA (STRATA_ENABLE_CUDA), HIP (STRATA_ENABLE_HIP; the layer-split 4# engine is the STRATA_BUILD_SPLIT option), the CPU-only build, and the test 5# programs. The Intel Arc (SYCL) engine is a separate project in sycl/ (STRATA_ENABLE_SYCL), and the Metal engine 6# one in metal/. CMakePresets.json has the CPU check preset (`cmake --preset cpu-check`) and the compile-only 7# backend presets used by tools/check and the CI workflows; the release scripts in packaging/ pass their own flags. 8# 9# The CUDA kernels need sm_80 or newer (tf32 mma, bf16 math) and the guard below refuses anything older: silently 10# building for a pre-Ampere arch would produce a binary that runs and is wrong about its own performance, which is 11# the worst of both outcomes. 12cmake_minimum_required ( VERSION 3.24 ) 13project ( strata VERSION 0.1.61 LANGUAGES CXX ) 14include ( $ { CMAKE_CURRENT_SOURCE_DIR } /cmake/strata_geometry.cmake ) # -DSTRATA_GEOMETRY=<name>: the model shape the kernels are compiled for (default flash_next, no flag added) 15# The build is cut by backend (cleanup 5.4): each file below only DEFINES macros (strata_<part>()), which run here, in this scope, at the place their 16# block used to be - so this file reads in the order the old single CMakeLists.txt evaluated. 17include ( $ { CMAKE_CURRENT_SOURCE_DIR } /cmake/strata_ggml.cmake ) # which ggml: the vendored third_party/strata-ggml, or -DSTRATA_GGML_DIR 18include ( $ { CMAKE_CURRENT_SOURCE_DIR } /cmake/backends/cpu.cmake ) # strata_kernels_cpu, the native (ggml-cpu) expert rows, the CPU tests 19include ( $ { CMAKE_CURRENT_SOURCE_DIR } /cmake/backends/quant.cmake ) # strata_quant: the Strata quant layer (no ggml) and its oracle tests 20include ( $ { CMAKE_CURRENT_SOURCE_DIR } /cmake/backends/cuda.cmake ) # NVIDIA: toolchain, llama.cpp's MMQ kernels (strata_mmq, strata_kq) 21include ( $ { CMAKE_CURRENT_SOURCE_DIR } /cmake/backends/hip.cmake ) # AMD: gfx906 compat, MMQ on HIP 22include ( $ { CMAKE_CURRENT_SOURCE_DIR } /cmake/strata_gpu_engine.cmake ) # the GPU engine both of them build 23# EXPERIMENTAL: the Intel Arc engine, the SYCL port in sycl/ (PR #423; icpx + oneMKL, docs/INTEL_ARC.md). It is its 24# own project that takes the unported sources from src/; with this on, nothing below is configured. 25option ( STRATA_ENABLE_SYCL "EXPERIMENTAL: build the Intel Arc (SYCL) engine from sycl/ - docs/INTEL_ARC.md" OFF ) 26if ( STRATA_ENABLE_SYCL) 27if ( STRATA_ENABLE_CUDAOR STRATA_ENABLE_HIP) 28message ( FATAL_ERROR "STRATA_ENABLE_SYCL is a separate backend; leave STRATA_ENABLE_CUDA and STRATA_ENABLE_HIP off" ) 29endif () 30message ( WARNING "STRATA_ENABLE_SYCL: the Intel Arc engine is experimental (community port, docs/INTEL_ARC.md)" ) 31add_subdirectory ( sycl ) 32return () 33endif () 34add_compile_definitions ( STRATA_VERSION= " ${ PROJECT_VERSION } " ) 35# issue #31: release builds keep a PDB beside the exe (not shipped in it), so a minidump from a stalled engine can 36# be read back to the exact source line 37if ( MSVCAND CMAKE_BUILD_TYPESTREQUAL "Release" ) 38add_compile_options ( $< $ <COMPILE_LANGUAGE:CXX>:/Zi> ) 39add_link_options ( /DEBUG /OPT:REF /OPT:ICF ) 40endif () 41 42# The prebuilt release (setup.py downloads it, so users need no compiler): ggml's CPU backend for any AVX2 CPU 43# instead of this machine's (Strata's own AVX-512 kernels are per-file and chosen at run time either way), and 44# the MSVC runtime linked in, so no Visual C++ redistributable is needed. 45option ( STRATA_PORTABLE "build for other PCs: AVX2 baseline, static MSVC runtime" OFF ) 46# EXPERIMENTAL, opt-in: an engine for CPUs without AVX2 (#394, #595, #623), compiled on that PC. ggml-cpu, which then 47# computes every CPU expert row, is built for this floor instead of AVX2 or the build host: "avx" (Sandy/Ivy Bridge: 48# AVX, no FMA/F16C/AVX2) or "none" (SSE4.2 + POPCNT: Nehalem/Westmere). Strata's own AVX2/AVX-512 kernels stay in the 49# binary behind their CPU checks; the router lookahead gets an AVX1 kernel. Empty (the default) changes nothing. 50set ( STRATA_ISA_FLOOR "" CACHE STRING "experimental older-CPU build: empty (default, AVX2 floor), avx, or none (SSE4.2)" ) 51set_property ( CACHE STRATA_ISA_FLOOR PROPERTY STRINGS "" avx none ) 52if ( NOT STRATA_ISA_FLOORSTREQUAL "" AND NOT STRATA_ISA_FLOORSTREQUAL "avx" AND NOT STRATA_ISA_FLOORSTREQUAL "none" ) 53message ( FATAL_ERROR "STRATA_ISA_FLOOR must be empty, avx or none (got ' ${ STRATA_ISA_FLOOR } ')" ) 54endif () 55if ( STRATA_ISA_FLOORAND STRATA_PORTABLE) 56message ( FATAL_ERROR "STRATA_ISA_FLOOR (an older-CPU build) and STRATA_PORTABLE (the AVX2 release build) exclude each other" ) 57endif () 58if ( STRATA_PORTABLEAND MSVC) 59set ( CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded" ) 60endif () 61 62# #3202: Windows hands a program its command line in the system's ANSI code page (cp1251 / cp866 on a Russian Windows, cp1252 on an 63# English one), but the engine reads every path as UTF-8 (the run configs and the server write UTF-8). A model folder with 64# Cyrillic letters arrived as other bytes, or as "?" where the page has no such letter, and the model did not open. This manifest 65# makes the process's ANSI code page UTF-8 (Windows 10 1903 and newer; older Windows ignores it and nothing changes), so the 66# command line, fopen and std::ifstream all take UTF-8. 67function ( strata_utf8_manifest target ) 68if ( MSVC) 69target_sources ( $ { target } PRIVATE ${ CMAKE_CURRENT_FUNCTION_LIST_DIR } /cmake/strata-utf8.manifest ) 70endif () 71endfunction () 72 73# The AVX kernels exist for x86 only. On aarch64 (DGX Spark / GB10) portable.cpp stands in for them and 74# native experts run on ggml-cpu's NEON dot products. 75# 76# Windows builds on an ARM64 CPU (the case this was added for): CMake can run under x64 emulation and report the PROCESSOR as 77# AMD64, and an unset processor is read as x86 below, so the processor string alone is not enough there and the 78# x86 kernel sources were pulled into an aarch64 build (kq_avx1.cpp failed on <immintrin.h>). Ask the compiler 79# what it targets instead; STRATA_FORCE_ARM64 overrides the answer for a shell that misdetects the host. On x86 80# and on arm64 Linux both tests give the same answer as before, so those configurations are unchanged. 81option ( STRATA_FORCE_ARM64 "force the aarch64 CPU path (portable.cpp) when the emulated shell misdetects the host as x86" OFF ) 82include ( CheckCXXSourceCompiles ) 83set ( STRATA_QUIET_SAVE " ${ CMAKE_REQUIRED_QUIET } " ) 84set ( CMAKE_REQUIRED_QUIET ON ) 85check_cxx_source_compiles ( " 86#if !defined(_M_ARM64) && !defined(__aarch64__) 87#error not aarch64 88#endif 89int main() { return 0; }" STRATA_COMPILER_TARGET_ARM64 ) 90set ( CMAKE_REQUIRED_QUIET " ${ STRATA_QUIET_SAVE } " ) 91if ( STRATA_FORCE_ARM64OR STRATA_COMPILER_TARGET_ARM64) 92set ( STRATA_CPU_X86 OFF ) 93elseif ( NOT CMAKE_SYSTEM_PROCESSOROR CMAKE_SYSTEM_PROCESSORMATCHES "^(x86_64|AMD64|amd64|x64|X64|i[3-6]86|x86|X86) $ " ) # an unset processor stays the x86 build, as before 94set ( STRATA_CPU_X86 ON ) 95else () 96set ( STRATA_CPU_X86 OFF ) 97endif () 98# The sources' _MSC_VER branches assume x86 (intrin.h, _xgetbv, cpuid): in Arm64 builds on Windows clang-cl defines both 99# _MSC_VER and __aarch64__, so the define lets the portable path skip them. Not set on x86. 100if ( NOT STRATA_CPU_X86) 101add_compile_definitions ( STRATA_CPU_ARM64=1 ) 102endif () 103if ( STRATA_ISA_FLOORAND NOT STRATA_CPU_X86) 104message ( WARNING "STRATA_ISA_FLOOR is an x86 older-CPU build and does not apply to ${ CMAKE_SYSTEM_PROCESSOR } ; ignored" ) 105set ( STRATA_ISA_FLOOR "" CACHE STRING "" FORCE ) 106endif () 107set ( CMAKE_CXX_STANDARD 20 ) 108set ( CMAKE_CXX_STANDARD_REQUIRED ON ) 109set ( CMAKE_CXX_EXTENSIONS OFF ) 110if ( NOT CMAKE_BUILD_TYPEAND NOT CMAKE_CONFIGURATION_TYPES) 111set ( CMAKE_BUILD_TYPE Release CACHE STRING "" FORCE ) 112endif () 113 114option ( STRATA_ENABLE_CUDA "Build the CUDA targets (Phase 2+)" OFF ) 115# AMD gfx906 (MI50, wave64): the same .cu sources compiled as HIP through the gfx906 compat layer. The CUDA runtime and 116# cuBLAS names are mapped by the headers in include/strata/platform/hip_compat/, which go first on the include path, 117# and CUDA::cudart / CUDA::cublas become aliases of HIP's targets, so every CUDA target below stays as it is. This is 118# separate from STRATA_ENABLE_HIP (the wave32 RDNA backend): with it on, STRATA_ENABLE_CUDA is on and 119# STRATA_ENABLE_HIP stays off, so every "CUDA" branch of the tree is the one taken. 120option ( STRATA_HIP_GFX906 "Build the CUDA targets for AMD gfx906 through HIP (wave64 compat layer)" OFF ) 121if ( STRATA_HIP_GFX906) 122if ( STRATA_ENABLE_HIP) 123message ( FATAL_ERROR "STRATA_HIP_GFX906 and STRATA_ENABLE_HIP are separate backends; enable only one" ) 124endif () 125set ( STRATA_ENABLE_CUDA ON CACHE BOOL "" FORCE ) 126endif () 127option ( STRATA_ENABLE_HIP "Build the HIP targets for wave32 AMD GPUs (gfx1100, gfx1201; gfx1012/gfx1030 unvalidated)" OFF ) 128option ( STRATA_PREFILL_MMQ "Build the optional GGML MMQ prefill path for HIP (only together with STRATA_MMQ=ON)" OFF ) 129# P4-SPLIT: llama.cpp's MMQ prompt kernels (strata_mmq, strata_mmq_w4a4, strata_kq) are built only with -DSTRATA_MMQ=ON: on CUDA, and on HIP 130# together with STRATA_PREFILL_MMQ=ON. The default (OFF) leaves them out of both. Strata's own prompt kernels (strata_pf_own: the fused experts 131# and their helpers) are built either way; without MMQ the prompt path takes them where they cover a layer and the FP16 path elsewhere. A name 132# of its own rather than STRATA_PREFILL_MMQ for CUDA: every CUDA build folder configured before has STRATA_PREFILL_MMQ=OFF in its cache. 133# A build folder configured before the default changed keeps STRATA_MMQ=ON in its cache: setup and the packaging scripts pass the value. 134# -DSTRATA_MMQ=ON builds the old path (for A/B runs). 135option ( STRATA_MMQ "Build llama.cpp's MMQ prompt kernels (CUDA; HIP together with STRATA_PREFILL_MMQ)" OFF ) 136# The community-made AMD changes (include/strata/core/amd_community.hpp): on by default. This option is the build half of the one 137# switch STRATA_AMD_COMMUNITY_TUNING: OFF compiles the portable signed-byte dot for gfx1010 again (the SDWA sequence of #4855). 138# The rocBLAS tables are switched at run time (STRATA_AMD_COMMUNITY_TUNING=0). 139option ( STRATA_AMD_COMMUNITY_TUNING "Compile the community-made gfx1010 SDWA dot product (the runtime switch of the same name controls the gfx1030 rocBLAS tables)" ON ) 140if ( NOT STRATA_AMD_COMMUNITY_TUNING) 141add_compile_definitions ( STRATA_AMD_COMMUNITY_DOT_OFF=1 ) 142endif () 143# The rows one verify / batch window holds (include/strata/kernels/window_limits.hpp): 8, the 0.2.7 window, or 16 (four pipelined 144# groups of 16 slots = 64 slots on a four-card split, docs/BATCHING.md). Only the CUDA and HIP engines are built from 145# these sources with a wide window; the SYCL and Metal builds never read this variable and keep 8. A window of up to 146# 8 rows runs the kernels it always ran, whichever is chosen (the wide instantiations are extra code). "auto" = 16 for 147# the HIP engines (a HIP code object loads on first use, so the extra kernels cost nothing until a wide window forms) 148# and 8 for CUDA, which loads every kernel at start (CUDA_MODULE_LOADING=EAGER: the wide kernels would take VRAM from 149# the expert cache of every card); -DSTRATA_WINDOW_MAX_T=16 builds the wide CUDA engine. 150set ( STRATA_WINDOW_MAX_T "auto" CACHE STRING "rows of a verify / batch window: 8, 12, 16 or auto (HIP 16, CUDA 8)" ) 151set_property ( CACHE STRATA_WINDOW_MAX_T PROPERTY STRINGS auto 8 12 16 ) 152if ( NOT STRATA_WINDOW_MAX_TSTREQUAL "auto" AND NOT STRATA_WINDOW_MAX_TSTREQUAL "8" AND NOT STRATA_WINDOW_MAX_TSTREQUAL "12" AND NOT STRATA_WINDOW_MAX_TSTREQUAL "16" ) 153message ( FATAL_ERROR "STRATA_WINDOW_MAX_T must be auto, 8, 12 or 16 (got ' ${ STRATA_WINDOW_MAX_T } ')" ) 154endif () 155if ( STRATA_ENABLE_HIPOR STRATA_ENABLE_CUDA) 156if ( STRATA_WINDOW_MAX_TSTREQUAL "auto" ) 157if ( STRATA_ENABLE_HIP) 158set ( _strata_window_max_t 16 ) 159else () 160set ( _strata_window_max_t 8 ) 161endif () 162else () 163set ( _strata_window_max_t ${ STRATA_WINDOW_MAX_T }) 164endif () 165add_compile_definitions ( STRATA_VERIFY_MAX_T= ${ _strata_window_max_t }) 166message ( STATUS "Strata: verify / batch windows hold up to ${ _strata_window_max_t } rows" ) 167endif () 168# MMQ prompt kernels for Q4_K / Q5_K / Q5_1 / Q6_K (Unsloth's UD-Q4/Q5/Q6_K_XL experts; on HIP also the dense GGUF 169# projections, STRATA_DENSE_MMQ). On by default since MODEL-UPDATE Phase 1: on CUDA they are their own library 170# (strata_kq, loaded only for a model with these formats: the engine loads every kernel of its own binary at start, 171# CUDA_MODULE_LOADING=EAGER, and these took ~3.8 MB of VRAM - 3 IQ3_XXS expert slots on a P100 - from every model); on 172# HIP a code object loads on first use, so they cost other models nothing there (R9700: the same slots). Used at run 173# time when STRATA_MMQ_KQ=1, which the engine sets by itself on NVIDIA cards of compute capability 8.0 and up (include/strata/core/nv_defaults.hpp) and on 174# Linux gfx12 (STRATA_MMQ_KQ=0 turns it off; setup also writes it for UD-Q5_K_XL / UD-Q6_K_XL); other cards keep the FP16 path. This CMake option only 175# decides whether the kernels are BUILT: on in every release build. 176option ( STRATA_MMQ_TQ_OVERLAY "Gyro trellis MMQ prompt kernels: the patched ggml-cuda headers of third_party/strata-ggml/ggml/src/ggml-cuda-tq (with -DSTRATA_GGML_DIR: an overlay of that llama.cpp's headers written at configure time, cmake/strata_ggml_tq_overlay.cmake)" ON ) 177option ( STRATA_MMQ_KQUANTS "Build the MMQ prompt kernels for Q4_K / Q5_K / Q5_1 / Q6_K: the experts of Unsloth's K-quant files, and on HIP the dense GGUF projections (STRATA_DENSE_MMQ)" ON ) 178# Q6_K gate/up in the grouped expert kernels (Unsloth's UD-Q6_K_XL, and layer 2 of UD-Q5_K_XL; docs/QUANTS.md). On by 179# default since MODEL-UPDATE Phase 1: one more instance per grouped kernel in iq_kernels.cu, +19 KB of sm_60 code, 180# measured to leave every expert-cache slot count as it was (P100, R9700). -DSTRATA_Q6K_EXPERTS=OFF drops it. 181option ( STRATA_Q6K_EXPERTS "Build the Q6_K gate/up grouped expert kernels (UD-Q6_K_XL, UD-Q5_K_XL)" ON ) 182if ( STRATA_Q6K_EXPERTS) 183add_compile_definitions ( STRATA_Q6K_EXPERTS=1 ) 184endif () 185option ( STRATA_ORCA_Q4KS_MMQ "Build the GGML Q5_0 MMQ instance for OrcaRouter Q4_K_S" OFF ) 186# CUDA: the pointer-table MMQ behind STRATA_MMQ_DIRECT=1 (the prompt path's MMQ reads resident experts in their cache 187# slots through a Strata-side copy of llama.cpp's MMQ scheduler, src/prefill/moe_mmq_tab.cuh). Off by default, like 188# the K-quant options above: the engine loads every kernel when it starts (CUDA_MODULE_LOADING=EAGER), and these nine 189# instances (+15 MB of binary) take 36-38 MiB of VRAM per GPU on sm_86 - expert slots every model would lose, with 190# STRATA_MMQ_DIRECT unset too. They also add ~70% of the upstream MMQ instances' compile time per CUDA arch (175 s 191# of CPU for the nine at sm_86 alone). Off, the build's device code is byte for byte the one without this feature. CUDA 192# only (not HIP, not gfx906); switched off at configure time when the llama.cpp tree's mmq.cuh is not one the copy 193# was verified against. 194option ( STRATA_MMQ_TAB "Build the pointer-table prompt MMQ for STRATA_MMQ_DIRECT=1 (CUDA; ~37 MiB VRAM per GPU)" OFF ) 195if ( STRATA_PREFILL_MMQAND NOT STRATA_ENABLE_HIP) 196message ( FATAL_ERROR "STRATA_PREFILL_MMQ requires STRATA_ENABLE_HIP=ON" ) 197endif () 198if ( STRATA_ENABLE_CUDAAND STRATA_ENABLE_HIPAND NOT STRATA_HIP_GFX906) 199message ( FATAL_ERROR "STRATA_ENABLE_CUDA and STRATA_ENABLE_HIP are separate backends; enable only one" ) 200endif () 201if ( STRATA_ENABLE_HIP) 202include ( cmake/hip_backend.cmake ) 203endif () 204# Tests are on by default when the build can run them. What they need: their sources (src/**/*_test.cpp, tests/core, 205# bench/micro; a source drop without them has nothing to build) and the x86 CPU kernels, which most of the CPU suite drives 206# (arm64 stays off by default: -DSTRATA_BUILD_TESTS=ON still builds what builds there). GPU tests are registered only 207# when STRATA_ENABLE_CUDA / STRATA_ENABLE_HIP is on, and the configure summary below says which kinds were registered, so 208# a missing GPU is a stated skip and never a silent pass. Release builds say -DSTRATA_BUILD_TESTS=OFF themselves 209# (packaging/, setup.py, Dockerfile, spark/). 210set ( _strata_tests_default OFF ) 211if ( EXISTS ${ CMAKE_CURRENT_SOURCE_DIR } /tests/coreAND EXISTS ${ CMAKE_CURRENT_SOURCE_DIR } /bench/microAND STRATA_CPU_X86) 212set ( _strata_tests_default ON ) 213endif () 214option ( STRATA_BUILD_TESTS "Build the test suite" ${ _strata_tests_default }) 215# A test that needs a model file (a real expert blob from a pack, which is not in the source tree): registered as the real test 216# when the file is there, and otherwise as a stated skip that ctest lists as "Skipped" with this reason, never as a pass of nothing 217# and not as a failure on a machine that has no pack. 218function ( strata_add_pack_test name needs ) 219if ( EXISTS " ${ CMAKE_CURRENT_SOURCE_DIR } / ${ needs } " ) 220add_test ( NAME ${ name } COMMAND ${ ARGN } WORKING_DIRECTORY ${ CMAKE_CURRENT_SOURCE_DIR }) 221else () 222add_test ( NAME ${ name } COMMAND ${ CMAKE_COMMAND } -E echo "SKIPPED: ${ name } needs ${ needs } (a Q2_0 expert pack, a model file), which is not in this tree" ) 223set_tests_properties ( $ { name } PROPERTIES SKIP_REGULAR_EXPRESSION "SKIPPED: " ) 224endif () 225endfunction () 226option ( STRATA_BUILD_CONVERSATION_TESTS "Build standalone conversation cache tests" OFF ) 227option ( STRATA_WERROR "Treat compiler warnings as errors" OFF ) 228# #2027: defined here, before the GPU section reads it to register the native-expert tests (it was defined at the 229# native-experts section far below, so a first configure registered four tests fewer than the second) 230option ( STRATA_NATIVE_EXPERTS "Native (IQ) expert support through ggml-cpu" ON ) 231# Own-stack phase 2: the CPU expert pool's dot products, activation quantizers and the --mtp-q4 requantizer come from the Strata quant layer 232# (src/quant, no ggml-cpu in the pool) instead of ggml-cpu's type traits. OFF keeps the ggml path, selectable for two releases. Default ON on x86 (AVX / 233# AVX2 tiers) and on arm64 (the NEON tier: bit-exact against ggml-cpu's NEON dots, tests/quant/run_oracle.sh and pool_rows_bench on the Spark and the Mac, 234# token gates identical). arm64 was OFF until the gate/up loop's store-forwarding stall was fixed (OWN-2N2); the Spark pool decode then measured 235# 0.992 of ggml's over 18 interleaved pairs. -DSTRATA_OWN_CPU_QUANT=OFF builds the ggml-cpu pool. 236option ( STRATA_OWN_CPU_QUANT "CPU expert pool on the Strata quant layer (src/quant) instead of ggml-cpu's type traits" ON ) 237 238if ( STRATA_BUILD_CONVERSATION_TESTS) 239enable_testing () 240add_executable ( conversation_cache_test src/core/conversation_cache_test.cpp ) 241target_include_directories ( conversation_cache_test PRIVATE include ) 242add_test ( NAME conversation_cache_test COMMAND conversation_cache_test ) 243# STRATA_PARK_SEGPOOL_MIB: the arena behind the conversation buffers' segments (header-only; a fake OS counts the calls) 244find_package ( Threads REQUIRED ) 245add_executable ( conversation_segment_pool_test src/core/conversation_segment_pool_test.cpp ) 246target_include_directories ( conversation_segment_pool_test PRIVATE include ) 247target_compile_features ( conversation_segment_pool_test PRIVATE cxx_std_17 ) 248target_link_libraries ( conversation_segment_pool_test PRIVATE Threads::Threads ) 249add_test ( NAME conversation_segment_pool_test COMMAND conversation_segment_pool_test ) 250add_executable ( conversation_buffer_pool_test src/core/conversation_buffer_pool_test.cpp ) 251target_include_directories ( conversation_buffer_pool_test PRIVATE include ) 252target_compile_features ( conversation_buffer_pool_test PRIVATE cxx_std_17 ) 253target_link_libraries ( conversation_buffer_pool_test PRIVATE Threads::Threads ) 254add_test ( NAME conversation_buffer_pool_test COMMAND conversation_buffer_pool_test ) 255# the park pools' sizes from the cache budget (header-only), with the sizes small machines get 256add_executable ( park_pool_policy_test src/core/park_pool_policy_test.cpp ) 257target_include_directories ( park_pool_policy_test PRIVATE include ) 258target_compile_features ( park_pool_policy_test PRIVATE cxx_std_17 ) 259add_test ( NAME park_pool_policy_test COMMAND park_pool_policy_test ) 260add_executable ( conversation_split_failure_test src/core/conversation_split_failure_test.cpp ) 261target_include_directories ( conversation_split_failure_test PRIVATE include ) 262add_test ( NAME conversation_split_failure_test COMMAND conversation_split_failure_test ) 263add_executable ( conversation_memory_test src/core/conversation_memory_test.cpp src/core/conversation_memory.cpp ) 264target_include_directories ( conversation_memory_test PRIVATE include ) 265add_test ( NAME conversation_memory_test COMMAND conversation_memory_test ) 266add_executable ( scr_test src/core/scr_test.cpp ) 267target_include_directories ( scr_test PRIVATE include ) 268add_test ( NAME scr_test COMMAND scr_test ) 269add_executable ( conversation_file_test src/core/conversation_file_test.cpp src/core/conversation_file.cpp ) 270target_include_directories ( conversation_file_test PRIVATE include ) 271add_test ( NAME conversation_file_test COMMAND conversation_file_test ) 272add_executable ( conversation_disk_test src/core/conversation_disk_test.cpp src/core/conversation_file.cpp ) 273target_include_directories ( conversation_disk_test PRIVATE include ) 274add_test ( NAME conversation_disk_test COMMAND conversation_disk_test ) 275add_executable ( session_save_reclaim_test src/core/session_save_reclaim_test.cpp src/core/conversation_file.cpp ) 276target_include_directories ( session_save_reclaim_test PRIVATE include ) 277add_test ( NAME session_save_reclaim_test COMMAND session_save_reclaim_test ) 278endif () 279 280if ( STRATA_HIP_GFX906) 281strata_hip_gfx906_toolchain () 282elseif ( STRATA_ENABLE_CUDA) 283strata_cuda_toolchain () 284elseif ( STRATA_ENABLE_HIP) 285set ( _strata_gpu_runtime_target strata_hip_runtime ) 286set ( _strata_gpu_blas_target ${ STRATA_HIP_BLAS_TARGETS }) 287set ( _strata_gpu_include_directories ${ STRATA_HIP_COMPAT_INCLUDE_DIR }) 288endif () 289 290# Warnings live on an INTERFACE target the project's own code links, NOT in add_compile_options: applied 291# globally they would also hit FetchContent'd Catch2, whose -W4 warnings are not this project's to fix and 292# whose /WX failures would be indistinguishable from our own. 293# 294# Every flag is guarded by COMPILE_LANGUAGE:CXX. Without that guard nvcc receives bare `/W4 /utf-8` and dies 295# with "A single input file is required for a non-link phase" - it parses them as inputs rather than host 296# flags. Host flags for CUDA must go through -Xcompiler, which is what COMPILE_LANGUAGE:CUDA does below. 297add_library ( strata_warnings INTERFACE ) 298target_compile_options ( strata_warnings INTERFACE 299$ < $ <AND: $ <COMPILE_LANGUAGE:CXX>, $ <CXX_COMPILER_ID:MSVC>>:/W4> 300$ < $ <AND: $ <COMPILE_LANGUAGE:CXX>, $ <CXX_COMPILER_ID:MSVC>>:/utf-8> 301$ < $ <AND: $ <COMPILE_LANGUAGE:CXX>, $ <NOT: $ <CXX_COMPILER_ID:MSVC>>>:-Wall> 302$ < $ <AND: $ <COMPILE_LANGUAGE:CXX>, $ <NOT: $ <CXX_COMPILER_ID:MSVC>>>:-Wextra> 303$ < $ <AND: $ <COMPILE_LANGUAGE:CUDA>, $ <CXX_COMPILER_ID:MSVC>>:-Xcompiler=/W4> 304$ < $ <COMPILE_LANGUAGE:HIP>:-Wall> 305$ < $ <COMPILE_LANGUAGE:HIP>:-Wextra> ) 306if ( STRATA_WERROR) 307target_compile_options ( strata_warnings INTERFACE 308$ < $ <AND: $ <COMPILE_LANGUAGE:CXX>, $ <CXX_COMPILER_ID:MSVC>>:/WX> 309$ < $ <AND: $ <COMPILE_LANGUAGE:CXX>, $ <NOT: $ <CXX_COMPILER_ID:MSVC>>>:-Werror> 310$ < $ <COMPILE_LANGUAGE:HIP>:-Werror> ) 311endif () 312 313# ---- strata_artifact ------------------------------------------------------- 314# Header-only, and that is a deliberate property rather than an unfinished split: the GGUF reader and the 315# scalar dequantizers hold no state worth hiding, and a header-only boundary cannot introduce a 316# duplicate-symbol or missing-declaration bug into code that is already validated against the real artifact. 317add_library ( strata_artifact INTERFACE ) 318target_include_directories ( strata_artifact INTERFACE ${ CMAKE_CURRENT_SOURCE_DIR } /include ) 319target_link_libraries ( strata_artifact INTERFACE strata_warnings ) 320 321add_executable ( strata-gguf src/artifact/gguf_reader.cpp ) 322target_link_libraries ( strata-gguf PRIVATE strata_artifact ) 323 324add_executable ( strata-dequant src/artifact/dequant.cpp ) 325target_link_libraries ( strata-dequant PRIVATE strata_artifact ) 326# this file is now nothing but the CLI entry point, and its inherited guard spells that as a "selftest" 327target_compile_definitions ( strata-dequant PRIVATE STRATA_DEQUANT_SELFTEST ) 328if ( STRATA_BUILD_TESTS) 329add_executable ( batch_telemetry_test src/core/batch_telemetry_test.cpp ) 330target_include_directories ( batch_telemetry_test PRIVATE include ) 331add_test ( NAME batch_telemetry_test COMMAND batch_telemetry_test ) 332# #5697: an evicted parked conversation gives its RAM back to the system (glibc's heap; RSS before and after) 333add_executable ( conversation_heap_test src/core/conversation_heap_test.cpp ) 334target_include_directories ( conversation_heap_test PRIVATE include ) 335add_test ( NAME conversation_heap_test COMMAND conversation_heap_test ) 336# the residency entries past what the shrinking expert cache still maps, also after a shrink refused part way (no GPU) 337add_executable ( residency_trim_test tests/core/residency_trim_test.cpp ) 338target_include_directories ( residency_trim_test PRIVATE include ) 339add_test ( NAME residency_trim_test COMMAND residency_trim_test ) 340# #5718 follow-up: the stall report's list of GPU streams a host may wait on, and its lines (faked queries, no GPU) 341add_executable ( stream_watch_test tests/core/stream_watch_test.cpp ) 342target_include_directories ( stream_watch_test PRIVATE include ) 343add_test ( NAME stream_watch_test COMMAND stream_watch_test ) 344# AMD on Linux: how long the driver paused this process's GPU work (a fake KFD tree; the stall and request lines) 345add_executable ( gpu_pause_time_test tests/core/gpu_pause_time_test.cpp ) 346target_include_directories ( gpu_pause_time_test PRIVATE include ) 347add_test ( NAME gpu_pause_time_test COMMAND gpu_pause_time_test ) 348# the picture reader's room in the resident RAM mode (owner 11-11, reader on demand): the reserve rule, no GPU 349add_executable ( reader_room_test tests/core/reader_room_test.cpp ) 350target_include_directories ( reader_room_test PRIVATE include ) 351add_test ( NAME reader_room_test COMMAND reader_room_test ) 352# the elastic K/V once the expert cache is known: it always grows when the pools are elastic, from the cache only when it can give (no GPU) 353add_executable ( kv_grow_rules_test tests/core/kv_grow_rules_test.cpp ) 354target_include_directories ( kv_grow_rules_test PRIVATE include ) 355add_test ( NAME kv_grow_rules_test COMMAND kv_grow_rules_test ) 356# how the prompt path's K/V append reaches the host copy under KV streaming: the switch both ways, the backend defaults, no pool (no GPU) 357add_executable ( kv_host_dma_test tests/core/kv_host_dma_test.cpp ) 358target_include_directories ( kv_host_dma_test PRIVATE include ) 359add_test ( NAME kv_host_dma_test COMMAND kv_host_dma_test ) 360# the wait before READY on an integrated AMD GPU (the counter reader and the wait, faked clock; no GPU) 361add_executable ( kfd_settle_test tests/core/kfd_settle_test.cpp ) 362target_include_directories ( kfd_settle_test PRIVATE include ) 363add_test ( NAME kfd_settle_test COMMAND kfd_settle_test ) 364# keeping the KFD quiet on an integrated gfx11 GPU: the switches, the load order's rule (no GPU) 365add_executable ( kfd_quiet_test tests/core/kfd_quiet_test.cpp ) 366target_include_directories ( kfd_quiet_test PRIVATE include ) 367add_test ( NAME kfd_quiet_test COMMAND kfd_quiet_test ) 368# the file-cache give-back during and after the expert load on an integrated AMD GPU (a temporary file; no GPU) 369add_executable ( page_cache_drop_test tests/core/page_cache_drop_test.cpp ) 370target_include_directories ( page_cache_drop_test PRIVATE include ) 371add_test ( NAME page_cache_drop_test COMMAND page_cache_drop_test ) 372add_executable ( logit_bias_test src/core/logit_bias_test.cpp ) 373target_include_directories ( logit_bias_test PRIVATE include ) 374add_test ( NAME logit_bias_test COMMAND logit_bias_test ) 375# hard bans to MTP draft-head columns, and the no-bias / finite-bias no-ops (core/draft_ban.hpp) 376add_executable ( draft_ban_test src/core/draft_ban_test.cpp ) 377target_include_directories ( draft_ban_test PRIVATE include ) 378add_test ( NAME draft_ban_test COMMAND draft_ban_test ) 379# the reader refuses a duplicate tensor name at open, naming it (a synthetic GGUF: no model, no GPU) 380add_executable ( gguf_reader_test src/artifact/gguf_reader_test.cpp ) 381target_link_libraries ( gguf_reader_test PRIVATE strata_artifact ) 382add_test ( NAME gguf_reader_test COMMAND gguf_reader_test ) 383# a split model's shards and their joint view: missing shard, split keys, duplicates, truncation (synthetic) 384add_executable ( gguf_split_test tests/core/gguf_split_test.cpp ) 385target_link_libraries ( gguf_split_test PRIVATE strata_artifact ) 386add_test ( NAME gguf_split_test COMMAND gguf_split_test ) 387# the model families (qwen4exp, qwen35moe): the guards, the geometry from metadata, the layout tables (synthetic) 388add_executable ( model_family_test tests/core/model_family_test.cpp ) 389target_link_libraries ( model_family_test PRIVATE strata_artifact ) 390add_test ( NAME model_family_test COMMAND model_family_test ) 391# how --batch cuts a prompt read into pieces (a layer split with no slot decoding must still reach a BYIELD) 392add_executable ( batch_read_test tests/program/batch_read_test.cpp ) 393target_include_directories ( batch_read_test PRIVATE include ) 394add_test ( NAME batch_read_test COMMAND batch_read_test ) 395# the model's geometry from its metadata, and the check against the kernels' compiled shape (synthetic) 396add_executable ( gguf_geometry_test tests/core/gguf_geometry_test.cpp ) 397target_link_libraries ( gguf_geometry_test PRIVATE strata_artifact ) 398add_test ( NAME gguf_geometry_test COMMAND gguf_geometry_test ) 399 400# the hipBLASLt tuning header's architecture gate: RDNA4 siblings share solution IDs, RDNA3 siblings share 401# theirs, cross-family pairs and version mismatches stay rejected (synthetic tables: no model, no GPU) 402add_executable ( tuning_header_arch_family_test tests/prefill/tuning_header_arch_family_test.cpp ) 403target_include_directories ( tuning_header_arch_family_test PRIVATE " ${ CMAKE_CURRENT_SOURCE_DIR } /src/prefill" ) 404add_test ( NAME tuning_header_arch_family_test COMMAND tuning_header_arch_family_test ) 405 406# #5722: each layer-split participant's prompt loan priced on its own device (faked devices, no GPU) 407add_executable ( split_part_price_test tests/program/split_part_price_test.cpp ) 408target_include_directories ( split_part_price_test PRIVATE include ) 409add_test ( NAME split_part_price_test COMMAND split_part_price_test ) 410# STRATA_RESIDENT_PIN read for the automatic RAM copy too, and that copy's clamp line names no flag (header-only, no GPU) 411add_executable ( resident_ram_copy_test tests/core/resident_ram_copy_test.cpp ) 412target_include_directories ( resident_ram_copy_test PRIVATE include ) 413add_test ( NAME resident_ram_copy_test COMMAND resident_ram_copy_test ) 414# the auto layer split's minimum stage size (#1616): header-only rule, no GPU 415add_executable ( split_rules_test tests/program/split_rules_test.cpp ) 416target_include_directories ( split_rules_test PRIVATE include ) 417add_test ( NAME split_rules_test COMMAND split_rules_test ) 418 419# #3797: the out-of-memory report at start (per card free/total, the largest other programs): the text is a pure 420# function; the driver query (NVML, loaded at run time) is only checked to be safe to call. No GPU needed. 421add_executable ( gpu_report_test tests/program/gpu_report_test.cpp ) 422target_include_directories ( gpu_report_test PRIVATE include ) 423target_link_libraries ( gpu_report_test PRIVATE ${ CMAKE_DL_LIBS }) 424add_test ( NAME gpu_report_test COMMAND gpu_report_test ) 425 426# #3702: the later-stage reserve of the layer split search (header-only arithmetic, pinned against the old expression) 427add_executable ( stage_reserve_test tests/program/stage_reserve_test.cpp ) 428target_include_directories ( stage_reserve_test PRIVATE include ) 429add_test ( NAME stage_reserve_test COMMAND stage_reserve_test ) 430 431# the layer split's spill walk (header-only arithmetic: who is short, which step comes next) 432add_executable ( split_walk_test tests/program/split_walk_test.cpp ) 433target_include_directories ( split_walk_test PRIVATE include ) 434add_test ( NAME split_walk_test COMMAND split_walk_test ) 435 436# the prompt planner's host-memory model (#2824): header-only, no GPU 437add_executable ( prefill_plan_test tests/program/prefill_plan_test.cpp ) 438target_include_directories ( prefill_plan_test PRIVATE include ) 439add_test ( NAME prefill_plan_test COMMAND prefill_plan_test ) 440 441# #5715: strata-q36's one-session context check (the reporter's 12 GB card from its log): header-only, no GPU 442add_executable ( q36_context_fit_test tests/program/q36_context_fit_test.cpp ) 443target_include_directories ( q36_context_fit_test PRIVATE include ) 444add_test ( NAME q36_context_fit_test COMMAND q36_context_fit_test ) 445 446# the default CPU prefill share is not armed when every expert is resident (#1595): header-only rule, no GPU 447add_executable ( share_rules_test tests/prefill/share_rules_test.cpp ) 448target_include_directories ( share_rules_test PRIVATE include ) 449add_test ( NAME share_rules_test COMMAND share_rules_test ) 450 451# the chunk a prompt piece below the walk floor lends its buffers for (the staged layout, not the rounded chunk's streamed one): header-only rule, no GPU 452add_executable ( loan_rules_test tests/prefill/loan_rules_test.cpp ) 453target_include_directories ( loan_rules_test PRIVATE include ) 454add_test ( NAME loan_rules_test COMMAND loan_rules_test ) 455 456# how a long prompt segment is cut into chunks: equal chunks, ceil(tokens / chunk) of them, on one GPU in a build without MMQ (header-only rule, no GPU) 457add_executable ( equal_cut_rule_test tests/prefill/equal_cut_rule_test.cpp ) 458target_include_directories ( equal_cut_rule_test PRIVATE include ) 459add_test ( NAME equal_cut_rule_test COMMAND equal_cut_rule_test ) 460 461# which tail the serve auto chunk scan counts in a build without MMQ with the equal cut on (header-only rule, no GPU) 462add_executable ( fit_out_rule_test tests/prefill/fit_out_rule_test.cpp ) 463target_include_directories ( fit_out_rule_test PRIVATE include ) 464add_test ( NAME fit_out_rule_test COMMAND fit_out_rule_test ) 465 466# which work item (128 or 64 routed rows) the CUDA fused prompt kernels take, per card class (pick_ww): the pure rule, pinned at the two sides of every threshold for the 467# measured classes and compared with the previous rule for every class that must not change (header-only, no GPU) 468add_executable ( fused_tile_rule_test tests/prefill/fused_tile_rule_test.cpp ) 469target_include_directories ( fused_tile_rule_test PRIVATE include ) 470add_test ( NAME fused_tile_rule_test COMMAND fused_tile_rule_test ) 471 472# whether the staged walk (chunks below 1,024 tokens) takes the batched group entry: on by default in a CUDA build, opt-in in a HIP build, STRATA_PF_FUSED=1 / =0 both ways 473# (header-only, no GPU) 474add_executable ( staged_group_rule_test tests/prefill/staged_group_rule_test.cpp ) 475target_include_directories ( staged_group_rule_test PRIVATE include ) 476add_test ( NAME staged_group_rule_test COMMAND staged_group_rule_test ) 477 478# when a prompt layer's expert groups take our own int8 kernels (native_expert_i8): STRATA_EXPERT_I8 = 1 / 0 / unset, where unset means the HIP cards gfx1030 / 1031 / 1032 from 479# 256 entries per group and every other card keeps MMQ (header-only, no GPU) 480add_executable ( i8_expert_rule_test tests/prefill/i8_expert_rule_test.cpp ) 481target_include_directories ( i8_expert_rule_test PRIVATE include ) 482add_test ( NAME i8_expert_rule_test COMMAND i8_expert_rule_test ) 483# which kernels carry one Qwen3.6 layer's prompt experts (strata-q36): fused > int8 (switch set to 1) > MMQ > int8 > grouped, in a build with and without MMQ (header-only, no GPU) 484add_executable ( q36_prompt_route_test tests/prefill/q36_prompt_route_test.cpp ) 485target_include_directories ( q36_prompt_route_test PRIVATE include ) 486add_test ( NAME q36_prompt_route_test COMMAND q36_prompt_route_test ) 487# from which chunk size a prompt chunk takes the long-prompt path: 1,024, or the lower floor of a layer set that is fused-only on every layer on Windows gfx1151 (header-only, no GPU) 488add_executable ( stream_floor_rule_test tests/prefill/stream_floor_rule_test.cpp ) 489target_include_directories ( stream_floor_rule_test PRIVATE include ) 490add_test ( NAME stream_floor_rule_test COMMAND stream_floor_rule_test ) 491 492# whether the staged walk's group entry also takes a layer with no MMQ tile that the fused kernels cover (research switch STRATA_PF_STAGED_FO=1, off by default; header-only, no GPU) 493add_executable ( staged_fo_rule_test tests/prefill/staged_fo_rule_test.cpp ) 494target_include_directories ( staged_fo_rule_test PRIVATE include ) 495add_test ( NAME staged_fo_rule_test COMMAND staged_fo_rule_test ) 496 497# whether a layer the CPU share took experts of keeps the staged fused entry and the int8 kernels for the GPU's own experts: yes in a build without MMQ, no in a build with MMQ (header-only, no GPU) 498add_executable ( share_own_rule_test tests/prefill/share_own_rule_test.cpp ) 499target_include_directories ( share_own_rule_test PRIVATE include ) 500add_test ( NAME share_own_rule_test COMMAND share_own_rule_test ) 501 502# the long-prompt floor of the plain pack by card class and share state: 1,536 tokens on a discrete CUDA card in a build without MMQ, the old answer elsewhere (header-only, no GPU) 503add_executable ( plain_floor_rule_test tests/prefill/plain_floor_rule_test.cpp ) 504target_include_directories ( plain_floor_rule_test PRIVATE include ) 505add_test ( NAME plain_floor_rule_test COMMAND plain_floor_rule_test ) 506 507# the start-up sentence of an engine built without llama.cpp's MMQ prompt kernels (layer counts per path; header-only, no GPU) 508add_executable ( own_only_line_test tests/prefill/own_only_line_test.cpp ) 509target_include_directories ( own_only_line_test PRIVATE include ) 510add_test ( NAME own_only_line_test COMMAND own_only_line_test ) 511 512# the opt-in fused-kernel switches a build without MMQ turns on by default, per backend (header-only, no GPU) 513add_executable ( own_only_switches_test tests/prefill/own_only_switches_test.cpp ) 514target_include_directories ( own_only_switches_test PRIVATE include ) 515add_test ( NAME own_only_switches_test COMMAND own_only_switches_test ) 516 517# how many tokens the FP16 expert path's buffers (Xs, Hh) are sized for: the tail below the stream floor in a fused layout, the full chunk elsewhere (header-only, no GPU) 518add_executable ( fp16_rows_rule_test tests/prefill/fp16_rows_rule_test.cpp ) 519target_include_directories ( fp16_rows_rule_test PRIVATE include ) 520add_test ( NAME fp16_rows_rule_test COMMAND fp16_rows_rule_test ) 521 522# the expert-paths bench's per-expert blob change never touches a scale byte of the gate/up format's block (test-only header; no GPU, no ggml) 523add_executable ( bench_blob_layout_test tests/prefill/bench_blob_layout_test.cpp ) 524# with the quant layer (STRATA_NATIVE_EXPERTS, defined further down): the table's geometry against strata::quant::type_info too 525target_link_libraries ( bench_blob_layout_test PRIVATE $ <TARGET_NAME_IF_EXISTS:strata_quant> ) 526target_compile_definitions ( bench_blob_layout_test PRIVATE $ < $ <TARGET_EXISTS:strata_quant>:BBL_HAVE_QUANT=1> ) 527add_test ( NAME bench_blob_layout_test COMMAND bench_blob_layout_test ) 528 529# STRATA_SWITCH_POINT (on by default for NVIDIA sm_86, one GPU): the floor from the card's share of non-resident experts, a cost estimate of the staged and the streamed walk (header-only, no GPU) 530add_executable ( switch_point_rule_test tests/prefill/switch_point_rule_test.cpp ) 531target_include_directories ( switch_point_rule_test PRIVATE include ) 532add_test ( NAME switch_point_rule_test COMMAND switch_point_rule_test ) 533 534# whether the CUDA fused prompt kernels take the Gyro trellis experts by default (STRATA_PF_FUSED_TQ unset: the sm_86 cards with 80+ SMs; =1 any card; =0 off): the pure 535# rule, pinned for every card class (header-only, no GPU) 536add_executable ( fused_tq_default_test tests/prefill/fused_tq_default_test.cpp ) 537target_include_directories ( fused_tq_default_test PRIVATE include ) 538add_test ( NAME fused_tq_default_test COMMAND fused_tq_default_test ) 539 540# whether a HIP device's fused prompt kernels take the Gyro trellis experts (gfx12 with STRATA_PF_FUSED_TQ=1; gfx1151 by STRATA_PF_TQ_G1151 and its Windows 541# default): the pure rule, pinned over every input (header-only, no GPU) 542add_executable ( fused_tq_hip_test tests/prefill/fused_tq_hip_test.cpp ) 543target_include_directories ( fused_tq_hip_test PRIVATE include ) 544add_test ( NAME fused_tq_hip_test COMMAND fused_tq_hip_test ) 545 546# STRATA_SELECT_TWO_PASS: the bound between the single-pass and 3xTF32 QSA block scores and the cut-off rule that 547# keeps the selection (header-only, no GPU) 548add_executable ( qsa_two_pass_test tests/prefill/qsa_two_pass_test.cpp ) 549target_include_directories ( qsa_two_pass_test PRIVATE include ) 550add_test ( NAME qsa_two_pass_test COMMAND qsa_two_pass_test ) 551# STRATA_SELECT_TWO_PASS: the request's parse and the line it prints once where the scorer cannot run (no GPU) 552add_executable ( qsa_two_pass_status_test tests/prefill/qsa_two_pass_status_test.cpp ) 553target_include_directories ( qsa_two_pass_status_test PRIVATE include ) 554add_test ( NAME qsa_two_pass_status_test COMMAND qsa_two_pass_status_test 555" ${ CMAKE_CURRENT_BINARY_DIR } /qsa_two_pass_status_test.log" ) 556 557# STRATA_PREFILL_ROUTED_STREAM: the prompt stream's issuer walk and route gate, on a simulated link and consumer 558# (header-only, no GPU) 559add_executable ( routed_stream_test tests/prefill/routed_stream_test.cpp ) 560target_include_directories ( routed_stream_test PRIVATE include ) 561target_link_libraries ( routed_stream_test PRIVATE Threads::Threads ) 562add_test ( NAME routed_stream_test COMMAND routed_stream_test ) 563 564# PR #4006: STRATA_PREFILL_TIMING does not record a mark in the phase already running (header-only, no GPU) 565add_executable ( timer_marks_test tests/prefill/timer_marks_test.cpp ) 566target_include_directories ( timer_marks_test PRIVATE include ) 567add_test ( NAME timer_marks_test COMMAND timer_marks_test ) 568 569# PR #5108: the MMQ row table's over-read margin follows the backend tile bound; every fixup read stays inside (header-only, no GPU) 570add_executable ( mmq_ids_margin_test tests/prefill/mmq_ids_margin_test.cpp ) 571target_include_directories ( mmq_ids_margin_test PRIVATE include ) 572add_test ( NAME mmq_ids_margin_test COMMAND mmq_ids_margin_test ) 573 574# few-row experts on the FP16 prompt path: the research switch and the rule (header-only, no GPU) 575add_executable ( fewrows_rule_test tests/prefill/fewrows_rule_test.cpp ) 576target_include_directories ( fewrows_rule_test PRIVATE include ) 577add_test ( NAME fewrows_rule_test COMMAND fewrows_rule_test ) 578 579# Tesla P100: when the prompt experts take the FP16 path by default instead of MMQ (header-only, no GPU) 580add_executable ( gp100_prompt_default_test tests/prefill/gp100_prompt_default_test.cpp ) 581target_include_directories ( gp100_prompt_default_test PRIVATE include ) 582add_test ( NAME gp100_prompt_default_test COMMAND gp100_prompt_default_test ) 583 584# PR #4844: the adaptive tier's copy-in range across serial, pipelined and drained rounds (header-only, no GPU) 585add_executable ( adaptive_range_test tests/program/adaptive_range_test.cpp ) 586target_include_directories ( adaptive_range_test PRIVATE include ) 587add_test ( NAME adaptive_range_test COMMAND adaptive_range_test ) 588 589# P0.1 (lite): STRATA_MANIFEST, the machine-readable record of the selected paths, tensor formats, engine and budgets (header-only, no GPU) 590add_executable ( run_manifest_test tests/core/run_manifest_test.cpp ) 591target_include_directories ( run_manifest_test PRIVATE include ) 592add_test ( NAME run_manifest_test COMMAND run_manifest_test ) 593# the staged latent walk keeps an open batch's ring slots until it launches: header-only, no GPU 594add_executable ( staged_batch_test tests/prefill/staged_batch_test.cpp ) 595target_include_directories ( staged_batch_test PRIVATE include ) 596add_test ( NAME staged_batch_test COMMAND staged_batch_test ) 597 598# the Windows HIP auto prefill chunk cap (#1630) and the commit-limit verdict (#1607): header-only, no GPU 599add_executable ( host_limits_test tests/platform/host_limits_test.cpp ) 600target_include_directories ( host_limits_test PRIVATE include ) 601add_test ( NAME host_limits_test COMMAND host_limits_test ) 602# #4733: an engine started at Low I/O priority goes back to Normal (Windows; else skips) 603add_executable ( io_priority_test tests/platform/io_priority_test.cpp src/platform/io_priority.cpp ) 604target_include_directories ( io_priority_test PRIVATE include ) 605add_test ( NAME io_priority_test COMMAND io_priority_test ) 606set_tests_properties ( io_priority_test PROPERTIES SKIP_RETURN_CODE 77 ) 607endif () 608 609# ---- strata_plan ---------------------------------------------------------- 610# Also header-only. A "planner" that hides state would be one whose decision is not inspectable, and the 611# whole point of P1.S9 is that the decision is arithmetic you can check by hand. 612add_library ( strata_plan INTERFACE ) 613target_include_directories ( strata_plan INTERFACE ${ CMAKE_CURRENT_SOURCE_DIR } /include ) 614target_link_libraries ( strata_plan INTERFACE strata_warnings ) 615 616add_executable ( strata-plan src/plan/plan_main.cpp ) 617target_link_libraries ( strata-plan PRIVATE strata_plan ) 618 619# ---- strata_core (GPU runtime) --------------------------------------------- 620# Only built when a GPU backend is on, so the Phase 1 targets keep working without a toolkit. 621strata_gpu_engine () 622 623strata_cpu_kernels () 624 625# ---- plan v0.3 P6: the i-quant models' CPU experts (IQ2_XS / IQ3_XXS files) ---- 626# 627# The CPU computes a native expert with ggml-cpu's own dot products (`ggml_get_type_traits_cpu`), so an IQ 628# weight means exactly what it means in llama.cpp. ggml is built static from the tree vendored in 629# third_party/strata-ggml (frozen at the llama.cpp commit in third_party/ggml/VERSION.txt, see its UPSTREAM.md): no download. 630# -DSTRATA_GGML_DIR=<llama.cpp checkout> still builds from that checkout instead (an override kept for two releases). 631strata_ggml_resolve ( " ${ CMAKE_CURRENT_SOURCE_DIR } " ) 632if ( STRATA_PREFILL_MMQAND NOT STRATA_NATIVE_EXPERTS) 633message ( FATAL_ERROR "STRATA_PREFILL_MMQ requires STRATA_NATIVE_EXPERTS=ON for GGML sources" ) 634endif () 635if ( STRATA_ORCA_Q4KS_MMQAND NOT STRATA_NATIVE_EXPERTS) 636message ( FATAL_ERROR "STRATA_ORCA_Q4KS_MMQ requires STRATA_NATIVE_EXPERTS=ON for GGML sources" ) 637endif () 638if ( STRATA_NATIVE_EXPERTS) 639enable_language ( C ) 640strata_ggml_configure_root () 641strata_cpu_native_experts () 642strata_quant_layer () 643strata_ggml_mmq_types () 644# #296: OrcaRouter Q4_K_S's Q5_0 experts (Q4_K and Q5_1 come with STRATA_MMQ_KQUANTS on CUDA, S5's branch) 645if ( STRATA_ORCA_Q4KS_MMQ) 646list ( APPEND _strata_mmq_types q5_0 ) 647endif () 648if ( STRATA_ENABLE_CUDAAND STRATA_MMQ) 649strata_cuda_mmq () 650elseif ( STRATA_ENABLE_CUDA) 651strata_cuda_pf_own () # P4-SPLIT: no MMQ, Strata's own prompt kernels only 652elseif ( STRATA_PREFILL_MMQAND STRATA_MMQ) 653strata_hip_mmq () 654elseif ( STRATA_ENABLE_HIP) 655strata_hip_pf_own () 656endif () 657if ( STRATA_ENABLE_CUDA) 658strata_cuda_prompt_tests () 659elseif ( STRATA_ENABLE_HIP) 660strata_hip_prompt_tests () 661endif () 662if ( STRATA_ENABLE_HIP) 663# Optional real-model diagnostic: pass the GGUF shard containing the native PLE key. 664add_executable ( hip_ple_iq4 tests/hip/ple_iq4.cpp ) 665target_link_libraries ( hip_ple_iq4 PRIVATE strata_kernels strata_hip_runtime ggml-base ) 666endif () 667# the NVFP4 AVX-512 and AVX2 rows vs ggml-cpu's vec_dot, and their speed (CPU only; optional arg: a pack's experts.bin) 668add_executable ( nvfp4_avx512_parity src/kernels/cpu/nvfp4_avx512_parity.cpp ) 669target_link_libraries ( nvfp4_avx512_parity PRIVATE strata_kernels_cpu ) 670if ( STRATA_ISA_FLOOR) # ggml-cpu without AVX2 / FMA: its dot is not the AVX2 one, so no bit-equality check (cmake/backends/cpu.cmake) 671target_compile_definitions ( nvfp4_avx512_parity PRIVATE STRATA_TEST_GGML_WITHOUT_AVX2=1 ) 672endif () 673add_test ( NAME nvfp4_cpu_parity COMMAND nvfp4_avx512_parity ) # random blocks; the AVX2 rows bit-equal to ggml's 674set_tests_properties ( nvfp4_cpu_parity PROPERTIES TIMEOUT 120 ) 675if ( STRATA_ENABLE_CUDA) # the NVFP4 decode kernels vs ggml's reference 676add_executable ( nvfp4_expert_gpu_parity src/kernels/nvfp4_expert_gpu_parity.cpp ) 677target_link_libraries ( nvfp4_expert_gpu_parity PRIVATE strata_kernels ggml-base CUDA::cudart ) 678# the decode experts' weight bandwidth on random blobs of a format pair, and an output hash (bit-for-bit checks) 679add_executable ( nvfp4_decode_bench src/kernels/nvfp4_decode_bench.cpp ) 680target_link_libraries ( nvfp4_decode_bench PRIVATE strata_kernels CUDA::cudart ) 681 682target_sources ( strata_engine PRIVATE src/core/latent_dense.cpp src/latent/latent_moe.cpp ) 683 684# latent MoE layer0: D(Q8) -> A(native NVFP4) -> U(Q8) -> combine 685add_executable ( latent_layer0_verify src/kernels/latent_layer0_verify.cpp ) 686target_link_libraries ( latent_layer0_verify PRIVATE strata_kernels ggml-base CUDA::cudart ) 687 688add_executable ( latent_layout_check src/kernels/latent_layout_check.cpp ) 689target_link_libraries ( latent_layout_check PRIVATE strata_kernels_cpu ) 690 691add_executable ( latent_source_check src/kernels/latent_source_check.cpp ) 692target_link_libraries ( latent_source_check PRIVATE strata_engine strata_kernels_cpu ) 693 694add_executable ( latent_share_test src/core/latent_share_test.cpp ) 695target_include_directories ( latent_share_test PRIVATE include ) 696target_link_libraries ( latent_share_test PRIVATE CUDA::cudart ) 697add_executable ( latent_dense_check src/kernels/latent_dense_check.cpp src/core/latent_dense.cpp ) 698target_include_directories ( latent_dense_check PRIVATE ${ CMAKE_SOURCE_DIR } /include ) 699 700add_executable ( latent_layer_pack_verify src/kernels/latent_layer_pack_verify.cpp src/core/latent_dense.cpp ) 701target_include_directories ( latent_layer_pack_verify PRIVATE ${ CMAKE_SOURCE_DIR } /include ) 702target_link_libraries ( latent_layer_pack_verify PRIVATE strata_engine strata_kernels strata_kernels_cpu CUDA::cudart ) 703 704add_executable ( latent_bench src/kernels/latent_bench.cpp src/core/latent_dense.cpp ) 705target_include_directories ( latent_bench PRIVATE ${ CMAKE_SOURCE_DIR } /include ) 706target_link_libraries ( latent_bench PRIVATE strata_engine strata_kernels strata_kernels_cpu CUDA::cudart ) 707 708add_executable ( latent_module_verify src/kernels/latent_module_verify.cpp src/latent/latent_moe.cpp src/core/latent_dense.cpp ) 709target_include_directories ( latent_module_verify PRIVATE ${ CMAKE_SOURCE_DIR } /include ) 710target_link_libraries ( latent_module_verify PRIVATE strata_engine strata_kernels strata_kernels_cpu CUDA::cudart ) 711 712add_executable ( latent_u_check src/kernels/latent_u_check.cpp src/core/latent_dense.cpp ) 713target_include_directories ( latent_u_check PRIVATE ${ CMAKE_SOURCE_DIR } /include ) 714target_link_libraries ( latent_u_check PRIVATE strata_engine strata_kernels CUDA::cudart ) 715 716add_executable ( latent_cpu_verify src/kernels/latent_cpu_verify.cpp src/core/latent_dense.cpp ) 717target_include_directories ( latent_cpu_verify PRIVATE ${ CMAKE_SOURCE_DIR } /include ) 718target_link_libraries ( latent_cpu_verify PRIVATE strata_engine strata_kernels_cpu CUDA::cudart ) 719endif () 720if ( STRATA_ENABLE_CUDAOR STRATA_ENABLE_HIP) 721add_executable ( native_expert_parity src/kernels/native_expert_parity.cpp ) 722target_include_directories ( native_expert_parity PRIVATE ${ _strata_gpu_include_directories }) 723# strata_engine: the --load-check mode runs the engine's start-up checks (NativeDense, check_experts_gguf) 724target_link_libraries ( native_expert_parity PRIVATE strata_engine strata_kernels strata_kernels_cpu strata_artifact ${ _strata_gpu_runtime_target }) 725add_executable ( native_expert_bench src/kernels/native_expert_bench.cpp ) 726target_include_directories ( native_expert_bench PRIVATE ${ _strata_gpu_include_directories }) 727target_link_libraries ( native_expert_bench PRIVATE strata_kernels strata_kernels_cpu strata_artifact ${ _strata_gpu_runtime_target }) 728if ( STRATA_ENABLE_CUDAAND STRATA_EXPERIMENTAL_SM60) 729# STRATA_EXPERT_NIBBLE (include/strata/core/expert_nibble.hpp): the 4-bit gate/up expert slots against the 730# production kernels and the GGUF blobs, bit for bit, on a real model's layers (needs a GP100); --header: the 731# contract's host half, no GPU 732add_executable ( iq_nibble_parity src/kernels/iq_nibble_parity.cpp ) 733target_include_directories ( iq_nibble_parity PRIVATE ${ _strata_gpu_include_directories }) 734target_link_libraries ( iq_nibble_parity PRIVATE strata_kernels strata_kernels_cpu strata_artifact ggml-base ${ _strata_gpu_runtime_target }) 735if ( STRATA_BUILD_TESTS) 736add_test ( NAME iq_nibble_parity_header COMMAND iq_nibble_parity --header ) 737# the synthetic experts of every gate/up x down format pair, no model (skips with 77 on a card that is not a GP100) 738add_test ( NAME iq_nibble_parity_synthetic COMMAND iq_nibble_parity --synthetic-only ) 739set_tests_properties ( iq_nibble_parity_synthetic PROPERTIES SKIP_RETURN_CODE 77 TIMEOUT 900 ) 740endif () 741endif () 742# MODEL-UPDATE: the dense Q8_0 GEMVs at the engine's shapes against the memory bandwidth (a benchmark, no test) 743add_executable ( q8_gemv_bench src/kernels/q8_gemv_bench.cpp ) 744target_include_directories ( q8_gemv_bench PRIVATE ${ _strata_gpu_include_directories }) 745target_link_libraries ( q8_gemv_bench PRIVATE strata_kernels ${ _strata_gpu_runtime_target }) 746# EXPDEC (docs/EXPERTDEC.md): the grouped experts' default kernels against STRATA_EXPDEC=1 at T = 1..4, bit for bit 747# and in microseconds, on synthetic blobs read cold from DRAM 748add_executable ( expdec_bench EXCLUDE_FROM_ALL src/kernels/expdec_bench.cpp ) 749target_include_directories ( expdec_bench PRIVATE ${ _strata_gpu_include_directories }) 750target_link_libraries ( expdec_bench PRIVATE strata_kernels ${ _strata_gpu_runtime_target }) 751if ( STRATA_BUILD_TESTSAND STRATA_ENABLE_CUDA) 752# Unsloth UD-Q4_K_XL's three expert pairs (and Q8_0 alone, its embedding) on synthetic ggml-quantized weights 753# at 2560/640: GPU and CPU experts against the float reference, GPU dequantizers against to_float. 754# q4_K/q5_0 and q5_0/q8_0: a plain llama-quantize "_M" tier GGUF (not Unsloth's dynamic method) commonly 755# puts Q5_0 on down-projections (sometimes gate/up too) where this model's native_experts.txt had no GPU 756# kernel for it before; q5_0/q5_0 (both roles Q5_0) is left out of this list since stacking the same 757# lower-precision format on both roles pushes the GPU path over this test's 3% threshold (quantization 758# noise, not a kernel bug -- see the PR). 759# q4_0/q4_0 and q4_0/q4_1: a plain llama-quantize Q4_0 file (bartowski's Qwen3.8-Flash-Next-Q4_0: gate/up Q4_0, 760# down Q4_0 on 42 layers and Q4_1 on 6) 761# q6_K/q8_0: Unsloth UD-Q6_K_XL gate/up Q6_K with Q8_0 down (docs/UNSLOTH_Q6.md). Layer 2 is q8_0/q8_0, already listed. 762set ( _strata_parity_pairs q4_K/q5_1 q4_K/q8_0 q5_K/q8_0 q8_0/q8_0 q4_K/q5_0 q5_0/q8_0 q4_0/q4_0 q4_0/q4_1 ) 763if ( STRATA_Q6K_EXPERTS) 764list ( APPEND _strata_parity_pairs q6_K/q8_0 ) 765else () # a pair without GPU kernels (Q6_K gate/up) is refused by native_expert_supported, not run 766add_test ( NAME native_expert_parity_refuses_q6_K COMMAND native_expert_parity --synthetic q6_K/q8_0 ) 767set_tests_properties ( native_expert_parity_refuses_q6_K PROPERTIES WILL_FAIL TRUE ) 768endif () 769foreach ( _pair${ _strata_parity_pairs }) 770string ( REPLACE "/" "_" _name " ${ _pair } " ) 771add_test ( NAME native_expert_parity_ ${ _name } COMMAND native_expert_parity --synthetic ${ _pair }) 772set_tests_properties ( native_expert_parity_ ${ _name } PROPERTIES TIMEOUT 120 ) 773endforeach () 774add_test ( NAME native_expert_parity_q5_1_min COMMAND native_expert_parity --q5_1-min ) 775# Unsloth v3.1 Qwen3.8-Flash-Next sets (UD-IQ1_M .. UD-IQ4_XS, round 0214): every gate/up x down pair their layers use, 776# at the real shapes (hidden 2560, FF 640): gate/up IQ2_XXS IQ2_XS IQ2_S IQ3_XXS IQ4_XS (+ IQ1_M, the GSQ-RCO packs'), 777# down Q2_0 IQ4_NL Q5_0 Q8_0. Q5_0 down (UD-IQ4_XS 33 layers, UD-Q3_K_XL 20) had no test on this model before. 778foreach ( _gu iq1_m iq2_xxs iq2_xs iq2_s iq3_xxs iq4_xs) 779foreach ( _dn q2_0 iq4_nl q5_0 q8_0) 780add_test ( NAME native_expert_parity_v31_ ${ _gu } _ ${ _dn } COMMAND native_expert_parity --synthetic ${ _gu } / ${ _dn }) 781set_tests_properties ( native_expert_parity_v31_ ${ _gu } _ ${ _dn } PROPERTIES TIMEOUT 180 ) 782endforeach () 783endforeach () 784# the dense projections (Q5_0, Q6_K, Q5_K, Q4_K, Q8_0, IQ4_XS, IQ4_NL ...): decode MMVQ and the prompt's dequantizers 785add_executable ( native_dense_parity src/kernels/native_dense_parity.cpp ) 786target_include_directories ( native_dense_parity PRIVATE ${ _strata_gpu_include_directories }) 787target_link_libraries ( native_dense_parity PRIVATE strata_kernels ggml-base ${ _strata_gpu_runtime_target }) 788add_test ( NAME native_dense_parity COMMAND native_dense_parity ) 789set_tests_properties ( native_dense_parity PROPERTIES SKIP_RETURN_CODE 77 TIMEOUT 300 ) 790# APR: the trellis expert types and the Hadamard activation rotation, when ggml comes from the agention fork 791# (the only tree with these types; marked by its ggml-cuda/tq.cuh) 792if ( STRATA_GGML_DIRAND EXISTS " ${ STRATA_GGML_DIR } /ggml/src/ggml-cuda/tq.cuh" ) 793set ( _strata_tq_pairs tqk6/tqk7 tq2_t/tq2_t ) 794if ( EXISTS " ${ STRATA_GGML_DIR } /ggml/src/ggml-cuda/template-instances/mmq-instance-tqp5.cu" ) # Gyro-L's pair trellis 795list ( APPEND _strata_tq_pairs tqp5/tqp5 tqp6/tqp6 tqp7/tqp7 ) 796endif () 797foreach ( _pair${ _strata_tq_pairs }) 798string ( REPLACE "/" "_" _name " ${ _pair } " ) 799add_test ( NAME native_expert_parity_ ${ _name } COMMAND native_expert_parity --synthetic ${ _pair }) 800add_test ( NAME native_expert_parity_hadamard_ ${ _name } COMMAND native_expert_parity --synthetic-hadamard ${ _pair }) 801set_tests_properties ( native_expert_parity_ ${ _name } native_expert_parity_hadamard_ ${ _name } PROPERTIES TIMEOUT 300 ) 802endforeach () 803endif () 804# #290: the BF16 token embedding (--embd-gguf) gathered and dequantized bit for bit 805add_test ( NAME native_expert_parity_bf16_embd COMMAND native_expert_parity --bf16-embd ) 806endif () 807endif () 808# Round 0214 (the new Unsloth Qwen3.8-Flash-Next quants UD-IQ1_M .. UD-IQ4_XS), CUDA and HIP: every expert type pair the 809# sets use at 2560/640 (GPU decode kernels, the CPU pool and the prompt path's dequantizers against ggml), and the dense 810# tensor types (Q5_0, Q6_K, the K-quants, IQ4_NL, IQ4_XS, Q2_0) through native_mmvq. 811if ( STRATA_BUILD_TESTSAND ( STRATA_ENABLE_CUDAOR STRATA_ENABLE_HIP)) 812set ( _strata_new_gu iq1_m iq2_xxs iq2_xs iq2_s q2_0 iq3_xxs iq4_xs ) 813set ( _strata_new_dn q2_0 iq4_nl q5_0 q8_0 ) 814foreach ( _g${ _strata_new_gu }) 815foreach ( _d${ _strata_new_dn }) 816add_test ( NAME native_expert_parity_new_ ${ _g } _ ${ _d } COMMAND native_expert_parity --synthetic ${ _g } / ${ _d }) 817set_tests_properties ( native_expert_parity_new_ ${ _g } _ ${ _d } PROPERTIES TIMEOUT 300 ) 818endforeach () 819endforeach () 820add_executable ( native_dense_types_parity src/kernels/native_dense_types_parity.cpp ) 821target_include_directories ( native_dense_types_parity PRIVATE ${ _strata_gpu_include_directories }) 822target_link_libraries ( native_dense_types_parity PRIVATE strata_kernels strata_kernels_cpu ${ _strata_gpu_runtime_target }) 823add_test ( NAME native_dense_types_parity COMMAND native_dense_types_parity ) 824set_tests_properties ( native_dense_types_parity PROPERTIES SKIP_RETURN_CODE 77 TIMEOUT 300 ) 825endif () 826# #296's real-weight checks (OrcaRouter Q4_K_S files; docs/ORCA_Q4_K_S.md) - test programs, not part of a release 827if ( STRATA_ENABLE_CUDAAND STRATA_BUILD_TESTS) 828add_executable ( ple_q5_parity src/kernels/ple_q5_parity.cpp ) 829target_link_libraries ( ple_q5_parity PRIVATE strata_kernels strata_artifact ggml-base ${ _strata_gpu_runtime_target }) 830add_executable ( q5_projection_parity src/kernels/q5_projection_parity.cpp ) 831target_include_directories ( q5_projection_parity PRIVATE ${ _strata_gpu_include_directories }) 832target_link_libraries ( q5_projection_parity PRIVATE strata_kernels strata_artifact ggml-base ${ _strata_gpu_runtime_target }) 833# #291: the FP8 PLE table (tools/ple_fp8_pack.py) through PleTable vs the checkpoint's own values 834add_executable ( ple_fp8_parity src/kernels/ple_fp8_parity.cpp ) 835target_link_libraries ( ple_fp8_parity PRIVATE strata_kernels ${ _strata_gpu_runtime_target }) 836endif () 837elseif ( STRATA_BUILD_TESTS) 838# without the native experts (the cpu-check preset) there is no ggml, but the quant layer needs none: its own tests (quant_selftest, 839# nvfp4_decode_model_test) are built and run here too; the ggml oracle tests (quant_parity and the benches against ggml-cpu) stay native-only 840set ( STRATA_QUANT_NO_GGML ON ) 841strata_quant_layer () 842endif () 843 844if ( STRATA_ENABLE_CUDAAND STRATA_BUILD_TESTSAND EXISTS " ${ CMAKE_CURRENT_SOURCE_DIR } /bench/micro/hit_cpu_order_parity.cu" ) 845add_executable ( hit_cpu_order_parity bench/micro/hit_cpu_order_parity.cu ) 846target_link_libraries ( hit_cpu_order_parity PRIVATE strata_kernels strata_kernels_cpu ${ _strata_gpu_runtime_target }) 847endif () 848 849strata_cpu_tests () 850 851# CUDA release kernels must not spill or keep a per-thread array in local memory: every access there is a round trip 852# to device memory in the hottest loops the engine has, and nothing on the build machine says so without -Xptxas -v 853# or a GPU. tools/check_cuda_spills.py reads the resource usage the compiler wrote into the kernel libraries 854# (cuobjdump: STACK and LOCAL per entry function and per sm_) and fails on any kernel outside its ALLOWED table, which 855# carries the measured allowance of the kernels that hold such an array on purpose. CUDA only: HIP has no cuobjdump. 856strata_cuda_spill_guard () 857 858if ( STRATA_BUILD_TESTS) 859enable_testing () 860# Model-level checks may be absent from source distributions. 861if ( EXISTS " ${ CMAKE_CURRENT_SOURCE_DIR } /tests/CMakeLists.txt" ) 862add_subdirectory ( tests ) 863endif () 864endif () 865 866# ---- HIP gfx906: every CUDA source of the tree (and the ggml-cuda MMQ sources) is compiled as HIP ---- 867strata_hip_gfx906_sources () 868 869# ---- strata-split: the opt-in engine that splits every layer across 2-4 NVIDIA cards (src/split, from sFNX, MIT, John Fink) ---- 870# OFF by default, Linux + CUDA or HIP only, no other target depends on it; see src/split/CMakeLists.txt and docs/SPLIT_ENGINE.md. 871option ( STRATA_BUILD_SPLIT "Build strata-split: sFNX's split-every-layer engine, host-memory exchange (Linux, CUDA or HIP gfx1201, 2-4 cards)" OFF ) 872if ( STRATA_BUILD_SPLIT) 873add_subdirectory ( src/split ) 874endif () 875 876# What this configure registered, so a missing capability is a stated skip (tools/check prints this line too). 877if ( STRATA_BUILD_TESTS) 878set ( _strata_test_kinds "cpu" ) 879if ( STRATA_ENABLE_CUDA) 880string ( APPEND _strata_test_kinds ", cuda" ) 881elseif ( STRATA_ENABLE_HIP) 882string ( APPEND _strata_test_kinds ", hip" ) 883else () 884string ( APPEND _strata_test_kinds " (gpu tests not registered: neither STRATA_ENABLE_CUDA nor STRATA_ENABLE_HIP is on)" ) 885endif () 886if ( NOT STRATA_NATIVE_EXPERTS) 887string ( APPEND _strata_test_kinds " (native-expert tests not registered: STRATA_NATIVE_EXPERTS=OFF)" ) 888endif () 889message ( STATUS "strata tests: ON - ${ _strata_test_kinds } " ) 890else () 891message ( STATUS "strata tests: OFF (STRATA_BUILD_TESTS=OFF)" ) 892endif () 893 894# the SCR move kernels' parity test (needs a CUDA device) 895option ( STRATA_BUILD_SCR_TESTS "Build the SCR kernel parity test" OFF ) 896if ( STRATA_BUILD_SCR_TESTSAND TARGET strata_kernels) 897add_executable ( scr_move_parity src/kernels/scr_move_parity.cu ) 898target_include_directories ( scr_move_parity PRIVATE include ) 899target_link_libraries ( scr_move_parity PRIVATE strata_kernels ) 900endif () 901include ( cmake/strata_dsv41.cmake )