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

Start the GPU host-callback thread before the host is pinned, by default (STRATA_ADAPT_CALLBACK_WARMUP=0 turns it off)

Niko12210e20d9aee9ab
diff --git a/bench/results/2026-10-11-rtx-5090-callback-affinity/README.md b/bench/results/2026-10-11-rtx-5090-callback-affinity/README.md
index 950f5f0b9..36da32bd0 100644
--- a/bench/results/2026-10-11-rtx-5090-callback-affinity/README.md
+++ b/bench/results/2026-10-11-rtx-5090-callback-affinity/README.md
@@ -43,7 +43,7 @@ latencies should not be treated as unprofiled production measurements.
## Opt-in warm-up and inference comparison
-Set `STRATA_ADAPT_CALLBACK_WARMUP=1` and leave `STRATA_ADAPT_OVERLAP=1`.
+The warm-up is on by default (`STRATA_ADAPT_CALLBACK_WARMUP=0` turns it off, for comparison).
The candidate initializes and synchronizes a no-op CUDA host callback before
constructing `ExpertPool`, leaving its worker free to run on the process's
original allowed CPUs. It does not change swap selection, notifications,
diff --git a/docs/DETAILS.md b/docs/DETAILS.md
index d7d87d4f9..3d0ef9cb5 100644
--- a/docs/DETAILS.md
+++ b/docs/DETAILS.md
@@ -1704,7 +1704,7 @@ the pairs in which the switched arm won). They are here so you can try them on y
`STRATA_ADAPT_NOWAIT` or `STRATA_DMA_BATCH`; otherwise the log says why it is off. RTX A4000, 6 interleaved pairs each,
decode median tok/s: Q2_0 16 GB 62.5 -> 66.2 (+5.9%), Q2_0 as a 12 GB card 51.3 -> 54.2 (+5.7%), IQ3_XXS 16 GB 48.6 -> 52.6 (+8.3%),
IQ3_XXS as 12 GB 39.3 -> 41.5 (+5.5%), 6/6 pairs faster every time.
-- **`STRATA_ADAPT_CALLBACK_WARMUP=1` (Linux CUDA, opt-in): initialize the CUDA host-callback thread before the CPU
+- **`STRATA_ADAPT_CALLBACK_WARMUP` (Linux, on by default since 0.1.43.1; =0 turns it off): start the GPU host-callback thread before the CPU
pool pins the host thread.** A callback thread created later can inherit the host's one-CPU affinity and compete
with the verifier spinning for its signal (#1975). The warm-up runs and synchronizes one no-op host callback before
constructing the pool; swap selection, per-layer callbacks and residency updates stay unchanged. On an RTX 5090 /
diff --git a/src/program/generate.cpp b/src/program/generate.cpp
index 884e38398..4592c3103 100644
--- a/src/program/generate.cpp
+++ b/src/program/generate.cpp
@@ -4741,16 +4741,20 @@ int main(int argc, char** argv) {
#endif
srcp = &arena_src;
}
-#if defined(__linux__) && !defined(STRATA_USE_HIP)
- if (const char* e = std::getenv("STRATA_ADAPT_CALLBACK_WARMUP"); e && e[0] == '1' && adapt_overlap()) {
- // CUDA creates its host-callback thread lazily. Create it before ExpertPool pins this thread:
- // otherwise it inherits the host core and competes with the verifier's busy wait for its signal.
+#if defined(__linux__)
+ // 0.1.43.1: on by default (STRATA_ADAPT_CALLBACK_WARMUP=0 turns it off). Linux threads inherit the creator's CPU mask, and
+ // the host pins itself to one CPU later; a callback thread the driver creates lazily after that would run on the
+ // host's CPU and fight the host's spin-wait (985 us instead of 4 us per callback, #1964 #1975). Windows CPU Sets are
+ // per thread and not inherited.
+ if (const char* e = std::getenv("STRATA_ADAPT_CALLBACK_WARMUP"); !(e && e[0] == '0')) {
+ // The driver creates its host-callback thread lazily. Create it before ExpertPool pins this thread.
if (cudaLaunchHostFunc(nullptr, [](void*) {}, nullptr) != cudaSuccess ||
cudaStreamSynchronize(nullptr) != cudaSuccess) {
- std::fprintf(stderr, "strata generate: cannot warm up the CUDA host-callback thread\n");
- return 1;
+ (void) cudaGetLastError();
+ std::fprintf(stderr, "strata generate: could not warm up the GPU host-callback thread (continuing)\n");
+ } else {
+ std::fprintf(stderr, "strata generate: GPU host-callback thread started before host-core pinning\n");
}
- std::fprintf(stderr, "strata generate: CUDA host-callback thread warmed before host-core pinning\n");
}
#endif
strata::kernels::cpu::ExpertPool pool(o.pool_workers, /*pin=*/true, /*host_works=*/!o.no_host_worker,