leleka-gpu-npu-worker (crates/gpu-npu-worker) splits a long prompt: the NPU path takes the first share of the tokens and the GPU path the rest, on two threads. They meet only in the KV cache, through the new leleka_gptoss::LayerCache, which both prefill paths now use instead of &mut State (same behaviour). The GPU part's cache waits for each layer the NPU part stores, so the GPU runs layer l while the NPU runs l+1. The last-token distribution matches the GPU alone (KL <= 1e-4). Measured: 2048 tokens 0.89-1.13x against the GPU alone, depending on share; agent episode (4 turns of ~2,060 new tokens, 6 alternating pairs) 0.81-1.16x per pair, a net loss. Both paths stream all weights whatever their token share and share the 15 W budget, and the NPU part's CPU attention over the growing context is the slow side. Not adopted; stays experimental. Also: NpuPrefill::with_cpu_threads, and -ArmA/-ArmB/-LogDir in Compare-PrefillWorkers.ps1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
62 lines
4.3 KiB
Markdown
62 lines
4.3 KiB
Markdown
# One prompt prefilled by the iGPU and the NPU together (STRA-220, experimental; measured: no gain)
|
|
|
|
`leleka-gpu-npu-worker` is the CPU worker's decoder and protocol with long prompts split between the two accelerators
|
|
(`crates/gpu-npu-worker`). The NPU path (`docs/npu-service.md`) takes the first `--npu-share` of the tokens and the GPU
|
|
path (`docs/igpu-prefill.md`) the rest, on two threads at once. Both run the prompt layer by layer and meet only in the
|
|
key and value cache (`leleka_gptoss::LayerCache`): the GPU part's attention at layer `l` needs the NPU part's keys and
|
|
values of layer `l`, so its cache view waits until the NPU part has stored that layer, while the NPU part never waits.
|
|
The GPU part runs layer `l` while the NPU part runs layer `l + 1`. Each part keeps its own numerics; the last token's
|
|
distribution agreed with the GPU alone (same top token, KL 8e-5 to 1e-4 in every probe run).
|
|
|
|
```powershell
|
|
cargo build --release -p leleka-gpu-npu-worker -p leleka-npu-service
|
|
.\target\release\leleka-gpu-npu-worker.exe --serve --model <gpt-oss-20b-MXFP4.gguf> --openvino-root <openvino_toolkit_windows_*> `
|
|
[--npu-share 0.45] [--split-min-tokens 1024] [--gpu-min-tokens 256] [--gpu-batch 512] [--npu-batch 2048]
|
|
```
|
|
|
|
`LELEKA_SPLIT_LOG=1` prints the time of each part and how long the GPU part waited. Without the NPU service it prefills
|
|
on the GPU alone; without a GPU it serves from the CPU.
|
|
|
|
## Why it was tried
|
|
|
|
Run as two separate processes on two separate prompts, the iGPU and the NPU together prefill 93-98 tokens/s against
|
|
73-77 for the faster one alone (`benchmarks/results/igpu-npu-concurrent-prefill-2026-10-16.txt`), so the two units do add
|
|
throughput where decode cannot (decode is limited by the one memory channel). The question was whether one prompt can
|
|
use that.
|
|
|
|
## Results (Core Ultra 7 265U, gpt-oss-20b-MXFP4, 2026-10-16; machine otherwise idle, power and clocks not controlled)
|
|
|
|
Probe `examples/split_prefill.rs`, 2048 synthetic tokens, GPU alone against the split, alternating (one pair per line):
|
|
|
|
| NPU share | GPU alone | split | speed-up |
|
|
| --- | --- | --- | --- |
|
|
| 0.45 | 28.6 s, 28.5 s, 28.7 s | 25.3 s, 26.6 s, 28.9 s | 1.13, 1.07, 0.99 |
|
|
| 0.5 | 31.6-35.2 s | 31.8-33.7 s | 1.05, 0.94, 1.06, 1.09 (last two with the NPU part capped at 8 and 4 CPU threads) |
|
|
| 0.6 | 29.3 s | 33.0 s | 0.89 |
|
|
| 0.7 | 32.7 s | 36.5 s | 0.90 |
|
|
|
|
Agent-shaped episode through the control plane (`benchmarks/tools/Compare-PrefillWorkers.ps1 -ArmA leleka-igpu-worker
|
|
-ArmB leleka-gpu-npu-worker`, NPU share 0.5, four turns of about 2,060 new tokens each over a growing cached context, 32
|
|
output tokens per turn, 3 + 3 alternating pairs; `benchmarks/results/agent-episode-gpu-npu-ab-2026-10-16.jsonl`, split
|
|
log in `agent-episode-gpu-npu-split-log-2026-10-16.txt`). Episode totals, iGPU worker against the split worker:
|
|
170.5 vs 177.4 s, 176.1 vs 152.3 s (run 1, pairs 2-3), 202.3 vs 209.9 s, 178.2 vs 214.2 s, 173.3 vs 214.4 s (run 2).
|
|
In run 1 the split arm's first pair took 35, 84, 110 and 148 s per turn; the cause was not captured and did not recur.
|
|
|
|
Conclusion: no reliable gain, and a loss over the episode. Not adopted; the worker stays as an experiment.
|
|
|
|
## Why it does not pay
|
|
|
|
* Each part's time hardly falls with its share of the tokens: both paths stream every layer's weights once per prefill
|
|
whatever the token count, and when both run, they share the 15 W power budget and the memory channel. With the NPU
|
|
path running, the GPU's 1,024-1,126 tokens took as long as 2,048 tokens alone (attention about 10 s, experts about
|
|
19 s in both cases); 819 and 614 tokens took longer still.
|
|
* The NPU part is the slow one: 1,025-1,065 tokens took 35-39 s in the first turn and 46-59 s in later turns, because
|
|
its attention runs on the CPU over the whole cached context, which grows by about 2,000 tokens a turn. The GPU part
|
|
waited 3-12 s per turn for it.
|
|
* Capping the NPU part's CPU threads (`NpuPrefill::with_cpu_threads`, 8 or 4 of 14) changed nothing measurable, so the
|
|
GPU was not starved of CPU time.
|
|
|
|
Splitting the experts instead (each device streams half of the expert weights for every token) would remove the
|
|
duplicated weight streaming, but by the timings above the gain would be about 1.1x after contention, so it was not built.
|
|
Two concurrent requests, one per device, are the case where the two accelerators measurably add throughput.
|