okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
7f46672a4
main
1// metal/src/engine/msl_libs.h - the kernel libraries the engine compiles: which .metal files, in which order, with which 2// prelude. One place, so that the engine (window.cpp, prompt_chain.inc, dflash2.inc) and metal/tests/msl_dump.cpp, which 3// compiles the same libraries without starting an engine, cannot drift apart: STRATA_METAL_MSL_DUMP=<dir> writes the exact 4// text of every library handed to the compiler, and tools/msl_text_check.py compares two such dumps. 5// 6// `engine_dir`: the folder with the engine's own kernels (src/engine/msl). `kq`: the prelude kq_down_prelude() gives for the 7// model (K-quant / IQ down experts). `f16`: STRATA_METAL_F16. The libraries that read GEO_* macros (moe, glue, gr, qsa, prompt) start 8// with geo::prelude(): empty for a Flash-Next build, so the text of such a library is what it was. 9#pragma once 10 11#include "geo.h" 12 13#include <string> 14#include <vector> 15 16namespace strata_metal { 17 18struct MslLib { 19std ::vector < std ::string > files ; 20std ::string prelude ; 21}; 22 23inline const char * kNoGgmlCommon = "#define NO_GGML_COMMON 1\n" ; 24 25// the decode window 26inline MslLib lib_core (bool f16 ,const std ::string & kq ) { 27return {{"quant.metal" ,"units.metal" ,"moe.metal" ,"gemv.metal" ,"router.metal" ,"gr.metal" ,"gr2.metal" ,"glue.metal" }, 28geo ::prelude ()+ (f16 ?std ::string ("#define STRATA_METAL_F16 1\n" ) :std ::string ())+ kq }; 29} 30inline MslLib lib_gdn () {return {{"gdn.metal" },kNoGgmlCommon }; } 31inline MslLib lib_qsa () {return {{"qsa.metal" ,"qsa2.metal" },geo ::prelude ()+ kNoGgmlCommon }; } 32inline MslLib lib_sample () {return {{"sample.metal" },kNoGgmlCommon }; } 33inline MslLib lib_ple (const std ::string & engine_dir ) {return {{engine_dir + "/ple.metal" },kNoGgmlCommon }; } 34// the MTP draft layer 35inline MslLib lib_mtp (const std ::string & engine_dir ) {return {{engine_dir + "/mtp.metal" },kNoGgmlCommon }; } 36inline MslLib lib_mtp_chain (const std ::string & engine_dir ) {return {{"quant.metal" ,"units.metal" ,engine_dir + "/mtp_chain.metal" },"" }; } 37// DFlash2 38inline MslLib lib_dflash2 (const std ::string & engine_dir ) {return {{engine_dir + "/dflash2.metal" },kNoGgmlCommon }; } 39// the prompt on the matrix units: PromptGemm (window.cpp) and the prompt chain (prompt_chain.inc) share the lists 40inline MslLib lib_prompt (const std ::string & kq ) { 41return {{"quant.metal" ,"units.metal" ,"mma.metal" ,"dense_mm.metal" ,"moe_mm.metal" ,"gr.metal" ,"gemv.metal" ,"prompt.metal" },geo ::prelude ()+ kq }; 42} 43inline MslLib lib_prompt_gdn () {return {{"gdn.metal" ,"gdn_prompt.metal" },kNoGgmlCommon }; } 44inline MslLib lib_prompt_qsa () {return {{"qsa.metal" ,"qsa_prompt.metal" },geo ::prelude ()+ kNoGgmlCommon }; } 45inline MslLib lib_coop_probe () {return {{"mm_bench.metal" },kNoGgmlCommon }; } 46 47}// namespace strata_metal