okami.mom/strata

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

Niko1221Merge f-q4-metal (ed1f58d27): the Mac (Metal) engine follows the compiled geometry (q4_lite/q4_mid/q4_big kernel parity 40/40, gate 2 like CUDA), plus the PLE row-buffer fix in src/program/generate.cpp (sized by the compiled hidden size, not 2560; it overran 24 KB at hidden 4096 and crashed Metal serve); default build unchanged (CUDA SASS 3573/3573 and 160/160 host objects, HIP gfx1201/gfx1151 string offsets only, SYCL 129/129 objects and 22/22 checksums, Metal per-token functions identical, UD-Q4_K_XL 10/10 tokens, CUDA IQ3_S 26/26 tokens) (Qwen4 prep)7f46672a4

main
2.7 KiB47 linesraw
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 {
19    std::vector<std::string> files;
20    std::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) {
27    return {{"quant.metal", "units.metal", "moe.metal", "gemv.metal", "router.metal", "gr.metal", "gr2.metal", "glue.metal"},
28            geo::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) {
41    return {{"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