Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
Windows HIP: a bare --prefill auto stops at 6144; commit-limit check at serve start (#1630, #1607)
Niko12215728828a8498
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 02dd84fe7..b4078db8e 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -260,6 +260,11 @@ if(STRATA_BUILD_TESTS)add_executable(share_rules_test tests/prefill/share_rules_test.cpp)target_include_directories(share_rules_test PRIVATE include)add_test(NAME share_rules_test COMMAND share_rules_test)++ # the Windows HIP auto prefill chunk cap (#1630) and the commit-limit verdict (#1607): header-only, no GPU+ add_executable(host_limits_test tests/platform/host_limits_test.cpp)+ target_include_directories(host_limits_test PRIVATE include)+ add_test(NAME host_limits_test COMMAND host_limits_test)endif()# ---- strata_plan ----------------------------------------------------------diff --git a/include/strata/platform/host_limits.hpp b/include/strata/platform/host_limits.hppnew file mode 100644index 000000000..f4543efbd--- /dev/null+++ b/include/strata/platform/host_limits.hpp@@ -0,0 +1,58 @@+// include/strata/platform/host_limits.hpp - host-side limits that need no GPU to check (#1630, #1607).+//+// Windows HIP, RX 7900 XTX (#1630): the first long prompt at --prefill 8192 / auto made the system commit charge jump+// ~70 GB inside a second and the engine died (0xC0000409); 7500 and below stayed flat (reporter's table, 26,902- and+// 66,235-token prompts), so a bare `auto` stops at 6144 on that platform (645-708 tok/s there, 7500 gave 748-782).+// A chunk the user asks for is theirs: it stays, with a warning.+//+// Windows commit limit (#1607): RAM + page file; the engine died silently when the charge reached it with GBs of+// physical RAM free. The startup check compares what the engine plans to allocate on the host with the commit that+// is left.+#pragma once++#include <cstdint>+#include <cstdio>+#include <string>++namespace strata::platform::host_limits {++constexpr int64_t kWinHipAutoChunkCap = 6144;+constexpr int64_t kWinHipCrashChunk = 8192; // the smallest chunk reported to crash++/// The ceiling a bare `--prefill auto` takes on this build; 0 = none (keep the usual 8192).+/// win_hip: a Windows HIP build; bare_auto: "auto" without ":N" and no STRATA_PREFILL_AUTO_MAX.+constexpr int64_t auto_chunk_cap(bool win_hip, bool bare_auto) {+ return win_hip && bare_auto ? kWinHipAutoChunkCap : 0;+}++/// Whether to warn about a chunk the user chose: a fixed N, or auto:N, of 8192 or more on a Windows HIP build.+constexpr bool warn_user_chunk(bool win_hip, bool bare_auto, int64_t chunk) {+ return win_hip && !bare_auto && chunk >= kWinHipCrashChunk;+}++struct CommitVerdict {+ bool warn = false;+ std::string text;+};++/// avail: commit left (ullAvailPageFile); limit: the commit limit (ullTotalPageFile); planned: host bytes the engine+/// plans to allocate from here on (conversation cache budget, checkpoints, staging); floor: kept free for Windows and+/// other programs. Warns when planned + floor exceeds what is left.+inline CommitVerdict commit_verdict(uint64_t avail, uint64_t limit, uint64_t planned, uint64_t floor_bytes) {+ CommitVerdict v;+ if (limit == 0) return v; // unknown (not Windows)+ if (planned + floor_bytes <= avail) return v;+ v.warn = true;+ const double gib = 1073741824.0;+ char buf[400];+ std::snprintf(buf, sizeof buf,+ "WARNING the Windows commit limit is %.1f GiB (RAM + page file) and %.1f GiB of it is left, but this run "+ "plans %.1f GiB of host allocations and keeps %.1f GiB free: it can end at the limit with no message "+ "(exit code 0xC0000409, #1607) while RAM is still free. Raise the page file (System managed, or "+ "RAM-sized) or lower --conversation-cache-mib / --max-context / --prefill",+ (double) limit / gib, (double) avail / gib, (double) planned / gib, (double) floor_bytes / gib);+ v.text = buf;+ return v;+}++} // namespace strata::platform::host_limitsdiff --git a/src/core/conversation_memory.cpp b/src/core/conversation_memory.cppindex bd5740f2f..ac93cfa20 100644--- a/src/core/conversation_memory.cpp+++ b/src/core/conversation_memory.cpp@@ -1,5 +1,6 @@#include "strata/core/conversation_memory.hpp"+#include <algorithm>#include <charconv>#include <fstream>#include <limits>@@ -37,7 +38,8 @@ std::optional<uint64_t> conversation_available_memory() {#if defined(_WIN32)MEMORYSTATUSEX status{};status.dwLength = sizeof status;- if (GlobalMemoryStatusEx(&status)) return status.ullAvailPhys;+ // #1607: the commit limit (RAM + page file) refuses an allocation while physical RAM is still free+ if (GlobalMemoryStatusEx(&status)) return std::min<uint64_t>(status.ullAvailPhys, status.ullAvailPageFile);return {};#elif defined(__linux__)std::ifstream meminfo("/proc/meminfo");diff --git a/src/program/generate.cpp b/src/program/generate.cppindex 8b6be7a4d..d70249705 100644--- a/src/program/generate.cpp+++ b/src/program/generate.cpp@@ -62,6 +62,7 @@#include "strata/program/conv_cache.hpp"#include "strata/program/split_rules.hpp"#include "strata/prefill/share_rules.hpp"+#include "strata/platform/host_limits.hpp"#include "strata/program/message_boundary.hpp"#include "strata/spec/draft_policy.hpp"#include "strata/spec/draft_source.hpp"@@ -513,6 +514,8 @@ struct Options {/// #282, opt-in: the largest chunk `--prefill auto` may take - 8192 by default; `--prefill auto:16384` or/// `auto:32768` (or STRATA_PREFILL_AUTO_MAX) lets it go further, never past the contextint64_t prefill_auto_max = 8192;+ /// #1630: a bare `--prefill auto` stops here on a Windows HIP build (0: no cap). A chunk the user names is not capped.+ int64_t prefill_auto_cap = 0;bool no_split_rows = false; ///< plan v0.3 P4 A/B: one whole expert per pool thread/// Plan v0.3 P5: the prompt path borrows the top expert-cache slots for its buffers and refills them after/// the prompt (default); `--no-prefill-borrow` reserves the buffers' VRAM for the whole session instead.@@ -1777,6 +1780,22 @@ int main(int argc, char** argv) {: (o.prefill_auto && env_max != nullptr ? std::atoll(env_max) : 8192);o.prefill_auto_max = want_max >= 32768 ? 32768 : want_max >= 16384 ? 16384 : 8192;o.prefill_chunk = o.prefill_auto ? o.prefill_auto_max : std::atoll(v.c_str());+ { // #1630: Windows HIP, RX 7900 XTX: a first long prompt at 8192-token chunks charged ~70 GB of commit and+ // killed the engine; 7500 and below were flat. A bare auto stops at 6144; a chunk the user names stays.+#if defined(STRATA_USE_HIP) && defined(_WIN32)+ constexpr bool win_hip = true;+#else+ constexpr bool win_hip = false;+#endif+ const bool bare_auto = v == "auto" && !(o.prefill_auto && env_max != nullptr);+ o.prefill_auto_cap = strata::platform::host_limits::auto_chunk_cap(win_hip, bare_auto && o.prefill_auto);+ if (o.prefill_auto_cap > 0) o.prefill_chunk = std::min(o.prefill_chunk, o.prefill_auto_cap);+ if (strata::platform::host_limits::warn_user_chunk(win_hip, bare_auto, o.prefill_chunk))+ std::fprintf(stderr, "strata: WARNING --prefill %s: prompt chunks of 8192 tokens or more crashed the engine "+ "on Windows HIP (RX 7900 XTX: the commit charge jumped ~70 GB, exit code 0xC0000409, "+ "#1630); 7500 and below were stable. Kept as asked; a bare --prefill auto stops at %lld\n",+ v.c_str(), (long long) strata::platform::host_limits::kWinHipAutoChunkCap);+ }}else if (a == "--no-split-rows") o.no_split_rows = true;else if (a == "--no-prefill-borrow") o.no_prefill_borrow = true;@@ -5796,7 +5815,8 @@ int main(int argc, char** argv) {// context, but a bare `auto` always reaches 8192. 32768 and 16384 stay opt-in (#282): a 32K prompt with// IQ2_XS (RTX 5090, 64K context) read at 5,624 tok/s in 8192-token chunks and 6,465 in one 32768 chunk (40K// -> 18K experts streamed; an NVFP4 pack at 262K: 3,535 -> 5,201).- const int64_t auto_ceiling = std::max<int64_t>(8192, std::min<int64_t>(o.prefill_auto_max, o.max_context));+ int64_t auto_ceiling = std::max<int64_t>(8192, std::min<int64_t>(o.prefill_auto_max, o.max_context));+ if (o.prefill_auto_cap > 0) auto_ceiling = std::min<int64_t>(auto_ceiling, o.prefill_auto_cap); // #1630// The auto scan used to walk a fixed list of sizes - 32768, 16384, 8192, 6144, ... - and take the first that// fit. That list is coarse exactly where a rig needs it: this one affords ~8,700 tokens and was handed 8192,// and 8704 is not on it. `bytes_needed` is a sum of (T x positive constant) terms plus a max of such sums,@@ -5821,6 +5841,7 @@ int main(int argc, char** argv) {for (const int64_t c : kAutoChunks) {// above 8192: only when asked for, and only when a prompt of the context can use itif (c > 8192 && (c > o.prefill_auto_max || c > o.max_context)) continue;+ if (o.prefill_auto_cap > 0 && c > o.prefill_auto_cap) continue; // #1630const int64_t k = slots_for(c);if (k + 128 <= xcache.slots() && k * 100 <= kAutoLendPct * xcache.slots()) return c;}@@ -6247,6 +6268,23 @@ int main(int argc, char** argv) {strata::prefill::Prefill sp;// the pool is idle while a prompt is read unless batch slots decode between its parts; with// STRATA_PREFILL_CPU_SHARE the staged-chunk limit before the chunk below sizes the loans (bytes_needed reads it)+ // #1607: Windows, the commit limit (RAM + page file) is what ends the engine silently; compare what this run plans+ // to allocate on the host from here (the conversation cache, checkpoints) with the commit that is left+#if defined(_WIN32)+ {+ MEMORYSTATUSEX cs{};+ cs.dwLength = sizeof cs;+ if (GlobalMemoryStatusEx(&cs)) {+ const uint64_t planned = (o.prompt_cache > 0 ? (uint64_t) std::max<int64_t>(o.conversation_cache_mib, 0) << 20 : 0) ++ (2ull << 30); // checkpoints and prompt staging+ const auto cv = strata::platform::host_limits::commit_verdict((uint64_t) cs.ullAvailPageFile,+ (uint64_t) cs.ullTotalPageFile, planned, 4ull << 30);+ std::fprintf(stderr, "strata serve: Windows commit: %.1f GiB left of a %.1f GiB limit (RAM + page file)\n",+ (double) cs.ullAvailPageFile / 1073741824.0, (double) cs.ullTotalPageFile / 1073741824.0);+ if (cv.warn) std::fprintf(stderr, "strata serve: %s\n", cv.text.c_str());+ }+ }+#endifconst bool share_pool = o.batch <= 0 && !o.no_pool;const bool share_has_work = strata::prefill::share_rules::default_share_has_work((int64_t) xcache.slots(), (int64_t) (g.n_layers * g.n_expert)); // #1595@@ -6380,6 +6418,7 @@ int main(int argc, char** argv) {static constexpr int64_t kAutoChunks[] = {32768, 16384, 8192, 6144, 4096, 3072, 2048, 1024, 512, 256};for (const int64_t c : kAutoChunks) {if (c > 8192 && (c > o.prefill_auto_max || c > o.max_context)) continue; // #282, as plan_lend+ if (o.prefill_auto_cap > 0 && c > o.prefill_auto_cap) continue; // #1630if (fits(c, true, only)) return c;}return 0;diff --git a/tests/platform/host_limits_test.cpp b/tests/platform/host_limits_test.cppnew file mode 100644index 000000000..1576e11ae--- /dev/null+++ b/tests/platform/host_limits_test.cpp@@ -0,0 +1,34 @@+// Windows HIP auto-chunk cap (#1630) and the commit-limit verdict (#1607): no GPU, no Windows needed.+#include <cstdio>++#include "strata/platform/host_limits.hpp"++using namespace strata::platform::host_limits;++static int failed = 0;+#define CHECK(x) do { if (!(x)) { std::fprintf(stderr, "FAIL %s:%d: %s\n", __FILE__, __LINE__, #x); ++failed; } } while (0)++int main() {+ // a bare auto on Windows HIP is capped below the 8192 that crashed; every other build keeps it+ CHECK(auto_chunk_cap(true, true) == 6144);+ CHECK(auto_chunk_cap(true, true) < 8192);+ CHECK(auto_chunk_cap(false, true) == 0);+ CHECK(auto_chunk_cap(true, false) == 0); // auto:N / STRATA_PREFILL_AUTO_MAX: the operator's pick+ CHECK(auto_chunk_cap(false, false) == 0);+ // a chunk the user names stays, with a warning from 8192 up (7500 was stable)+ CHECK(warn_user_chunk(true, false, 8192));+ CHECK(warn_user_chunk(true, false, 16384));+ CHECK(!warn_user_chunk(true, false, 7500));+ CHECK(!warn_user_chunk(true, true, 8192)); // the bare auto is capped instead+ CHECK(!warn_user_chunk(false, false, 8192));+ // commit: 188 GiB limit with 90 GiB left and a 10 GiB plan: quiet; 95 GiB limit with 6 GiB left: warns+ const uint64_t G = 1ull << 30;+ CHECK(!commit_verdict(90 * G, 188 * G, 10 * G, 4 * G).warn);+ CHECK(!commit_verdict(14 * G, 96 * G, 10 * G, 4 * G).warn); // exactly enough+ const CommitVerdict v = commit_verdict(6 * G, 96 * G, 10 * G, 4 * G);+ CHECK(v.warn);+ CHECK(v.text.find("1607") != std::string::npos);+ CHECK(!commit_verdict(0, 0, 10 * G, 4 * G).warn); // unknown limit (not Windows)+ if (failed == 0) std::printf("host_limits_test: ok\n");+ return failed ? 1 : 0;+}