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++
adapt-async (#876): keep the blocking tier when the exchange buffers are pageable, and report ms per round
Niko12215288cd290278
diff --git a/include/strata/core/expert_source.hpp b/include/strata/core/expert_source.hppindex e46271419..9bc1e6b46 100644--- a/include/strata/core/expert_source.hpp+++ b/include/strata/core/expert_source.hpp@@ -480,6 +480,8 @@ public:/// Host room for `n` evicted blobs (page-locked when possible). Idempotent for the same or a smaller `n`.bool reserve_exchanges(int64_t n, std::string& err);int64_t exchange_capacity() const { return xstage_cap_; }+ /// The exchange buffers are page-locked (cudaHostAlloc): copies to and from them are asynchronous.+ bool exchange_pinned() const { return xstage_pinned_; }uint8_t* exchange_buffer(int64_t q) const;/// Requires `has_resident(layer, in)`, `!has_resident(layer, out)` and `exchange_buffer(q)` holding out's blob.bool stage_exchange(int64_t layer, int64_t in, int64_t out, int64_t q);diff --git a/src/program/generate.cpp b/src/program/generate.cppindex 02ef8e211..58a99d96e 100644--- a/src/program/generate.cpp+++ b/src/program/generate.cpp@@ -4800,6 +4800,10 @@ int main(int argc, char** argv) {// page-locked (an asynchronous copy instead of the driver's staged, synchronous one)if (o.adapt_async && !src.reserve_exchanges(2 * std::min<int64_t>(o.adapt_swaps, 96), err))adapt_async_off(err.c_str());+ // pageable buffers would make every copy of a round synchronous (the driver stages them): that is the+ // blocking tier's cost, so the asynchronous tier is not worth running - said, and the blocking tier stays+ if (o.adapt_async && !src.exchange_pinned())+ adapt_async_off("the exchange buffers could not be page-locked");if (o.adapt_every > 0 && o.adapt_swaps > 0 &&!src.reserve_exchanges(std::min<int64_t>(o.adapt_swaps, 96), err)) {std::fprintf(stderr, "strata generate: CPU expert residency: %s\n", err.c_str());@@ -5872,6 +5876,8 @@ int main(int argc, char** argv) {std::vector<float> a_usage;std::vector<int32_t> a_res;int64_t a_win = 0, a_last = 0, a_rounds = 0, a_swapped = 0;+ double a_ms = 0; // wall time from a round's start to its flip, summed (the "ms/round" stat)+ Clock::time_point a_t0;std::atomic<bool> a_err{false};std::vector<AHome> ahomes; // [0] = CUDA0's cache, [k] = layer split stage k'sstd::unique_ptr<JobThread> ajob;@@ -5991,6 +5997,7 @@ int main(int argc, char** argv) {if (drain || a_win - a_last < (int64_t) o.adapt_every) return true;a_last = a_win;++a_rounds;+ a_t0 = Clock::now();a_usage = drive.d.usage;a_res = host_res;// #477: the routing counted, as adapt() counts it (--expert-profile-save; else `heat` is empty)@@ -6040,6 +6047,7 @@ int main(int argc, char** argv) {if (!a_ready(drain)) return true;if (a_err.load()) return false;src.commit_flip();+ a_ms += std::chrono::duration<double, std::milli>(Clock::now() - a_t0).count();aswaps.clear();astate = AState::Idle;continue; // a round due now starts at this same boundary@@ -7993,8 +8001,9 @@ int main(int argc, char** argv) {(double) src.resident_bytes() / 1073741824.0, (long long) src.exchanges(),(long long) src.file_reads());if (ajob) // --adapt-async, cumulative (a round may still be in flight: it lands before the next request)- std::fprintf(stderr, "strata serve: asynchronous adaptive tier: %lld rounds, %lld experts swapped in\n",- (long long) a_rounds, (long long) a_swapped);+ std::fprintf(stderr, "strata serve: asynchronous adaptive tier: %lld rounds, %lld experts swapped in, "+ "%.1f ms per round (start to flip, between windows)\n",+ (long long) a_rounds, (long long) a_swapped, a_rounds > 0 ? a_ms / (double) a_rounds : 0.0);// CS-T: the tiers, cumulative - GPU cache hits (the decode lookups above), RAM copy, files (SSD / OS cache)if (srcp == &src)std::fprintf(stderr, "strata serve: expert tiers: GPU %lld hits this request; since the start RAM %lld blobs, files %lld blobs "