From c77292f09dbee2a6952b38446cd2790b7ef0b468 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Mon, 26 Oct 2026 22:28:05 +0100 Subject: [PATCH] gfx1151 on Windows: the shared-expert fork (STRATA_SH_STREAM) is off by default Interleaved A/B on a Strix Halo Windows PC (Qwen IQ3_S, engine 0.1.51): chat decode 43.6 tok/s with the fork, 46.6 without (+6.9%), prompts unchanged. Linux gfx1151 and every other architecture keep their table. STRATA_SH_STREAM=1 turns it back on, STRATA_DEFAULTS=026 keeps v0.2.6's table. arch_default_env(arch, defaults026, windows) is a pure rule; arch_defaults_test checks both platforms. --- include/strata/core/arch_defaults.hpp | 4 ++ src/core/arch_defaults.cpp | 17 ++++++++ src/core/arch_defaults_test.cpp | 60 +++++++++++++++++++++++++++ src/core/verify.cpp | 4 +- 4 files changed, 84 insertions(+), 1 deletion(-) diff --git a/include/strata/core/arch_defaults.hpp b/include/strata/core/arch_defaults.hpp index 7062f4b2..2025af48 100644 --- a/include/strata/core/arch_defaults.hpp +++ b/include/strata/core/arch_defaults.hpp @@ -21,6 +21,10 @@ namespace strata::core { /// "gfx1151:sramecc-:xnack-"): empty for every other architecture. `defaults026` (STRATA_DEFAULTS=026, defaults_026.hpp): the gfx12 table of /// v0.2.6 (the five prompt switches only, without the four 0.2.7 decode switches); the one-argument form asks the environment. std::vector> arch_default_env(const char* gcn_arch, bool defaults026); +/// The same with the platform given instead of read from the build (a pure rule, so a test can check both). 0.2.7: on Windows the gfx1151 +/// table leaves STRATA_SH_STREAM out (the fork is off, +6.9% decode on a Strix Halo Windows PC, same ids); Linux gfx1151 and every +/// other architecture are unchanged; `defaults026` keeps it in on both. An explicit STRATA_SH_STREAM=1 turns the fork on anywhere. +std::vector> arch_default_env(const char* gcn_arch, bool defaults026, bool windows); std::vector> arch_default_env(const char* gcn_arch); /// The integrated Radeons (Phoenix / Hawk Point 780M gfx1103, Strix Point 890M / 880M gfx1150, Strix Halo gfx1151) whose diff --git a/src/core/arch_defaults.cpp b/src/core/arch_defaults.cpp index 47b9ba7a..7f2a89fd 100644 --- a/src/core/arch_defaults.cpp +++ b/src/core/arch_defaults.cpp @@ -15,6 +15,14 @@ std::vector> arch_default_env(const char* gc } std::vector> arch_default_env(const char* gcn_arch, bool defaults026) { +#if defined(_WIN32) + return arch_default_env(gcn_arch, defaults026, true); +#else + return arch_default_env(gcn_arch, defaults026, false); +#endif +} + +std::vector> arch_default_env(const char* gcn_arch, bool defaults026, bool windows) { std::vector> t; if (strata::kernels::gfx_arch_is_gfx12(gcn_arch)) { // gfx1200 / gfx1201 (RDNA4): the PROMPT half of the gfx1151 table (reported exact on an R9700 in #1478, re-checked @@ -71,6 +79,15 @@ std::vector> arch_default_env(const char* gc {"STRATA_PLE_BATCH", "1"}, // the verify window's PLE key / value projections at once (S25) {"STRATA_SH_STREAM", "1"}, // the shared expert on its own stream: decode +1.8% / +6.7% (UD-Q4_K_XL) (140-m) }; + // 0.2.7: Windows gfx1151 leaves the shared-expert fork off (the HIP default). Interleaved A/B on a Strix Halo Windows PC (Qwen + // 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 + // (+6.9% median), prompts unchanged, the token ids identical either way (docs/STRIX_HALO_WINDOWS.md). Linux gfx1151 keeps the + // fork on until it is measured there. STRATA_SH_STREAM=1 turns it back on; STRATA_DEFAULTS=026 keeps v0.2.6's table. + if (windows && !defaults026) { + for (auto it = t.begin(); it != t.end(); ++it) { + if (it->first == "STRATA_SH_STREAM") { t.erase(it); break; } + } + } return t; } diff --git a/src/core/arch_defaults_test.cpp b/src/core/arch_defaults_test.cpp index db193a7f..51f70493 100644 --- a/src/core/arch_defaults_test.cpp +++ b/src/core/arch_defaults_test.cpp @@ -48,6 +48,66 @@ int main() { CHECK(kv.first != bits); } } + // 0.2.7: STRATA_SH_STREAM. Windows gfx1151 leaves the shared-expert fork off (it measured slower there, same ids); Linux gfx1151, + // the 026 master switch and every other architecture are unchanged. Pure rule: the platform is an argument. + { + auto find = [](const std::vector>& t, const char* k) -> const std::string* { + for (const auto& kv : t) if (kv.first == k) return &kv.second; + return static_cast(nullptr); + }; + for (const char* a : {"gfx1151", "gfx1151:sramecc-:xnack-"}) { + const auto lin = arch_default_env(a, false, false); + const auto win = arch_default_env(a, false, true); + const auto lin26 = arch_default_env(a, true, false); + const auto win26 = arch_default_env(a, true, true); + const std::string* l = find(lin, "STRATA_SH_STREAM"); + CHECK(l != nullptr && *l == "1"); // Linux gfx1151: unchanged, the fork is on + CHECK(find(win, "STRATA_SH_STREAM") == nullptr); // Windows gfx1151: not in the table, so the HIP default (off) applies + CHECK(find(win26, "STRATA_SH_STREAM") != nullptr); // STRATA_DEFAULTS=026: v0.2.6's table on Windows too + CHECK(find(lin26, "STRATA_SH_STREAM") != nullptr); + CHECK(win26 == lin26 && win26 == lin); // under 026 and on Linux the whole table is the same + CHECK(win.size() + 1 == lin.size()); // Windows loses that one entry and nothing else + for (const auto& kv : win) CHECK(find(lin, kv.first.c_str()) != nullptr && *find(lin, kv.first.c_str()) == kv.second); + } + // other architectures: the platform changes nothing + for (const char* a : {"gfx1100", "gfx1030", "gfx1103", "gfx1150", "gfx1152", "gfx1201", "gfx1200", ""}) { + CHECK(arch_default_env(a, false, true) == arch_default_env(a, false, false)); + CHECK(arch_default_env(a, true, true) == arch_default_env(a, true, false)); + } + CHECK(arch_default_env(nullptr, false, true).empty()); + // the build's own platform answers like the explicit form (the one-argument form reads STRATA_DEFAULTS, unset here) + unset("STRATA_DEFAULTS"); +#if defined(_WIN32) + CHECK(arch_default_env("gfx1151") == arch_default_env("gfx1151", false, true)); + CHECK(find(arch_default_env("gfx1151"), "STRATA_SH_STREAM") == nullptr); +#else + CHECK(arch_default_env("gfx1151") == arch_default_env("gfx1151", false, false)); + CHECK(find(arch_default_env("gfx1151"), "STRATA_SH_STREAM") != nullptr); +#endif + // applying the table: an explicit STRATA_SH_STREAM=1 stays 1, an explicit 0 stays 0, and the Windows table does not set it + unset("STRATA_QFUSE"); + put("STRATA_SH_STREAM", "1"); + apply_arch_defaults("gfx1151"); + CHECK(std::getenv("STRATA_SH_STREAM") != nullptr && std::string(std::getenv("STRATA_SH_STREAM")) == "1"); + put("STRATA_SH_STREAM", "0"); + apply_arch_defaults("gfx1151"); + CHECK(std::string(std::getenv("STRATA_SH_STREAM")) == "0"); + unset("STRATA_SH_STREAM"); + unset("STRATA_QFUSE"); + const auto applied = apply_arch_defaults("gfx1151"); + bool sh_set = false; + for (const auto& n : applied) sh_set = sh_set || n == "STRATA_SH_STREAM"; +#if defined(_WIN32) + CHECK(!sh_set); + CHECK(std::getenv("STRATA_SH_STREAM") == nullptr || std::string(std::getenv("STRATA_SH_STREAM")).empty()); +#else + CHECK(sh_set); + CHECK(std::getenv("STRATA_SH_STREAM") != nullptr && std::string(std::getenv("STRATA_SH_STREAM")) == "1"); +#endif + unset("STRATA_SH_STREAM"); + unset("STRATA_QFUSE"); + unset("STRATA_TSUM"); + } // gfx12: the five prompt switches and four bit-identical decode switches, no bit-changing one unset("STRATA_GFX12_DEFAULTS"); for (const char* a : {"gfx1200", "gfx1201", "gfx1201:sramecc-:xnack-"}) { diff --git a/src/core/verify.cpp b/src/core/verify.cpp index ac3f874a..cdb20bef 100644 --- a/src/core/verify.cpp +++ b/src/core/verify.cpp @@ -286,7 +286,9 @@ bool batch_self_commits(const int* rows, int S) { return g_batch_self_commit && // profiler turns the fork off to time the stages, so a profiled run never showed that. #816 reports the same fall on a // gfx1030 (RX 6800, Windows, 42.5 -> 56.4 t/s). STRATA_SH_STREAM overrides either default: `=1` forks, `=0` does not. // Strix Halo (gfx1151, unified memory) is the exception: the fork pays there (+1.8% UD-IQ4_XS, +6.7% UD-Q4_K_XL decode -// at 8K, ids identical), so the gfx1151 arch table sets STRATA_SH_STREAM=1. Read on first use, after that table ran. +// at 8K, ids identical), so the gfx1151 arch table sets STRATA_SH_STREAM=1 on Linux. On Windows gfx1151 the fork is slower (0.2.7, +// Qwen IQ3_S: decode -6.4% with it, ids identical), so there the table leaves it out and this default (off on HIP) applies. +// Read on first use, after that table ran. bool sh_stream_on() { static const bool on = [] { if (const char* v = std::getenv("STRATA_SH_STREAM")) return v[0] != '0';