<|start|>system<|message|>You are ChatGPT, a large language model trained by OpenAI.
Knowledge cutoff: 2024-06
Current date: 2026-10-15

Reasoning: low

# Valid channels: analysis, commentary, final. Channel must be included for every message.<|end|><|start|>developer<|message|># Instructions

Answer concisely.<|end|><|start|>user<|message|>Explain this design note in your own words.

# Leleka CPU runtime (AVX2 / AVX-VNNI)

Status on 2026-10-14: runs gpt-oss-20b (MXFP4 GGUF, the lmstudio-community file with SHA-256
`65d06d31a3977d553cb3af137b5c26b5f1e9297a6aaa29ae7caa98788cde53ab`) end to end through the control plane's
worker protocol. Not wired into the control plane's request path yet (see "Not done").

## Crates (a separate runtime; shares only `crates/backend-api` with others)

| Crate | Role |
| --- | --- |
| `leleka-cpu-sys` | The only `unsafe` code of this runtime: SIMD kernels (`std::arch`, AVX2 and AVX-VNNI plus a portable level), read-only file mapping, core topology. Every public function is safe and checks lengths and CPU support. Optional test features: `c-reference` (the first, C implementation, compared bit for bit) and `ggml-oracle` (llama.cpp's quantizers). |
| `leleka-cpu-kernels` | Runtime dispatch by CPUID (`LELEKA_CPU_ISA` overrides and fails rather than silently switching). |
| `leleka-gguf` | Bounded GGUF reader and per-token byte inventory. |
| `leleka-gptoss` | The decoder: persistent thread pool, chunked prefill, prefix reuse, f32 KV cache, sampling. |
| `leleka-tokenizer` | `gguf_bpe`: gpt-oss tokenizer from the GGUF vocabulary. |
| `leleka-harmony` | Prompt rendering and output parsing of the Harmony chat format. |
| `leleka-cpu-worker` | The executable: `leleka-cpu-worker --serve --model <gguf> [--threads N] [--ctx N] [--no-warm] [--seed N]`. |

## Worker protocol

Same lines as Strata's `--serve` mode (`control-plane/src/wire.rs`). The worker prints `READY <ctx> stop`
after loading (and, unless `--no-warm`, reading every page of the model once), then per request:
`PP <done> <total>` after every prefill chunk, `REUSED <n>`, `T <id>` per generated token, and one
`DONE <generated> <prompt_tokens> <prompt_ms> <decode_ms> stop|length|cancel 0 0 <reused> 0 0` (or `ERR`).
Input: `GEN <max_new> [temperature=] [top_p=] [seed=] <ids>`, `STOP`, `QUIT`. The end-of-generation marker
(`<|return|>`, `<|call|>` or `<|endoftext|>`) is emitted as the last `T` so the caller can tell an answer
from a tool call. A `STOP` while no request runs is ignored. Tokenization and Harmony rendering/parsing
belong to the caller (the crates above are the pieces for it).

## What was measured (Core Ultra 7 265U, 15 W, 32 GB class laptop; one noisy machine, no quiet gate for
every number; see the work results on STRA-214 and STRA-217 for the paired runs)

* Decode, 10 threads, warm pages: 85-100 ms per token (10-11.7 tokens/s). Bionic's llama.cpp measured
  7.6-8.7 tokens/s on the same prompt on this machine (STRA-209, partial baseline).
<|end|><|start|>assistant<|channel|>final<|message|>