- The expert arena was pinned at most 8 GiB whenever a layer split (or remote experts) ran, on every OS - a Windows/WDDM workaround that cost a Linux 4090 + 3060 split two thirds of its prompt speed (#253, bettercallcaleb). The cap now applies only under WDDM (_WIN32, or WSL2 detected by /dev/dxg), for multi_gpu and expert_cache_remote alike. STRATA_ARENA_PIN_GIB overrides it on any OS: "0" pins the whole arena, N > 0 at most N GiB (arena_pin_cap_gib(), -1 when unset: the same name and meaning as the S2 branch's helper, file-local here). - The split's prompt chunk no longer stops the start when its buffers do not fit: a prompt path without a loan first gets the largest chunk whose buffers (Prefill::bytes_needed) leave 512 MiB free on its device, and an init that still fails steps down one size (8192 -> 6144 -> ... -> 2048 -> 1536 -> 1024 -> 512): Prefill::reset() frees what the failed init made, the loans are re-priced, and the failed allocation's sticky error is consumed (else the next launch check reported "out of memory"). - pinned.cu: the capped note no longer says "for CUDA1". - docs: MULTI_GPU.md, SECOND_GPU.md. Measured on amdbox (Linux, R9700 + RX 9070 XT, gpu [1, 0], Coder IQ1_M, 128 greedy tokens; tok/s): | cache | arm | 4K cold | 4K warm | 16K cold | 16K warm | decode | | auto (holds ~all) | 8 GiB cap | 678 | 1,355 | 1,709 | 1,880 | 44.5-51.5 | | | whole arena | 703 | 1,234 | 1,729 | 1,864 | 44.6-51.4 | | fixed 1500 on CUDA0 | 8 GiB cap | 608 | 1,101 | 1,287 | | 34.5-36.1 | | | whole arena | 716 | 1,160 | 1,803 | | 34.8-36.0 | (2 starts per arm for auto, 5 for fixed.) With most experts streamed the whole arena reads a 16K prompt 40% faster; with every expert already on the cards the two are within noise except 4K warm (-9%: the pinned share raises the auto lend to 90% and the streamed ring to 384 slots). Identity: the fixed-cache arms gave the same tokens in all 5 + 5 starts (4K, 16K, 4K again), and the auto arms 2 + 2. The step-down was exercised on the 9070 XT with --expert-cache 3000 --no-prefill-borrow --prefill 8192 ("need 4528 MiB, 2910 MiB free: 2048-token chunks"; with the init retry alone it went 8192 -> ... -> 2048, and 1536 ran all four requests). Known, also on main: that own-buffer configuration at 2048 makes hipBLAS pick hipBLASLt kernels whose code objects this ROCm 7.14 lacks (TensileLibrary_..._gfx1201-xnack+.co not found, "launchKernel failed") and the prompt hangs. The WDDM side (Windows, WSL2) is unchanged and not re-measured here.
86 lines
4.8 KiB
Markdown
86 lines
4.8 KiB
Markdown
# CUDA1–3 expert experiment
|
||
|
||
CUDA0 keeps the dense layers, KV/state, MTP and its existing expert cache. Up to
|
||
three independent expert caches fill CUDA1, CUDA2 and CUDA3 in that order. Each
|
||
expert has one owner: CUDA0, one secondary GPU, or the CPU pool. Each secondary
|
||
GPU computes its rows while the CPU pool works; the results return through
|
||
private pinned host buffers before CUDA0 continues the layer. The GPU launches
|
||
can overlap, but each layer waits for all three.
|
||
|
||
The shipped profile ranks 8,000 `(layer, expert)` pairs. CUDA0 takes its usual
|
||
`--expert-cache auto` allocation. With only CUDA1, it takes the first remaining
|
||
pairs. When CUDA2 or CUDA3 is enabled, the remaining profiled pairs are assigned
|
||
round robin to the secondary GPUs. The ranked list is then extended with all
|
||
other pairs in expert-then-layer order and distributed in the same way. This
|
||
fills the additional VRAM and lets all secondary GPUs see frequent experts, but
|
||
unranked experts may hardly ever be routed. The startup
|
||
log reports slots and GiB per card; each request reports the number of expert
|
||
entries actually computed on each secondary GPU. Remote outputs are packed
|
||
before returning over PCIe/USB4: the request log compares MiB transferred
|
||
with the previous full-row transfer. The input and routing metadata use pinned
|
||
host staging. This reduces transfer traffic and launch overhead, but does not
|
||
release the expert arena in system RAM or significantly change VRAM use.
|
||
|
||
The optional `--gpu-placement layer` gives each layer to exactly one secondary
|
||
GPU (layer number modulo the number of enabled cards). It fills that card with
|
||
the most frequently routed experts of its layers first, then the unranked ones.
|
||
This can reduce USB4 device switches and synchronization when several secondary
|
||
cards serve the same layer in the default `stripe` mode. All three cards still
|
||
keep their requested expert slots; the primary CUDA0 cache and CPU fallback
|
||
continue to work. The log counts active layer launches on each card, so the
|
||
tradeoff can be measured alongside tokens per second. This placement is
|
||
experimental and may be slower if a given layer needs more than one card's
|
||
compute capacity.
|
||
|
||
The experiment requires the corresponding visible CUDA devices and a CUDA
|
||
enabled build. Each card must keep at least 512 MiB free. Tiers must be enabled
|
||
in order. Under WDDM (Windows, WSL2), CUDA registration of the host expert arena is capped at
|
||
8 GiB to leave room for the contexts and MTP on CUDA0 (`STRATA_ARENA_PIN_GIB` overrides it; on Linux the whole
|
||
arena is registered). The rest remains
|
||
available to the CPU pool; the PCIe expert path is available only for the
|
||
registered layers. Without secondary GPUs, the original uncapped registration
|
||
behavior applies.
|
||
|
||
On an existing Linux installation, apply the patch to its source tree, then run:
|
||
|
||
```sh
|
||
./setup.sh --setup --gpu1-experts 5000 --gpu2-experts 5000 --gpu3-experts 5000
|
||
```
|
||
|
||
On Windows, from PowerShell in the installation folder:
|
||
|
||
```powershell
|
||
.\START-HERE.bat --setup --gpu1-experts 5000 --gpu2-experts 5000 --gpu3-experts 5000
|
||
```
|
||
|
||
To test the layer placement instead, add `--gpu-placement layer` to the setup
|
||
command. To go back, run the same command with `--gpu-placement stripe`. After
|
||
the new engine is built, the mode can also be changed without a rebuild: edit
|
||
`--expert-cache-remote-placement` in `strata-iq3_xxs.json` from `layer` to
|
||
`stripe` or vice versa and restart the server. If the argument is absent, the
|
||
default is `stripe`.
|
||
|
||
Choose the same model, size, context and image settings as your current
|
||
installation when prompted. Setup recompiles the engine, updates its server
|
||
configuration, and starts it. Later starts keep those settings. To tune the
|
||
slots without recompiling, edit the values after `--expert-cache-device1`,
|
||
`--expert-cache-device2` and `--expert-cache-device3` in the stored
|
||
`strata-iq3_xxs.json`, then restart with `.\run-iq3_xxs.bat`.
|
||
|
||
Compare identical requests at one, two and four GPUs, preferably with several
|
||
repeats. VRAM use alone does not show useful offload: compare the per-request
|
||
CUDA1–3 counts and tokens per second. More GPU contexts and synchronization
|
||
may lower the speed. Prompt prefill still uses CUDA0; secondary GPUs serve
|
||
decode, including MTP verification. No peer-to-peer access is required.
|
||
|
||
Longer contexts reserve more KV/state memory on CUDA0, which reduces its
|
||
automatic expert cache. On a 64 GB PC `setup.py` limits IQ3_XXS to 128K even
|
||
if 262K was selected; the secondary caches still require the host expert arena.
|
||
To try 262K on 64 GB, choose Q2_0 or IQ2_XS instead and check that CUDA0 still
|
||
has enough free VRAM after loading. Benchmark long prompts separately from
|
||
short decode requests.
|
||
|
||
The existing warning about the CUDA0 expert-cache GPU hit path still applies:
|
||
its outputs diverge from cache-off runs. Treat performance as experimental
|
||
until the generated tokens have been validated.
|