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++
DeepSeek Metal: DS4_BUSY_ALL experiment (off), progress lines
Niko122190359513e3b1
diff --git a/metal/src/mtl_rt.mm b/metal/src/mtl_rt.mmindex 8a0ba7978..bd0fd8499 100644--- a/metal/src/mtl_rt.mm+++ b/metal/src/mtl_rt.mm@@ -218,6 +218,7 @@ struct Busy {id<MTLComputePipelineState> ps = nil;id<MTLBuffer> flag = nil;id<MTLCommandBuffer> last = nil;+ bool running = false;};Busy g_busy;} // namespace@@ -250,7 +251,8 @@ kernel void busy_spin(device volatile atomic_uint* flag [[buffer(0)]], constantg_busy.ok = true;}}- if (!g_busy.ok) return;+ if (!g_busy.ok || g_busy.running) return;+ g_busy.running = true;if (g_busy.last != nil) [g_busy.last waitUntilCompleted]; // (the previous spin has left)*(volatile uint32_t*) [g_busy.flag contents] = 0;uint32_t cap = std::getenv("DS4_BUSY_CAP") ? (uint32_t) std::atoi(std::getenv("DS4_BUSY_CAP")) : 20000u; // ~ tens of ms at most@@ -266,8 +268,9 @@ kernel void busy_spin(device volatile atomic_uint* flag [[buffer(0)]], constant}}extern "C" void ds4_busy_end() {- if (!g_busy.ok || g_busy.last == nil) return;+ if (!g_busy.ok || g_busy.last == nil || !g_busy.running) return;*(volatile uint32_t*) [g_busy.flag contents] = 1;+ g_busy.running = false;}Context::Context() : impl_(new Impl) {diff --git a/src/dsv41/ds4_main.cpp b/src/dsv41/ds4_main.cppindex 1ecf4fa2a..9a997e77a 100644--- a/src/dsv41/ds4_main.cpp+++ b/src/dsv41/ds4_main.cpp@@ -991,6 +991,14 @@ int main(int argc, char** argv) {out.push_back(tok);std::printf("%d,", tok);std::fflush(stdout);+ if (std::getenv("DS4_PROGRESS") && out.size() % 200 == 0) { // (sustained-run time series)+ static double tp = now_ms();+ static size_t np = 0;+ const double tn = now_ms();+ std::fprintf(stderr, "progress %zu tokens: %.2f tok/s over the last %zu\n", out.size(), 1000.0 * (double) (out.size() - np) / (tn - tp), out.size() - np);+ tp = tn;+ np = out.size();+ }if ((tok == 1 && std::getenv("DS4_NO_EOS") == nullptr) || (int) out.size() >= n) break; // (DS4_NO_EOS: decode n tokens whatever)if (got.empty()) {int off = 0, acc = 0;diff --git a/src/dsv41/ds4_model.cu b/src/dsv41/ds4_model.cuindex 60f56c5ba..341536959 100644--- a/src/dsv41/ds4_model.cu+++ b/src/dsv41/ds4_model.cu@@ -7584,6 +7584,13 @@ struct Model::Impl {}bool forward(const int* tk, int T, int logits_rows, std::string& err, int seed_rows = -1) {+#if defined(STRATA_METAL)+ struct BusyAll { // DS4_BUSY_ALL: the GPU is held busy for the whole step (the host gaps between its bursts too)+ bool on;+ BusyAll() : on(std::getenv("DS4_BUSY_ALL") != nullptr) { if (on) ds4_busy_begin(); }+ ~BusyAll() { if (on) ds4_busy_end(); }+ } busy_all;+#endifif (T < 1 || T > kWin) {err = "a window of " + std::to_string(T) + " tokens";return false;