Commit Graph
5 Commits
Author SHA1 Message Date
Pavlo Ratushnyi 375e13ea87 STRA-338 size-fn: gptoss-npu client, cpu-worker slots/engine/main split 2026-11-06 17:09:55 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 4725df5bdf feat: --cache-slots, one worker keeps the KV caches of several agents and picks the right one (STRA-220)
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>
2026-10-17 03:45:20 +02:00
Pavlo RatushnyiandClaude Opus 5.5 b0f2b23d4e feat: exact prompt-lookup speculative decoding in the worker loop, cost-aware and off by default (STRA-220)
--speculate on leleka-cpu-worker, leleka-igpu-worker and leleka-npu-worker drafts from
prompt lookup, verifies the sampled token plus the draft in one batch
(Model::logits_after_each, bit-identical to one-at-a-time feeding), samples every
emitted token from the real logits and truncates rejected positions from the cache,
so output equals plain decoding. The drafter estimates acceptance per matched-context
length and drafts only the length whose expected tokens per pass beat the pass cost
(measured ratios, then observed pass times). Drafts are clipped to the output budget.
speculate::replay runs a policy over a recorded output without a model.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 12:11:02 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 7a78e87ea8 feat: add leleka-igpu-worker, the CPU worker with GPU prefill for long prompts (STRA-219, phase D)
- cpu-worker: GptOssEngine can take a PrefillAccelerator (falls back to the CPU and drops it on failure)
- igpu-worker: separate executable, same protocol, --gpu-min-tokens/--gpu-batch; CPU-only with a message when
  no GPU is usable
- real-model worker tests no longer assert llama.cpp's later greedy tokens (near-ties that moved with the
  attention/KV/router changes of STRA-214; the first token and the reuse/determinism checks stay); the
  teacher-forced gate is the comparison with llama.cpp

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-15 00:21:20 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 c2a2166fa5 feat: add the CPU worker that serves gpt-oss-20b over the control plane's line protocol (STRA-199, STRA-217)
New crate leleka-cpu-worker (executable leleka-cpu-worker --serve --model <gguf>): loads the GGUF through
the read-only mapping, runs the gpt-oss decoder on the AVX2 / AVX-VNNI kernels, and speaks the stdin/stdout
protocol of Strata's --serve mode (READY, GEN with temperature, top_p and seed, STOP, QUIT, PP, REUSED, T,
DONE, ERR). Prefix reuse across requests, cancellation between prefill chunks and between tokens, a stale
STOP while idle is ignored, the end-of-generation marker is emitted as the last token.

leleka-gptoss gains sampling (greedy, or temperature and top-p over the 1,024 best logits, with a seeded
generator) and prefill_reuse_with (progress and cancellation). A stray NUL byte left in a doc comment by an
earlier shell edit is removed.

Tests: protocol parsing, the request loop against a mock decoder (stop token, length, reuse, STOP, QUIT,
engine failure, broken pipe), and an end-to-end run on the real model (needs LELEKA_GPTOSS_GGUF) that gets
llama.cpp's 16 greedy tokens for "The capital of France is" and reuses the prefix of a longer prompt.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 19:14:31 +02:00