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++
gfx906 build on 0.1.39: the segmented expert cache (#533) is CUDA-only there too; pinned.cu's std::max beside windows.h
Niko1221005f7c718592
diff --git a/src/core/expert_cache.cpp b/src/core/expert_cache.cppindex e25f60e9f..b8df2faf4 100644--- a/src/core/expert_cache.cpp+++ b/src/core/expert_cache.cpp@@ -1,8 +1,14 @@// src/core/expert_cache.cpp - R4's slot storage and residency table. Read the header first.#include "strata/core/expert_cache.hpp"+// #533's segmented cache uses CUDA's virtual memory management (cuMem*): not on HIP, neither the RDNA backend nor+// the gfx906 compat build (PR #638), which compiles this file as HIP without STRATA_USE_HIP+#if defined(STRATA_USE_HIP) || defined(STRATA_HIP_GFX906)+#define STRATA_EC_NO_VMM 1+#endif+#include <cuda_runtime.h>-#if !defined(STRATA_USE_HIP)+#if !defined(STRATA_EC_NO_VMM)#include <cuda.h> // #533: the virtual memory management types (the functions come through the runtime's entry points)#endif@@ -148,7 +154,7 @@ ExpertCache::~ExpertCache() { close(); }// ---- #533: the segmented arena (--vram-elastic). The driver API's virtual memory functions, looked up through the// runtime (no link against the driver library): one address range for the whole arena, backed by physical segments,// and the tail's segments unmapped / mapped again later. Nothing here runs unless a segment size was set.-#if !defined(STRATA_USE_HIP)+#if !defined(STRATA_EC_NO_VMM)namespace {struct Vmm {CUresult (CUDAAPI* device_get)(CUdevice*, int) = nullptr;@@ -227,7 +233,7 @@ bool map_segment(const Vmm& v, int dev, CUdeviceptr va, size_t bytes, unsigned l#endifbool ExpertCache::open_segmented(uint64_t want, std::string& err) {-#if defined(STRATA_USE_HIP)+#if defined(STRATA_EC_NO_VMM)(void) want;err = "ExpertCache: --vram-elastic (a segmented expert cache) is CUDA-only for now";return false;@@ -280,7 +286,7 @@ bool ExpertCache::open_segmented(uint64_t want, std::string& err) {}void ExpertCache::release_segmented() {-#if !defined(STRATA_USE_HIP)+#if !defined(STRATA_EC_NO_VMM)const Vmm& v = vmm();if (base_ != nullptr) cudaDeviceSynchronize();const CUdeviceptr va = reinterpret_cast<CUdeviceptr>(base_);@@ -318,7 +324,7 @@ bool ExpertCache::shrink(int64_t keep_bytes, std::string& err) {err = "the expert cache is not segmented (the engine needs --vram-elastic)";return false;}-#if defined(STRATA_USE_HIP)+#if defined(STRATA_EC_NO_VMM)(void) keep_bytes;return false;#else@@ -352,7 +358,7 @@ bool ExpertCache::grow(int64_t want_bytes, std::string& err) {err = "the expert cache is not segmented (the engine needs --vram-elastic)";return false;}-#if defined(STRATA_USE_HIP)+#if defined(STRATA_EC_NO_VMM)(void) want_bytes;return false;#elsediff --git a/src/core/pinned.cu b/src/core/pinned.cuindex 780d93fb7..73b441f39 100644--- a/src/core/pinned.cu+++ b/src/core/pinned.cu@@ -452,7 +452,7 @@ LoadStats load_experts_direct(const std::string& path, uint8_t* dst, const std::std::mutex err_mu;std::string err;const int wide = MultiByteToWideChar(CP_UTF8, 0, path.c_str(), -1, nullptr, 0);- std::vector<wchar_t> wpath((size_t) std::max(wide, 1), L'\0');+ std::vector<wchar_t> wpath((size_t) (std::max)(wide, 1), L'\0');if (wide > 0) MultiByteToWideChar(CP_UTF8, 0, path.c_str(), -1, wpath.data(), wide);auto worker = [&]() {HANDLE h = CreateFileW(wpath.data(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING,@@ -520,7 +520,7 @@ bool experts_unbuffered(const std::vector<std::string>& files, uint64_t arena_byuint64_t seed = (uint64_t) GetTickCount64() * 6364136223846793005ull + 1442695040888963407ull;for (const std::string& f : files) {const int wide = MultiByteToWideChar(CP_UTF8, 0, f.c_str(), -1, nullptr, 0);- std::vector<wchar_t> w((size_t) std::max(wide, 1), L'\0');+ std::vector<wchar_t> w((size_t) (std::max)(wide, 1), L'\0');if (wide > 0) MultiByteToWideChar(CP_UTF8, 0, f.c_str(), -1, w.data(), wide);HANDLE h = CreateFileW(w.data(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS,nullptr);