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 f-resram into rel-0.1.30
Niko1221840f01734ec9
diff --cc setup.pyindex 13813a32f,b1d8571e1..f7380f45f--- a/setup.py+++ b/setup.py@@@ -2109,12 -2063,15 +2146,17 @@@ def main() -> int"--expert-profile", str(ROOT / "data" / fam.get("profile", "expert-profile.bin")), "--expert-cache", "auto","--prefill", "auto", "--spec", "4", "--spec-min-p", "0.5", "--mtp", str(rt),"--max-context", str(ctx)]+ if scaling is not None: # the resolved config: explicit flags as given, or the automatic yarn+factor+ args += ["--rope-scaling", scaling, "--rope-scale", f"{rope_scale:g}"]if ctx > 8192:args += ["--kv", kv]- if low_ram:- args += ["--mmap-experts"] # the experts from the pack's experts.bin, not copied into RAM+ engine_ver = tuple(int(x) for x in str(meta.get("version", "0")).split(".")[:3] if x.isdigit())+ if resident and a.low_ram != "resident" and engine_ver < RESIDENT_ENGINE:+ resident = False # an engine from before --resident-experts would refuse it+ ok(f"low-RAM mode: engine {meta.get('version')} has no resident variant yet; the experts are read through "+ "the OS file cache (run setup again after the next engine update)")+ if low_ram: # the experts from the pack's experts.bin: the ones the GPU does not hold copied into RAM, or mapped+ args += ["--resident-experts" if resident else "--mmap-experts"]# KV streaming: from 64K up the whole KV cache lives in RAM and only the part the attention reads (32K positions# per layer) stays in VRAM; the VRAM it frees holds more experts (+6% at 128K, +23% at 262K with Q2_0). It# costs ~13.7 KB of RAM per context token with 8-bit KV (1.7 GB at 128K), 7.5 KB with 4-bit, so only when it fits.diff --cc src/program/generate.cppindex 4caf7ec15,43e4f0d5d..bfc19202f--- a/src/program/generate.cpp+++ b/src/program/generate.cpp@@@ -196,8 -220,13 +234,14 @@@ struct Options/// is reserved for a host thread that has nothing to do while the drain runs.bool no_host_worker = false;bool mmap_experts = false; ///< R2.1: opt OUT of the resident arena, back to MapViewOfFile+ std::string shared_expert_arena; ///< Linux: optional file backing for the resident arena shared by processesbool resident_cpu_experts = false; ///< mmap-backed static-cache misses copied into ordinary RAM+ /// `--resident-experts` (the low-RAM PC's resident mode, chosen by setup): `--resident-cpu-experts` with the copy+ /// page-locked when the driver allows (else locked in the working set), 4 GiB of RAM headroom, and plain mmap+ /// (with a warning) when even the experts no slot holds do not fit.+ bool resident_pin = false;+ uint64_t resident_headroom = 8ull << 30;+ bool resident_soft = false;/// R4: slots of VRAM-resident experts. **0 = off, and off is the default.**/// **THE COMMENT THAT USED TO BE HERE WAS FALSE AND ROUND 328 MEASURED IT.** It said "the cache has no/// consumer yet - `moe_hit_grouped_s2` does not exist - so switching it on costs the fill traffic and@@@ -462,11 -480,12 +506,15 @@@ void usage()" --mmap-experts R2.1: opt OUT of the resident expert arena, back to MapViewOfFile.\n"" The A/B arm: the mmap's rate depends on the OS page cache holding\n"" 34 GB, and measured 71.97 vs 34.78 ms/token cold vs warm.\n"+ " --shared-expert-arena FILE Linux: back the resident arena with one MAP_SHARED file.\n"+ " Put this file on /dev/shm, not ordinary SSD storage.\n"+ " A small header binds an existing backing file to the same pack.\n"- " --resident-cpu-experts with mmap and a static profile, keep CPU misses resident in ordinary RAM.\n"- " Borrowed GPU-cache entries may read from mmap during prompt prefill.\n");+ " --resident-cpu-experts with mmap and a static profile, keep the experts the GPU cache does not\n"+ " hold resident in ordinary RAM (and the prompt path's lend region as far as\n"+ " RAM allows); adaptive swaps exchange them, so none is read from the file again.\n"+ " --resident-experts the low-RAM PC's resident mode (setup): --mmap-experts --resident-cpu-experts\n"+ " with the copy page-locked when possible, 4 GiB headroom, plain mmap if it\n"+ " does not fit. Same answers as --mmap-experts for the same placement.\n");}/// All shards of a split GGUF, from shard 1's path ("...-00001-of-00002.gguf"); just the path when it is not split.@@@ -1115,8 -1119,17 +1163,18 @@@ int main(int argc, char** argv)else if (a == "--expert-profile") o.expert_profile = next("--expert-profile");else if (a == "--gpu-stages") o.gpu_stages = true;else if (a == "--mmap-experts") o.mmap_experts = true;+ else if (a == "--shared-expert-arena") o.shared_expert_arena = next("--shared-expert-arena");else if (a == "--resident-cpu-experts") o.resident_cpu_experts = true;+ else if (a == "--resident-experts") {+ o.mmap_experts = o.resident_cpu_experts = o.resident_pin = o.resident_soft = true;+ o.resident_headroom = 4ull << 30;+ // A/B arms: STRATA_RESIDENT_PIN=0 keeps the copy pageable (the --resident-cpu-experts form);+ // STRATA_RESIDENT_HEADROOM_GIB=N leaves N GiB of the available RAM free instead of 4+ if (const char* v = std::getenv("STRATA_RESIDENT_PIN"); v != nullptr && std::string(v) == "0")+ o.resident_pin = false;+ if (const char* v = std::getenv("STRATA_RESIDENT_HEADROOM_GIB"); v != nullptr && std::atof(v) >= 0.0)+ o.resident_headroom = (uint64_t) (std::atof(v) * 1073741824.0);+ }else if (a == "--stats") o.stats = true;else if (a == "--shared-late") o.shared_late = true;else if (a == "--keep-canonical") o.keep_canonical = true;@@@ -1186,12 -1198,8 +1244,12 @@@}}const bool multi_gpu = !split_devs.empty() && !split_same;+ if (o.mmap_experts && !o.shared_expert_arena.empty()) {+ std::fprintf(stderr, "strata generate: --shared-expert-arena backs the resident arena and cannot be used with --mmap-experts\n");+ return 2;+ }- if (o.resident_cpu_experts && (!o.mmap_experts || o.expert_profile.empty() || o.adapt_every != 0)) {- std::fprintf(stderr, "strata generate: --resident-cpu-experts requires --mmap-experts, a static --expert-profile and --adapt-every 0\n");+ if (o.resident_cpu_experts && (!o.mmap_experts || o.expert_profile.empty())) {+ std::fprintf(stderr, "strata generate: --resident-cpu-experts requires --mmap-experts and a static --expert-profile\n");return 2;}if (o.resident_cpu_experts &&@@@ -3899,13 -3632,12 +3987,14 @@@"mtp_max=%d lookup=%d vram_free_mib=%lld cvec=%s arena_mib=%lld pool_workers=%d pcie_frac=%.2f ""spec_min_p=%.2f engine=" STRATA_VERSION "\n",(long long) o.max_context, o.kv.c_str(),- (long long) (g.n_qsa_layers() > 0 && ss.qsa_states[0].kv_mode == 1- ? ss.qsa_states[0].n_slots * 4 : 0),- (long long) xcache.slots(), (long long) (xcache.bytes() >> 20), o.spec, o.mtp_max_t,+ (long long) (g.n_qsa_layers() > 0 && ss.qsa_states[ss.qsa_primary()].kv_mode == 1+ ? ss.qsa_states[ss.qsa_primary()].n_slots * 4 : 0),+ (long long) slots_all, (long long) mib_all,+ (long long) slots_primary, (long long) mib_primary,+ o.spec, o.mtp_max_t,o.suffix_draft, (long long) (free_b >> 20), cvec_summary.c_str(),- (long long) (strata::kernels::cpu::expert_layout().total >> 20), pool.workers(), o.pcie_frac,+ (long long) ((o.mmap_experts ? src.resident_bytes() : strata::kernels::cpu::expert_layout().total) >> 20),+ pool.workers(), o.pcie_frac,o.spec_min_p);}// issue #29: a request whose heartbeat (tokens, prompt chunks, verify windows) stops for this long is stuck on