GptOssEngine holds up to N conversation caches (--cache-slots N on the four workers, default 1 =
unchanged). crates/cpu-worker/src/slots.rs chooses per prompt: continue in place a slot that is
wholly a prefix of the prompt (the same agent's next turn); otherwise take the slot sharing the
longest prefix as a donor and either continue it (losing its tail) or copy the shared part into
a new/empty/least recently used slot (State::copy_prefix_from), whichever discards fewer cached
tokens, so a new agent gets the shared system prompt without destroying another agent's cache.
Results are bit-identical to a fresh prefill (synthetic test: copied prefix continues bit for
bit, donor untouched).
Measured: CPU only, 3 agents, 36 requests: 1.37x/1.46x prompt time, outputs identical.
Through the control plane, 4 agents on one iGPU worker, 3 clean alternating pairs: 986/993/995 s
with 1 slot against 569/575/575 s with 4 slots (1.73x), answers identical in all six runs. The
first run of pair 1 was disturbed by the UTC date in the system prompt changing mid-run and was
repeated. Compare-ConcurrentEpisodes.ps1 takes -Agents, -SharedInstructionTokens and the
'slots' arm and records output hashes.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
engine.extra_workers starts further supervised workers behind the one request channel
(control-plane/src/pool.rs). A dispatcher hands each request to an idle, ready worker,
preferring the one whose last prompt shares the longest prefix with it, so each conversation
keeps its cached prefix. It learns completion by relaying the result channel, so the worker
and its tests are unchanged. /ready and /status need every member ready. 4 dispatcher tests;
the 13 failing control-plane tests fail identically at 3ebcb3f (Windows).
Paired A/B, two scripted 4-turn episodes sent at once (Compare-ConcurrentEpisodes.ps1, 3
alternating pairs each), time until both are done:
- one iGPU worker, interleaved: 686-713 s; pool: 254-306 s, 2.33-2.73x. Mostly the second
KV cache: the single worker re-prefilled every turn.
- one iGPU worker running the episodes in sequence: 317-342 s; pool: 292-303 s,
1.05-1.14x. This is the second device's own share. Per-turn latency in the pool is higher.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
- gptoss-npu: a prefill accelerator that sends the matrix products to the NPU service and keeps norms, RoPE,
attention, router, activation and combine on the CPU; debugging shadow device; examples for comparison, the
quality dump, a numerics probe and a paired A/B
- npu-worker: separate executable with the CPU worker's protocol, CPU-only fallback, --openvino-root/--npu-*
- the NPU flushes half-precision subnormals to zero, which erased every Q8_0 block with scale < 2^-14
(error 11% on attn_output); the service now boosts such rows' scales by a power of two and reports the
per-column shifts the client divides out (relative rms error back to 3e-4 on all shapes)
- Smoke-GptOssStack.ps1 takes -Worker leleka-npu-worker -OpenVinoRoot; passes through the control plane
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Four turns of ~1380 new tool-output tokens each on a growing cached prefix, three alternating pairs:
episode wall time 333.0 s (CPU worker) vs 125.0 s (GPU worker), paired 2.60x / 2.70x / 2.70x. Scripted
episode, not real agent traffic; the answers were not compared.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Smoke-GptOssStack.ps1 takes -Worker leleka-igpu-worker -GpuMinTokens N. With every prompt forced through the
GPU (N=1): plain answer, function call, tool-result round trip with prefix reuse (134 of 181 tokens cached)
and streaming all pass through the control plane. dot4_peak measures 4.49 TOPS of dot4I8Packed with no memory
traffic on this iGPU, against 0.67-0.86 TOPS for the GEMM kernels (tile sweep in docs/igpu-prefill.md).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
benchmarks/tools/Smoke-GptOssStack.ps1 starts strata-next with leleka-cpu-worker for a GGUF and checks a
plain question, a function call, a tool-result round trip that must reuse the cached prefix, and a
streaming request, then stops what it started. Run on the reference laptop with gpt-oss-20b: all pass
(second-turn prefix reuse 134 of 181 prompt tokens; 5.3 s for a short answer, 6-8 s for tool turns).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The first decoder spawned OS threads for each of about 385 matrix-vector products
per token, which made it slower with more threads (257 ms per token at 5 threads,
538 ms at 12). It now keeps a pool of parked workers; the products of a layer
are grouped into four regions (QKV, output projection, expert gate+up, expert
down) and participants claim row chunks from a shared counter, which suits the
mixed fast and slow cores. Weights are referenced through shared handles into the
mapped file so jobs are 'static. Adds a per-phase profile, a page pre-touch for the
mapping, and a real-model runner option for it.
Measured on the reference laptop (quiet machine, single runs, short context, NOT
paired; indicative only): 120 to 160 ms per token at 5 to 10 threads cold, 115 ms
(8.7 tokens/s) at 10 threads with pre-touched pages. Same 16 greedy tokens as
llama.cpp. The synthetic end-to-end tests still match the independent f64
reference and give identical logits at every thread count.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
leleka-gptoss reads the model hyper-parameters from the GGUF header and views
the weights in place in the memory-mapped file; only norms, biases, router and
sinks are copied. One-token forward pass: RMSNorm (f64 sum), attention with
grouped KV heads, learned sinks and alternating sliding/full layers, YaRN RoPE
in NeoX pairing, router with softmax over the selected logits, MXFP4 experts with
the clamped gated activation, Q8_0 attention and output head. Row-parallel
matrix-vector products; f32 KV cache. Greedy generation.
Tests: unit tests of each operation against f64 formulas, and an end-to-end test
on a tiny synthetic gpt-oss (ggml-quantized random weights) against an
independent f64 implementation: worst relative logit difference about 1e-7 over
three seeds, identical logits at every instruction-set level and thread count.
Whether the maths equals the real model's is NOT yet tested: that needs the
llama.cpp oracle (STRA-212 acceptance criteria).
leleka-cpu-sys gains a safe read-only file mapping (Windows and Linux). The
benchmark script now reproduces Bionic's server flags, supports concurrent
requests and reports aggregate speed. No speed claim is made.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
leleka-gguf reads the header of a GGUF file with bounded allocation (limits plus
the file size), validates tensor shapes against block geometry from the pinned
ggml, offsets against alignment, overlap and the end of the file, and builds an
inventory of which bytes one decoded token reads in a mixture-of-experts model
(experts scaled by used/total, one embedding row, full attention, router, norms
and output head). No dependencies, no unsafe. 13 tests on synthetic files, including
hostile headers and truncation at every length.
benchmarks/tools adds Capture-MachineState.ps1 (drift fields of the reference
laptop record, quiet-machine gate) and Measure-LlamaServer.ps1 (rotating-round
measurement of llama.cpp-style servers with the machine state before and after).
Tested only against a fake local server; no real model has been measured yet.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>