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

Layer split: STRATA_SPLIT_TIMING (per-stage host time per window); docs/MULTI_GPU.md

Niko12218d09be6051c1
diff --git a/docs/MULTI_GPU.md b/docs/MULTI_GPU.md
new file mode 100644
index 000000000..b7d8bd311
--- /dev/null
+++ b/docs/MULTI_GPU.md
@@ -0,0 +1,67 @@
+# Strata on two or three GPUs (layer split)
+
+One model can run across several NVIDIA cards in one PC. The layers are split into contiguous ranges, one per GPU:
+the first card runs layers 0 to K-1, the next card runs K onward, and so on; the last card also runs the output head
+and the draft (MTP) layer. Each card keeps an expert cache for **its own layers only**, so two cards hold about twice
+the experts one card holds - for the Coder model on a 16 GB + 24 GB pair, nearly all of them, which is where the
+speed comes from (decode then barely touches the CPU pool).
+
+This is pipeline (layer) parallelism, not tensor parallelism: a token crosses from one card to the next once per
+verify window (a few hundred KB through pinned RAM), not twice per layer. No NVLink or peer-to-peer access is
+needed; cards on x4 or x1 slots work, and the PCIe share of each card is probed on its own link.
+
+## Using it
+
+At setup time (Windows: `START-HERE.bat`, Linux: `./setup.sh`):
+
+```
+--gpus 0,2 the cards, as nvidia-smi numbers them; the first is the main one
+--layer-split auto (default) or the first layer of each later card, e.g. 18 or 16,32
+```
+
+or in an existing config (`strata-*.json`), then restart:
+
+```json
+"gpu": [0, 2],
+"layer_split": "auto"
+```
+
+The engine flags behind it: `--layer-split K1[,K2..]|auto` and `--split-device D1[,D2..]` (the later stages'
+devices; default the next visible ones). `--layer-split K --split-device 0` runs both stages on one card sharing
+everything - the bit-exact check of the hand-off, not a speed mode.
+
+**auto** tries every placement (all of them for two or three cards; proportional to the free VRAM beyond that) and
+keeps the one whose caches would hold the most of the expert profile, hottest pairs weighted most; ties go to the
+placement that leaves the fullest card the most room. The startup log prints the choice:
+
+```
+strata generate: layer split auto: K=19 - the caches hold 11767 of 12288 profiled pairs (fullest device 100%)
+strata serve: layer split: layers 0-18 (CUDA0), 19-47 (CUDA1), one hand-off per window
+```
+
+## What each card holds
+
+- **every card**: a copy of the dense weights (~3.4 GB for the Coder), its own session state (the KV cache of the full
+ context), its verify window and its prompt-path buffers, and an expert cache for its layers filled from the profile;
+- **the last card**: also the output head and the draft layer (~0.8 GB);
+- **host RAM**: the expert arena once, shared by all cards (the CPU pool computes whatever no card holds).
+
+Prompts are read in chunks that flow through the cards in turn; while a later card reads chunk c, the first card
+already reads chunk c+1. Conversation checkpoints save and restore every card's state; the adaptive expert swaps copy
+into the card that owns the layer.
+
+## Limits (for now)
+
+- Not with images (`--vision`), control vectors / the speed projection, KV streaming (`--kv-resident`), the older
+ helper-GPU experiment (`--expert-cache-remote`, docs/SECOND_GPU.md) or `--mmap-experts`.
+- The prompt path has its own buffers on every card (1.5 GB each at the default 2048-token chunk; `--prefill 1024`
+ halves that) instead of borrowing cache slots as one card does.
+- Mid-prompt checkpoints (`--prompt-cache-every`) are off; the ones at turn boundaries - what a chat reuses - stay.
+- On Windows only 8 GiB of the expert arena is pinned (more, mapped into two GPU contexts, leaves WDDM refusing
+ allocations); the PCIe share covers those layers.
+- Every card needs compute capability 8.0 (RTX 30 or newer). A Turing card (RTX 20, sm_75) builds only with the
+ experimental `-DSTRATA_EXPERIMENTAL_SM75=ON`.
+
+## Measured
+
+See `bench/results/2026-09-29-layer-split/` for the full runs.
diff --git a/src/program/generate.cpp b/src/program/generate.cpp
index adcb00e77..63d20ec1b 100644
--- a/src/program/generate.cpp
+++ b/src/program/generate.cpp
@@ -3979,6 +3979,16 @@ int main(int argc, char** argv) {
100.0 * (double) req_hits / (double) req_look,
(long long) req_hits, (long long) req_look);
}
+ // STRATA_SPLIT_TIMING: where each verify stage's host time went, cumulative per window since the start
+ // (waiting for its GPU to ring a layer, the CPU pool and plan per layer, staging the window)
+ if (static const bool st_timing = std::getenv("STRATA_SPLIT_TIMING") != nullptr; st_timing)
+ for (int st = 0; st < n_stages; ++st) {
+ const strata::core::Verifier& v = stage_ver(st);
+ const double w = v.windows > 0 ? (double) v.windows : 1.0;
+ std::fprintf(stderr, "strata serve: stage %d: %lld windows; per window: wait for the GPU %.3f ms, "
+ "pool + plan %.3f ms, host staging %.3f ms, commit %.3f ms\n", st,
+ (long long) v.windows, v.ms_wait / w, v.ms_pool / w, v.ms_host / w, v.ms_commit / w);
+ }
if (g.n_qsa_layers() > 0 && ss.qsa_states[0].kv_mode == 1) {
// KV streaming, cumulative over the process: blocks the selections named vs blocks read from RAM
uint64_t miss = 0, look = 0;