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++
Merge branch 'f-131-amd' into r131-amd
Niko12219305322ff5f5
diff --cc src/core/pinned.cuindex cae46b306,663c508ec..64ffe0137--- a/src/core/pinned.cu+++ b/src/core/pinned.cu@@@ -306,15 -265,7 +306,15 @@@ PinnedArena::PinnedArena(uint64_t bytes// Register with CUDA BEFORE any page is touched: cudaHostRegister pins what is resident now, and a region// that has already been faulted in page by page is far more expensive to register and may fail outright.if (base) {- const bool capped = max_pinned_bytes > 0 && max_pinned_bytes < bytes && bounds.size() >= 2;+ // #243: STRATA_ARENA_PIN_GIB=N caps the registration from the start where the caller set no cap+ const int env_gib = arena_pin_cap_gib();+ uint64_t cap = max_pinned_bytes;- std::string cap_why = "for CUDA1";++ std::string cap_why = "by the engine (multi-GPU under WDDM, or remote experts)";+ if (cap == 0 && env_gib > 0) {+ cap = (uint64_t) env_gib << 30;+ cap_why = "by STRATA_ARENA_PIN_GIB";+ }+ const bool capped = cap > 0 && cap < bytes && bounds.size() >= 2;const cudaError_t e = capped ? cudaSuccess :cudaHostRegister(base, (size_t) bytes, cudaHostRegisterPortable | cudaHostRegisterMapped);if (!capped && e == cudaSuccess) {diff --cc src/program/generate.cppindex 1a7ee0493,45f98871d..2a5eadef8--- a/src/program/generate.cpp+++ b/src/program/generate.cpp@@@ -19,6 -19,6 +19,7 @@@#include "strata/core/conversation_snapshot.hpp"#include "strata/core/conversation_memory.hpp"#include "strata/core/expert_source.hpp"++#include "strata/core/pinned.hpp"#include "strata/core/remote_experts.hpp"#include "strata/core/on_device.hpp"#include "strata/core/layer.hpp"@@@ -95,6 -94,29 +96,18 @@@#include <vector>namespace {-// STRATA_ARENA_PIN_GIB: how much of the expert arena is registered (pinned) for the GPUs. Unset: -1 (the default-// rule below); "0": the whole arena; N > 0: at most N GiB. (The same helper as src/core/pinned.cu's on the S2-// branch: identical name and meaning, file-local here.)-static int arena_pin_cap_gib() {- const char* v = std::getenv("STRATA_ARENA_PIN_GIB");- if (v == nullptr || *v == '\0') return -1;- char* end = nullptr;- const long n = std::strtol(v, &end, 10);- return (end == v || n < 0) ? -1 : (int) std::min<long>(n, 1 << 20);-}-+ // Windows' WDDM driver model: native Windows, or WSL2 (its GPU goes through /dev/dxg to the Windows driver). There,+ // pinning a large arena into two CUDA contexts leaves WDDM refusing every later allocation (the 5080 + 3090 rig);+ // a Linux driver has no such limit (#253: the 8 GiB cap cost a 4090 + 3060 split 3x of its prompt speed).+ bool under_wddm() {+ #ifdef _WIN32+ return true;+ #else+ static const bool dxg = std::filesystem::exists("/dev/dxg");+ return dxg;+ #endif+ }+// perf-review D-4: the lent slots are refilled with queued copies and one wait; STRATA_REFILL_BLOCKING=1 waits on eachbool refill_blocking() {static const bool v = std::getenv("STRATA_REFILL_BLOCKING") != nullptr;@@@ -2348,11 -2348,20 +2412,20 @@@ int main(int argc, char** argv)srcp = &src;} else {arena_src.set_gguf(o.native_preset); // plan v0.3 P6: a native pack may take its experts from shard 1- // On the multi-GPU Windows experiment, start with at most 8 GiB of mapped host pages.- // Unregistered layers remain in the resident arena and use the CPU expert path.- // (a layer split across GPUs too: pinning all of it into two contexts leaves WDDM refusing every later- // allocation - measured on the 5080 + 3090 rig: cudaMemGetInfo and the next cudaMalloc fail)- const uint64_t pin_limit = (o.expert_cache_remote[0] > 0 || multi_gpu) ? (8ull << 30) : 0;+ // Under WDDM (Windows, WSL2), a multi-GPU run (a layer split, or remote experts) starts with at most 8 GiB of+ // mapped host pages: pinning all of it into two contexts leaves WDDM refusing every later allocation -+ // measured on the 5080 + 3090 rig: cudaMemGetInfo and the next cudaMalloc fail. Unregistered layers remain+ // in the resident arena; their streamed experts go through the pinned staging ring. A Linux driver has no+ // such limit, so there the whole arena is pinned (#253). STRATA_ARENA_PIN_GIB overrides both ways.- const int pin_env = arena_pin_cap_gib();++ const int pin_env = strata::core::arena_pin_cap_gib(); // -1 unset, -2 "auto" (#243, Windows sliced pin)+ const bool pin_wddm_cap = pin_env < 0 && (o.expert_cache_remote[0] > 0 || multi_gpu) && under_wddm();+ const uint64_t pin_limit = pin_env >= 0 ? (uint64_t) pin_env << 30 : pin_wddm_cap ? (8ull << 30) : 0;+ if (pin_env >= 0)+ std::fprintf(stderr, "strata generate: STRATA_ARENA_PIN_GIB=%d: %s\n", pin_env,+ pin_env == 0 ? "the whole expert arena is pinned" : "the expert arena's pinning is capped");+ else if (pin_wddm_cap)+ std::fprintf(stderr, "strata generate: multi-GPU under WDDM: at most 8 GiB of the expert arena is pinned "+ "(STRATA_ARENA_PIN_GIB changes it)\n");if (!arena_src.open(o.pack, g.n_layers, g.n_expert, /*threads=*/6, err, pin_limit,o.shared_expert_arena)) {std::fprintf(stderr, "strata generate: %s\n", err.c_str());