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++
engine: the expert cache reserves the draft head's VRAM (0.1.27's CJK subset came out of the 700 MiB reserve, #199); a clear message when no VRAM is left for the cache (#174); the prompt's verify-window stage has its own label (#217)
Niko1221eef241178c93
diff --git a/include/strata/core/mtp.hpp b/include/strata/core/mtp.hppindex 6df843ba2..2224060e9 100644--- a/include/strata/core/mtp.hpp+++ b/include/strata/core/mtp.hpp@@ -53,6 +53,9 @@ public:/// KV streaming: refill the ring of the drafter's window from its host copy for a sequence that continues at/// `upto` (a conversation-cache resume). No-op unless the drafter's K/V is a ring.void kv_restore(int64_t upto);+ /// The VRAM bind() will allocate for a native head of `head_row_bytes` per vocabulary row: the draft logits and+ /// the draft head over rt/draft_vocab.bin's subset. The expert cache is sized before bind(), so it reserves this.+ uint64_t bind_bytes(uint64_t head_row_bytes, int64_t n_vocab) const;/// The main model's embedding and head, and the verify window's final residuals (T rows, hc*n_embd each).bool bind(const WeightTable& wt, const NativeHead* head, const float* window_R, std::string& err);diff --git a/src/core/mtp.cpp b/src/core/mtp.cppindex 11d16f79c..2b1d79ef8 100644--- a/src/core/mtp.cpp+++ b/src/core/mtp.cpp@@ -292,6 +292,19 @@ bool MtpDrafter::load(const std::string& rt_dir, const ModelGeometry& g, Sessionreturn true;}+uint64_t MtpDrafter::bind_bytes(uint64_t head_row_bytes, int64_t n_vocab) const {+ uint64_t bytes = head_logits_ ? 0 : (uint64_t) max_t_ * (uint64_t) n_vocab * sizeof(float);+ if (dhead_ == nullptr) {+ if (FILE* f = std::fopen((rt_dir_ + "/draft_vocab.bin").c_str(), "rb")) {+ std::fseek(f, 0, SEEK_END);+ const long size = std::ftell(f);+ std::fclose(f);+ if (size >= 4 && size % 4 == 0) bytes += (uint64_t) (size / 4) * head_row_bytes + (uint64_t) size;+ }+ }+ return bytes;+}+bool MtpDrafter::bind(const WeightTable& wt, const NativeHead* head, const float* window_R, std::string& err) {const OnDevice on_device(device_);wt_ = &wt;diff --git a/src/core/verify.cpp b/src/core/verify.cppindex 3422127fe..085135a95 100644--- a/src/core/verify.cpp+++ b/src/core/verify.cpp@@ -148,7 +148,8 @@ bool Verifier::init(const WeightTable& wt, const ModelGeometry& g, SessionState&return false;}if (hits.d_res == nullptr || hits.cache_base == nullptr || hits.blob <= 0) {- err = "verify: needs the profile-filled VRAM expert tier (--expert-profile and --expert-cache)";+ err = "verify: needs the profile-filled VRAM expert tier (--expert-profile and --expert-cache); with "+ "--expert-cache auto, no VRAM was left for it: lower --max-context, use --kv k8v4 or images on the CPU";return false;}std::string why;diff --git a/src/program/generate.cpp b/src/program/generate.cppindex 9a93edd3e..3b091eb20 100644--- a/src/program/generate.cpp+++ b/src/program/generate.cpp@@ -1993,12 +1993,20 @@ int main(int argc, char** argv) {// (with borrowing - the default with a profile - the prompt path lends cache slots instead)const bool borrow = !o.no_prefill_borrow && !o.expert_profile.empty();const int64_t prefill_mib = (o.prefill_chunk > 0 && !borrow) ? 160 + (o.prefill_chunk * 680) / 1024 : 0;- const int64_t reserve = ((int64_t) o.vram_reserve_mib + prefill_mib) << 20;+ // the draft layer's head and logits are allocated when it binds, after this: 0.1.27's CJK subset made them+ // ~110-180 MiB larger, and out of the reserve they left 16 GB cards below the stall line (#199)+ const int64_t mtp_bind = (!o.mtp.empty() && native_head.loaded())+ ? (int64_t) mtp.bind_bytes(native_head.row_bytes(), n_vocab) : 0;+ const int64_t reserve = (((int64_t) o.vram_reserve_mib + prefill_mib) << 20) + mtp_bind;int64_t slots = ((int64_t) free_b - reserve) / (int64_t) strata::kernels::cpu::expert_layout().max_blob;if (!profile.empty()) slots = std::min<int64_t>(slots, (int64_t) profile.size());o.expert_cache = (int) std::max<int64_t>(slots, 0);- std::fprintf(stderr, "strata generate: expert cache auto: %.2f GiB free, %d MiB reserved -> %d slots\n",- (double) free_b / 1073741824.0, o.vram_reserve_mib, o.expert_cache);+ std::fprintf(stderr, "strata generate: expert cache auto: %.2f GiB free, %d MiB reserved (+%lld MiB for the "+ "draft head) -> %d slots\n",+ (double) free_b / 1073741824.0, o.vram_reserve_mib, (long long) (mtp_bind >> 20), o.expert_cache);+ if (o.expert_cache == 0) // the verify window cannot start without it (#174): say what makes room+ std::fprintf(stderr, "strata generate: no VRAM is left for the expert cache: lower --max-context, use "+ "--kv k8v4, run images on the CPU, or close other programs that use the GPU\n");} else if (multi_gpu && o.expert_cache > 0) {// a layer split's prompt path has its own buffers (it borrows no slots): an explicit cache size leaves room// for them and the reserve, or the first prompt fails with "device buffers ... do not fit"@@ -3848,6 +3856,7 @@ int main(int argc, char** argv) {};// tokens [a, b) through the windows: commit all of them, then give the draft layer their residualsauto read_windows = [&](int64_t a, int64_t b, std::string& e) -> bool {+ strata::core::progress_at("reading the prompt (verify windows), from token", a); // #217: not "batched"// every token is committed and the picks are discarded: no head sampling (see set_head_sampling)struct NoHeadSampling {strata::core::Verifier& v;