Skip to content

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++

Adaptive overlap: the host-function signal is the Windows default, and the copy stream is flushed after the swaps are queued (#2188)

Niko1221cb22a53e0e7b
diff --git a/docs/DETAILS.md b/docs/DETAILS.md
index 998d661eb..1c570419a 100644
--- a/docs/DETAILS.md
+++ b/docs/DETAILS.md
@@ -1748,6 +1748,11 @@ the pairs in which the switched arm won). They are here so you can try them on y
- **`STRATA_ADAPT_SIGNAL=host`: the overlap's per-layer "landed" signal as a host function** (the 0.1.43 way). From 0.1.43.1 the default is a
4-byte stream-ordered copy into pinned memory, which needs no driver callback thread: on a 20-core desktop (RTX 3060) the host
functions still cost ~7 ms per window with the thread started early, because the pool's workers occupy every other CPU.
+ **On Windows the host function stays the default** (0.1.44, #2188): under WDDM the copy and its signal waited in the
+ driver's command buffer while the window spun on the pinned int, and the first request stopped with "the adaptive
+ tier's copies for layer 45 never landed" (RTX 4070 SUPER, driver 617.42). `STRATA_ADAPT_SIGNAL=copy` asks for the copy
+ there; the engine now flushes the copy stream after queueing the swaps, which is meant to fix it but has not been run
+ on Windows yet.
## Thread placement: `--aux-cpus` (Linux, off by default)
diff --git a/src/program/generate.cpp b/src/program/generate.cpp
index 0328b3874..adf971222 100644
--- a/src/program/generate.cpp
+++ b/src/program/generate.cpp
@@ -8471,7 +8471,20 @@ int main(int argc, char** argv) {
for (int64_t l = 0; l <= g.n_layers; ++l) agate.ticks[(size_t) l] = {&agate, (int32_t) l};
agate.has.assign((size_t) g.n_layers, 0);
if (!ver.set_adapt_gate(&agate)) aov_why = "the device-planned layers (STRATA_VERIFY_DEVICE_PLAN) are on";
- if (aov_why == nullptr && !(std::getenv("STRATA_ADAPT_SIGNAL") && std::getenv("STRATA_ADAPT_SIGNAL")[0] == 'h')) {
+ // #2188: on Windows the default is the host function. Under WDDM a stream's work sits in the driver's
+ // command buffer until something flushes it, and nothing does while the host only spins on the pinned
+ // int: the first request stopped with "copies for layer 45 never landed". STRATA_ADAPT_SIGNAL=copy asks
+ // for the stream-ordered copy there too (the enqueue then flushes the stream), =host everywhere.
+ const char* asig = std::getenv("STRATA_ADAPT_SIGNAL");
+#if defined(_WIN32)
+ const bool sig_copy = asig != nullptr && asig[0] == 'c';
+#else
+ const bool sig_copy = !(asig != nullptr && asig[0] == 'h');
+#endif
+ if (aov_why == nullptr && !sig_copy)
+ std::fprintf(stderr, "strata serve: adaptive overlap signal: host functions%s\n",
+ asig == nullptr ? " (the Windows default, #2188; STRATA_ADAPT_SIGNAL=copy: a stream-ordered copy)" : "");
+ if (aov_why == nullptr && sig_copy) {
// the landing of each layer's copies is told by a stream-ordered D2H copy of the layer number into pinned memory
// (STRATA_ADAPT_SIGNAL=host: a host function instead). No callback thread has to be scheduled while the pool's workers spin on every other CPU
int32_t* vals = nullptr; void* hp = nullptr;
@@ -8661,6 +8674,9 @@ int main(int argc, char** argv) {
return false;
}
if (!swaps.empty()) cudaEventRecord(adapt_ev, adapt_stream);
+ // #2188: hand the copies and their landing signals to the GPU now. WDDM batches a stream's work until a
+ // driver call flushes it, and the verify window only spins on the pinned int (Linux submits at once: no-op)
+ if (aov && agate.hland != nullptr && !swaps.empty()) (void) cudaStreamQuery(adapt_stream);
(void) main_live;
for (auto& st : stages)
if (st->adapt_live) {