okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
4786a2e7d
main
1// src/core/arch_defaults.cpp - see include/strata/core/arch_defaults.hpp. 2#include "strata/core/arch_defaults.hpp" 3#include "strata/core/defaults_026.hpp" 4#include "strata/core/amd_community.hpp" 5#include "strata/core/gfx12_extra.hpp" 6 7#include "strata/kernels/gfx_arch.hpp" 8 9#include <cstdio> 10#include <cstdlib> 11#include <cstring> 12 13namespace strata::core { 14 15std::vector < std::pair < std::string , std::string >> arch_default_env (const char * gcn_arch ) { 16return arch_default_env (gcn_arch , strata::qwen_defaults_026 ()); 17} 18 19std::vector < std::pair < std::string , std::string >> arch_default_env (const char * gcn_arch ,bool defaults026 ) { 20#if defined(_WIN32 ) 21return arch_default_env (gcn_arch ,defaults026 , true); 22#else 23return arch_default_env (gcn_arch ,defaults026 , false); 24#endif 25} 26 27std::vector < std::pair < std::string , std::string >> arch_default_env (const char * gcn_arch ,bool defaults026 ,bool windows ) { 28 std::vector < std::pair < std::string , std::string >> t ; 29if (strata::kernels::gfx_arch_is_gfx12 (gcn_arch )) { 30// gfx1200 / gfx1201 (RDNA4): the PROMPT half of the gfx1151 table (reported exact on an R9700 in #1478, re-checked 31// bitwise in notes-142-amd.md) plus four decode switches measured one at a time on an R9700 in 0.2.7 (p620, IQ3_S, 32// engine 0.1.51, 8K prompt, rotated pairs): ATTN_LANECELL + ATTN_MERGE_V2 +1.9%, TSUM +1.9%, EXPDEC +0.6%, GDN_SPLIT 33// 0.0%; the four together +3.5% (3/3 pairs) with the answer md5 identical to the default. The rest of the gfx1151 34// decode half stays out (PF_GEMM/PF_FUSED are bit-changing; Q8_PACKED, SH_STREAM and QFUSE were measured on other 35// cards only, and the whole half measured slower here when it was tried as one block). 36// STRATA_HCD_EXACT is left out: it needs the gfx1151 hipBLASLt tuning table, finds none on gfx12, says so on every start 37// and does nothing (measured: with and without it identical, 0.0 to +0.1%). 38// STRATA_GDN_CONVL2 is AMD-only on purpose: it is not bitwise on CUDA 13.3 sm_120 (#1522), and this table is never 39// consulted by a CUDA build. 40const char * off12 = std::getenv ("STRATA_GFX12_DEFAULTS" ); 41if (off12 != nullptr && off12 [0 ]== '0' )return t ; 42t = { 43 {"STRATA_GDN_HEAD" ,"1" }, 44 {"STRATA_GDN_PP" ,"2" }, 45 {"STRATA_GDN_CONVL2" ,"1" }, 46 {"STRATA_GDN_NOY" ,"1" }, 47 {"STRATA_CVEC_FUSE" ,"1" }, 48 }; 49if (defaults026 )return t ;// STRATA_DEFAULTS=026: v0.2.6's table, the prompt half only 50// decode (bit-identical on the R9700 measurement above) 51t .push_back ({"STRATA_ATTN_LANECELL" ,"1" }); 52t .push_back ({"STRATA_ATTN_MERGE_V2" ,"1" }); 53t .push_back ({"STRATA_TSUM" ,"1" }); 54t .push_back ({"STRATA_EXPDEC" ,"1" }); 55// AMD-Q (p620, R9700, IQ3_S, serve, interleaved pairs): the constant-trip loads of Blackwell's BW-DENSE (bit 0 the router-shaped bf16 read, 56// bit 1 the GDN a/b projection) and two load-ordering variants of the Q8 hyper-connection read (2 rows a warp loaded together in the 57// up read, the down read's staging loads of all tokens together); each is the same arithmetic in the same order (kernel hashes equal). 58t .push_back ({"STRATA_SMALL_UNR" ,"3" }); 59t .push_back ({"STRATA_GR_Q32_G" ,"2" }); 60t .push_back ({"STRATA_GR_Q8_PFS" ,"1" }); 61return t ; 62 } 63if (!strata::kernels::gfx_arch_is_gfx1151 (gcn_arch ))return t ; 64const char * off = std::getenv ("STRATA_GFX1151_DEFAULTS" ); 65if (off != nullptr && off [0 ]== '0' )return t ; 66// Exact (bitwise) on Aurora, each with its measured gain in aurora_s23.md: 67t = { 68// prompt 69 {"STRATA_GDN_HEAD" ,"1" },// the GDN recurrence, four lanes a column + the grid-stride norm (S23) 70 {"STRATA_GDN_PP" ,"2" },// two columns per lane: 64K prompt +2.9% (stream A, round 2) 71 {"STRATA_GDN_CONVL2" ,"1" },// conv + q/k L2 norm in one kernel: 64K -0.3 s (stream A) 72 {"STRATA_GDN_NOY" ,"1" },// no dead FP32 store of the norm (stream A) 73 {"STRATA_CVEC_FUSE" ,"1" },// a steered layer's write, control vector and next norm in one pass (S23) 74 {"STRATA_HCD_EXACT" ,"1" },// the HC down GEMM in hipBLASLt solution 1176's k order: 64K +1.8% (stream S) 75 {"STRATA_PF_PAD" ,"1" },// padded GEMM row strides (acts with STRATA_PF_GEMM; inert without it) (S23) 76 {"STRATA_TOPK_REG_MIN_BLOCKS" ,"4096" },// the register top-k from 16K cells, not 28K: same ids; per 2,048 queries the ref takes 1.0 / 2.4 / 3.9 ms at 16K / 20K / 24K cells, the scan 0.87 / 0.93 / 1.00 77// decode 78 {"STRATA_Q8_PACKED" ,"1" },// the packed Q8_0 decode layout: +2.3% (S26) 79 {"STRATA_Q6_PACKED" ,"1" },// the packed Q6_K heads (S26) 80 {"STRATA_MMVF_ROWS" ,"1" },// bf16 multi-row GEMV, 4 rows per block (S25) 81 {"STRATA_ATTN_LANECELL" ,"1" },// decode attention scores, one cell per thread (S25) 82 {"STRATA_EXPERT_V2" ,"1" },// the grouped decode experts, IQ3_S gate/up + IQ4_NL down (S26) 83 {"STRATA_TSUM" ,"1" },// several warp sums as one transposed butterfly (S26) 84 {"STRATA_LFUSE" ,"1" },// fewer launches around the shared expert and the KV append (S26) 85 {"STRATA_GDN_SPLIT" ,"1" },// the GDN step over 4 blocks per head (S25/S26) 86 {"STRATA_QFUSE" ,"1" },// activation q8_1 images written by their producers (S26) 87 {"STRATA_PLE_BATCH" ,"1" },// the verify window's PLE key / value projections at once (S25) 88 {"STRATA_SH_STREAM" ,"1" },// the shared expert on its own stream: decode +1.8% / +6.7% (UD-Q4_K_XL) (140-m) 89 }; 90// 0.2.7: Windows gfx1151 leaves the shared-expert fork off (the HIP default). Interleaved A/B on a Strix Halo Windows PC (Qwen 91// IQ3_S, engine 0.1.51, 9 chat answers each, 4K prompt): decode 43.9 / 43.6 / 43.2 tok/s with it, 48.3 / 46.0 / 46.6 without 92// (+6.9% median), prompts unchanged, the token ids identical either way (docs/STRIX_HALO_WINDOWS.md). Linux gfx1151 keeps the 93// fork on until it is measured there. STRATA_SH_STREAM=1 turns it back on; STRATA_DEFAULTS=026 keeps v0.2.6's table. 94if (windows && !defaults026 ) { 95for (auto it = t .begin ();it != t .end ();++ it ) { 96if (it -> first == "STRATA_SH_STREAM" ) {t .erase (it );break ; } 97 } 98// round 0215 (STRIX-PK): two load-ordering switches of the decode kernels, each the same arithmetic in the same order as without it 99// (the kernel hashes are equal; first-token logits and outputs identical in the engine). UD-Q4_K_XL on a Strix Halo Windows PC, DFlash2 100// serve, 4 request rounds x 2 passes x 4 prompts, interleaved: window time -0.25% (25 of 32 pairs faster, the same window and token count in 101// every pair), alone +0.2% / +0.3%. Small but consistent; Linux gfx1151 is unmeasured and keeps its table. 102t .push_back ({"STRATA_SMALL_UNR" ,"3" }); 103t .push_back ({"STRATA_GR_Q8_PFS" ,"1" }); 104 } 105return t ; 106} 107 108bool gfx12_prefill_share_default (const char * gcn_arch ,bool defaults026 ) { 109if (defaults026 || !strata::kernels::gfx_arch_is_gfx12 (gcn_arch ))return false; 110const char * off12 = std::getenv ("STRATA_GFX12_DEFAULTS" ); 111return !(off12 != nullptr && off12 [0 ]== '0' ); 112} 113 114bool gfx12_prefill_share_default (const char * gcn_arch ) { 115return gfx12_prefill_share_default (gcn_arch , strata::qwen_defaults_026 ()); 116} 117 118bool igpu_prompt_defaults_arch (const char * gcn_arch ) { 119return strata::kernels::gfx_arch_is (gcn_arch ,"gfx1103" )|| strata::kernels::gfx_arch_is (gcn_arch ,"gfx1150" )|| 120 strata::kernels::gfx_arch_is (gcn_arch ,"gfx1151" ); 121} 122 123bool igpu_prompt_set_enabled (const char * gcn_arch ,bool windows ) { 124const char * off = std::getenv ("STRATA_IGPU_DEFAULTS" ); 125if (off != nullptr && off [0 ]== '0' )return false; 126const char * e = std::getenv ("STRATA_IGPU_PROMPT_SET" ); 127if (e != nullptr && e [0 ]== '1' )return true; 128if (e != nullptr && e [0 ]== '0' )return false; 129// 0.2.8: Strix Halo (gfx1151) gets the matrix-core prompt set on Windows by default. Measured on the strix box 130// (Qwen3.8-Flash-Next IQ3_S, engine 0.1.52, ids prompts of 4,095 / 8,191 tokens, interleaved pairs, one engine at a 131// time): 4K 690 -> 1,090 and 8K 785 -> 1,183 on the f-024-strix-pp branch (0.2.3 engine, the same switches as 132// environment variables), i.e. x1.58 / x1.51; the first-token KL against the accepted HC_Q8 bar was 0.0088 mean 133// (0.0228 allowed), top-1 the same on every prompt. Linux gfx1151 stays opt-in until it is measured there; gfx1103 134// keeps its own rule below. 135if (windows && strata::kernels::gfx_arch_is (gcn_arch ,"gfx1151" ))return true; 136return kIgpuPromptSetDefaultOn && !windows && strata::kernels::gfx_arch_is (gcn_arch ,"gfx1103" ); 137} 138 139bool igpu_uma_arena_default (const char * gcn_arch ,bool integrated ,bool windows ,bool on ) { 140if (!integrated )return false; 141const char * reg = std::getenv ("STRATA_UMA_REGISTER" ); 142if (reg != nullptr && reg [0 ]== '1' )return false; 143// 0.2.1.2: a Strix Halo (gfx1151) on Windows. Registering the 47 GiB arena with the driver took ALL the free VRAM (91 GiB before, 144// 0 after; BIOS carve-out 64 GB + 32 GB shared): the expert cache got 0 slots and the engine exited ("the embedding buffer 145// failed"), 3 of 3 starts (notes-022-strix.md). Unregistered, the arena is held by the working-set lock and the cache gets 146// 24,576 slots. Independent of `on` (that is the 780M's opt-in). STRATA_ARENA_PIN_GIB=N / 0 still registers it. 147if (windows )return strata::kernels::gfx_arch_is (gcn_arch ,"gfx1151" ); 148return on && strata::kernels::gfx_arch_is (gcn_arch ,"gfx1103" ); 149} 150 151bool igpu_arena_no_thp_default (const char * gcn_arch ,bool integrated ,bool windows ) { 152if (!integrated || windows )return false; 153return strata::kernels::gfx_arch_is (gcn_arch ,"gfx1103" )|| strata::kernels::gfx_arch_is (gcn_arch ,"gfx1150" )|| 154 strata::kernels::gfx_arch_is (gcn_arch ,"gfx1151" ); 155} 156 157bool igpu_kfd_settle_default (const char * gcn_arch ,bool integrated ,bool windows ) { 158return igpu_arena_no_thp_default (gcn_arch ,integrated ,windows );// the same device class 159} 160 161bool igpu_cache_drop_default (const char * gcn_arch ,bool integrated ,bool windows ) { 162return igpu_arena_no_thp_default (gcn_arch ,integrated ,windows );// the same device class 163} 164 165bool igpu_fused_prompt_default (const char * gcn_arch ,bool integrated ,bool windows ) { 166return igpu_arena_no_thp_default (gcn_arch ,integrated ,windows );// the same device class 167} 168 169std::vector < std::pair < std::string , std::string >> igpu_default_env (const char * gcn_arch ,bool integrated ) { 170 std::vector < std::pair < std::string , std::string >> t ; 171if (!integrated || !igpu_prompt_defaults_arch (gcn_arch ))return t ; 172#if defined(_WIN32 ) 173const bool win = true; 174#else 175const bool win = false; 176#endif 177if (!igpu_prompt_set_enabled (gcn_arch ,win ))return t ; 178// Measured on a Radeon 780M (gfx1103, P2006, Q2_0, notes-153-igpu.md / notes-148-amd.md): prompts 109.5 -> 214.7 tok/s 179// with the first four, 233 with HC_UPMIX, decode unchanged. Dense projections are 63% of a prompt's GPU time there. 180t = { 181 {"STRATA_HIP_WMMA" ,"1" },// the prompt attention on matrix cores 182 {"STRATA_PF_GEMM" ,"1" },// the prompt's FP16 projections on the 128 x 256 WMMA GEMM 183 {"STRATA_PA_FAST" ,"1" },// the prompt attention with single FP16 q and p 184 {"STRATA_SELECT_WMMA" ,"1" },// the block scorer on matrix cores 185 {"STRATA_HC_UPMIX" ,"1" },// the hyper-connection up projection with its epilogue 186 }; 187// gfx1151 (Strix Halo) on Windows: SELECT_WMMA is in since 0.2.9 (x1.008 at 8K, x1.037 at 32K, x1.077 at 64K), and PF_FUSED (the 188// fused int8 gate/up prompt experts, #136) measured x1.12 there and joins the set. The 780M and the 890M keep the 189// table above exactly as measured on them. 190if (win && strata::kernels::gfx_arch_is (gcn_arch ,"gfx1151" )) { 191t = { 192 {"STRATA_HIP_WMMA" ,"1" }, 193 {"STRATA_PF_GEMM" ,"1" }, 194 {"STRATA_PA_FAST" ,"1" }, 195 {"STRATA_HC_UPMIX" ,"1" }, 196 {"STRATA_PF_FUSED" ,"1" }, 197 {"STRATA_SELECT_WMMA" ,"1" },// 0.2.9: the block scorer on matrix cores; not bitwise (about 10 of 2,051 selected cells flip at the cutoff 198// for queries past ~5K tokens), x1.008 at 8K, x1.037 at 32K, x1.077 at 64K (STRIX-Q-RESULTS.md) 199// 0.2.9 (owner, 10-30: a consistent Strix Halo speed gain goes on by default): the prompt experts of every covered 200// format on the F16 matrix-core kernels (the Q8_0 down layers of the Unsloth files included). Windows gfx1151, 201// interleaved x3, same 16 greedy ids: IQ3_S 4K 1,187 -> 1,296 and 8K 1,285 -> 1,399 tok/s (x1.09), UD-IQ4_XS 4K 1,119 -> 202// 1,221 and 8K 1,180 -> 1,270; decode unchanged. The rounding differs from the int8 kernels (KL is information only). 203 {"STRATA_PF_F16" ,"1" }, 204// Round 0215 (STRIX-FIT): the down rows of the F16 expert kernels go to the combine as FP16 (half the bytes written and read). Windows gfx1151, 205// interleaved 8K pairs, same engine: IQ3_S x1.022 (4 of 4 pairs), UD-IQ4_XS x1.026 (3 of 3), UD-Q4_K_XL x1.012 (3 of 4); the first-token KL 206// is 1e-4 at 8K and 0.02-0.04 on agent transcripts (information). STRATA_PF_DM16=0 turns it off. 207 {"STRATA_PF_DM16" ,"1" }, 208// The Q4_K gate/up + Q5_1 down layers (43 of 48 in UD-Q4_K_XL) on the F16 WMMA kernels of src/prefill/moe_p1a.cu; other layers 209// and packs keep the kernels above. Windows gfx1151, UD-Q4_K_XL, 5 interleaved pairs: prompt x1.046 (4K), x1.043 (8K), 210// x1.043 (32K), decode unchanged (job strix-20261114-1347-9a28). KL to the FP16 truth, 24 prompts a size: on 0.0112 / 0.0116 211// against off 0.0179 / 0.0118 at 4K / 8K (job strix-20261114-1347-238b). STRATA_PF_P1A=0 turns it off. 212 {"STRATA_PF_P1A" ,"1" }, 213 }; 214 } 215return t ; 216} 217 218static void set_default (const std::pair < std::string , std::string >& kv ) { 219#if defined(_WIN32 ) 220_putenv_s (kv .first .c_str (),kv .second .c_str ()); 221#else 222setenv (kv .first .c_str (),kv .second .c_str (),0 ); 223#endif 224} 225 226static std::vector < std::pair < std::string , std::string >> parallel_stack_table () { 227return { 228 {"STRATA_CKPT_POOL" ,"1" }, 229 {"STRATA_CKPT_POOL_READY" ,"4" }, 230 {"STRATA_SLOT_CKPT_MOVE" ,"1" }, 231 {"STRATA_SLOT_COPY_DIRECT" ,"1" }, 232 {"STRATA_SLOT_COPY_BATCHSYNC" ,"1" }, 233 {"STRATA_BATCH_GDN_GROUPS" ,"1" }, 234 {"STRATA_BATCH_ATTN_ROWS" ,"1" }, 235 {"STRATA_BATCH_SELF_COMMIT" ,"1" }, 236 {"STRATA_QSA_SLOTS" ,"1" }, 237 }; 238} 239 240std::vector < std::pair < std::string , std::string >> parallel_default_env (const char * gcn_arch ,bool windows ,int batch_slots ) { 241 std::vector < std::pair < std::string , std::string >> t ; 242if (!windows || batch_slots < 2 || !strata::kernels::gfx_arch_is_gfx1151 (gcn_arch ))return t ; 243const char * off = std::getenv ("STRATA_GFX1151_DEFAULTS" ); 244if (off != nullptr && off [0 ]== '0' )return t ; 245return parallel_stack_table (); 246} 247 248std::vector < std::pair < std::string , std::string >> parallel_default_env_cuda (bool linux_cuda ,int batch_slots ) { 249if (!linux_cuda || batch_slots < 2 )return {}; 250return parallel_stack_table (); 251} 252 253std::vector < std::string > apply_parallel_defaults_cuda (bool linux_cuda ,int batch_slots ) { 254 std::vector < std::string > set ; 255for (const auto & kv :parallel_default_env_cuda (linux_cuda ,batch_slots )) { 256if (std::getenv (kv .first .c_str ())!= nullptr )continue ;// the user's setting wins, =0 included 257set_default (kv ); 258set .push_back (kv .first ); 259 } 260return set ; 261} 262 263std::vector < std::pair < std::string , std::string >> gdn_default_env_cuda (bool linux_cuda ) { 264if (!linux_cuda )return {}; 265return {{"STRATA_GDN_TC" ,"1" }, {"STRATA_GDN_CONVL2" ,"2" }}; 266} 267 268std::vector < std::string > apply_gdn_defaults_cuda (bool linux_cuda ) { 269 std::vector < std::string > set ; 270for (const auto & kv :gdn_default_env_cuda (linux_cuda )) { 271if (std::getenv (kv .first .c_str ())!= nullptr )continue ;// the user's setting wins, =0 included 272set_default (kv ); 273set .push_back (kv .first ); 274 } 275return set ; 276} 277 278std::vector < std::pair < std::string , std::string >> gdn_chunked_default_env (bool linux_host ,bool all_gfx12 ) { 279if (!linux_host || !all_gfx12 )return {}; 280return {{"STRATA_GDN_CHUNKED" ,"1" }}; 281} 282 283std::vector < std::string > apply_gdn_chunked_default (bool linux_host ,bool all_gfx12 ) { 284 std::vector < std::string > set ; 285for (const auto & kv :gdn_chunked_default_env (linux_host ,all_gfx12 )) { 286if (std::getenv (kv .first .c_str ())!= nullptr )continue ;// the user's setting wins, =0 included 287set_default (kv ); 288set .push_back (kv .first ); 289 } 290return set ; 291} 292 293std::vector < std::pair < std::string , std::string >> launch_default_env (const char * gcn_arch ,bool windows ) { 294 std::vector < std::pair < std::string , std::string >> t ; 295if (!windows || !strata::kernels::gfx_arch_is_gfx1151 (gcn_arch ))return t ; 296const char * off = std::getenv ("STRATA_GFX1151_DEFAULTS" ); 297if (off != nullptr && off [0 ]== '0' )return t ; 298t = {{"STRATA_VERIFY_ASYNC_LAUNCH" ,"1" }}; 299return t ; 300} 301 302std::vector < std::string > apply_arch_defaults (const char * gcn_arch ,bool integrated ,int batch_slots ,bool mmq_built ) { 303 std::vector < std::string > set ; 304// the community-made gfx1010 / gfx1030 changes (amd_community.hpp): one line, and only on those two cards 305if (const std::string note = strata::amd_community::startup_line (gcn_arch ); !note .empty ()) 306 std::fprintf (stderr ,"%s\n" ,note .c_str ()); 307for (const auto & kv :arch_default_env (gcn_arch )) { 308if (std::getenv (kv .first .c_str ())!= nullptr )continue ;// the user's setting wins, whatever it is 309set_default (kv ); 310set .push_back (kv .first ); 311 } 312 {// gfx12 extras kept apart from the table (gfx12_extra.hpp); not counted in the returned list 313 std::vector < std::string > extra ; 314for (const auto & kv :gfx12_exact_extra_env (gcn_arch )) { 315if (std::getenv (kv .first .c_str ())!= nullptr )continue ; 316set_default (kv ); 317extra .push_back (kv .first ); 318 } 319if (!extra .empty ()) { 320 std::fprintf (stderr ,"strata: gfx12 (RDNA4): exact extra switches on by default (STRATA_GFX12_DEFAULTS=0 turns them off; a switch you set is kept): " ); 321for (size_t i = 0 ;i < extra .size ();++ i ) std::fprintf (stderr ,"%s%s" ,i ?" " :"" ,extra [i ].c_str ()+ 7 ); 322 std::fprintf (stderr ,"\n" ); 323 } 324 } 325 {// gfx12 defaults that change the answers (gfx12_extra.hpp): the matrix-core QSA scorer from 28,672 tokens; its own line 326const auto vc = gfx12_value_changing_env (gcn_arch ); 327bool any = false,kq = false; 328for (const auto & kv :vc ) { 329if (std::getenv (kv .first .c_str ())!= nullptr )continue ; 330set_default (kv ); 331if (kv .first == "STRATA_MMQ_KQ" )kq = true;else any = true; 332 } 333if (kq && !mmq_built )// a build without MMQ: the 'prompt kernels' line (prefill.cpp mmq_plan) follows in every such build once a prompt runs 334 std::fprintf (stderr ,"strata: gfx12 (RDNA4): a model with K-quant experts (Unsloth UD-Q4/Q5/Q6_K_XL) reads its prompt on Strata's own kernels; " 335"the 'prompt kernels' line below gives the counts\n" ); 336else if (kq )// the engine says nothing more on a pack without K-quant experts: the variable is never read there 337 std::fprintf (stderr ,"strata: gfx12 (RDNA4): a model with K-quant experts (Unsloth UD-Q4/Q5/Q6_K_XL) reads its prompt on llama.cpp's MMQ kernels (+10..17%% prompt speed on an R9700, " 338"first-token KL against the FP16 path about 0.03; STRATA_MMQ_KQ=0 or STRATA_GFX12_DEFAULTS=0 turns it off)\n" ); 339const char * wm = std::getenv ("STRATA_SELECT_WMMA" );// the line is only true while the scorer switch is not set to 0 340if (any && !(wm != nullptr && wm [0 ]== '0' )) 341 std::fprintf (stderr ,"strata: gfx12 (RDNA4): the matrix-core QSA block scorer is on once a prompt is past 28,672 tokens (+5.7%% prompt speed at 98K on an R9700, shorter prompts unchanged; " 342"the first-token KL against the warp kernel is 0.002 on average above 30K; STRATA_SELECT_WMMA=0 or STRATA_GFX12_DEFAULTS=0 turns it off)\n" ); 343 } 344if (strata::kernels::gfx_arch_is_gfx12 (gcn_arch )&& std::getenv ("STRATA_GDN_CHUNKED" )== nullptr ) {// the length-gated chunked GDN scan (prefill/kernels.cu: gdn_chunked_auto) 345const char * off12 = std::getenv ("STRATA_GFX12_DEFAULTS" ); 346if (!(off12 != nullptr && off12 [0 ]== '0' )) 347 std::fprintf (stderr ,"strata: RDNA4 (gfx12): prompt chunks of 30,000+ tokens use the chunked GDN scan (STRATA_GDN_CHUNKED=0 turns it off)\n" ); 348 } 349if (!set .empty ()) { 350const bool g12 = strata::kernels::gfx_arch_is_gfx12 (gcn_arch ); 351 std::fprintf (stderr ,"strata: %s: %zu exact speed switches on by default (%s=0 turns " 352"them off; a switch you set is kept): " , 353g12 ?"gfx12 (RDNA4)" :"gfx1151 (Strix Halo)" ,set .size (), 354g12 ?"STRATA_GFX12_DEFAULTS" :"STRATA_GFX1151_DEFAULTS" ); 355for (size_t i = 0 ;i < set .size ();++ i ) std::fprintf (stderr ,"%s%s" ,i ?" " :"" ,set [i ].c_str ()+ 7 ); 356 std::fprintf (stderr ,"\n" ); 357 } 358 std::vector < std::string > igpu ; 359for (const auto & kv :igpu_default_env (gcn_arch ,integrated )) { 360if (std::getenv (kv .first .c_str ())!= nullptr )continue ; 361set_default (kv ); 362igpu .push_back (kv .first ); 363 } 364if (!igpu .empty ()) { 365 std::fprintf (stderr ,"strata: integrated GPU (%s): the matrix-core prompt set is on (1.6x to 2x faster prompts on a " 366"Radeon 780M, the answers differ in the last bits): " ,gcn_arch ); 367for (size_t i = 0 ;i < igpu .size ();++ i ) std::fprintf (stderr ,"%s%s" ,i ?" " :"" ,igpu [i ].c_str ()+ 7 ); 368 std::fprintf (stderr ,". Turn one off with NAME=0 (for example STRATA_HC_UPMIX=0), all of them with STRATA_IGPU_PROMPT_SET=0" ); 369#if defined(_WIN32 ) 370 std::fprintf (stderr ,". Not yet tested on Windows" ); 371#endif 372 std::fprintf (stderr ,"\n" ); 373set .insert (set .end (),igpu .begin (),igpu .end ()); 374 } 375 std::vector < std::string > par ; 376#if defined(_WIN32 ) 377const bool win_host = true; 378#else 379const bool win_host = false; 380#endif 381// Linux integrated gfx11 (gfx1103 / gfx1150 / gfx1151): the prompt experts on Strata's fused int8 kernels. Silent: the prefill's own line 382// ("prompt experts on the fused int8 kernels (STRATA_PF_FUSED=1 ...") is printed when the kernels are taken. A value the user set is kept (=0 = MMQ). 383if (igpu_fused_prompt_default (gcn_arch ,integrated ,win_host )&& std::getenv ("STRATA_PF_FUSED" )== nullptr ) 384set_default ({"STRATA_PF_FUSED" ,"1" }); 385for (const auto & kv :parallel_default_env (gcn_arch ,win_host ,batch_slots )) { 386if (std::getenv (kv .first .c_str ())!= nullptr )continue ; 387set_default (kv ); 388par .push_back (kv .first ); 389 } 390if (!par .empty ()) { 391 std::fprintf (stderr ,"strata: gfx1151 (Strix Halo): the exact parallel-request switches are on for %d batch slots (STRATA_GFX1151_DEFAULTS=0 turns them off; a switch you set is kept): " ,batch_slots ); 392for (size_t i = 0 ;i < par .size ();++ i ) std::fprintf (stderr ,"%s%s" ,i ?" " :"" ,par [i ].c_str ()+ 7 ); 393 std::fprintf (stderr ,"\n" ); 394set .insert (set .end (),par .begin (),par .end ()); 395 } 396 std::vector < std::string > lau ; 397for (const auto & kv :launch_default_env (gcn_arch ,win_host )) { 398if (std::getenv (kv .first .c_str ())!= nullptr )continue ; 399set_default (kv ); 400lau .push_back (kv .first ); 401 } 402if (!lau .empty ()) { 403 std::fprintf (stderr ,"strata: gfx1151 (Strix Halo): the verify window's graph is launched from a helper thread (the main thread serves the doorbells meanwhile; STRATA_GFX1151_DEFAULTS=0 or STRATA_VERIFY_ASYNC_LAUNCH=0 turns it off)\n" ); 404set .insert (set .end (),lau .begin (),lau .end ()); 405 } 406return set ; 407} 408 409}// namespace strata::core