Commit Graph
15 Commits
Author SHA1 Message Date
Pavlo RatushnyiandClaude Sonnet 5.5 bf4f01b3ac perf: vec4 shared-memory attention kernel for the GPU prefill (STRA-219)
One full layer over a 512-token batch ending at position 4096: 0.52 s -> 0.22 s (8192: 1.07 s -> 0.44 s).
4096-token synthetic prompt, single unpaired run: 91.9 s -> 67.5 s (60.7 tok/s; CPU 247 s earlier). Same
tests against the CPU attention. Teacher-forced vs llama.cpp on the gate text: 95.3% / KL 0.0121 (the
earlier kernel gave 97.1% / 0.0100): the two GPU runs differ from each other by KL 0.0058, as much as GPU vs
CPU (0.0067-0.0080) and the CPU's own scalar vs SIMD (0.0048); a second text shows GPU-vs-CPU noise equal
to CPU-scalar-vs-SIMD noise (docs/igpu-prefill.md). Reported as borderline against the strict KL limit.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-15 00:38:20 +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 d8460a0e8d feat: add the leleka-gptoss-igpu crate: GPU prefill of gpt-oss that fills the CPU decoder's KV cache (STRA-219, phase C)
- gptoss: PrefillAccelerator hook, Model::prefill_reuse_accelerated, layer/weight views, embed,
  next_from_hidden (shared with the CPU forward pass), State KV export/import
- igpu: threaded weight repacking (131 s -> 6 s of upload for 24 layers), explicit half rounding of block
  scales (the compiler folds the pack/unpack round trip away), matmul_rows, buffer reads/writes at offsets
- teacher-forced gate with GPU prefill: best token 97.1% vs llama.cpp, mean KL 0.0100, NLL +0.0148;
  vs the CPU decoder KL 0.0067 (see docs/igpu-prefill.md). Experimental, not wired into the worker.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-15 00:10:43 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 4c00f0d209 feat: keep the gpt-oss KV cache in half precision (STRA-214)
Keys and values are stored as IEEE half floats (49 KB per token instead of 98 KB, llama.cpp's default
cache type). New cpu-sys kernels read them directly: attention scores and weighted value sums over half
floats (portable and AVX2 + FMA + F16C, blocked over positions like the f32 ones) and a vector
float-to-half conversion that is bit-identical to the portable one. The decoder writes rotated keys and
values through Dispatch::f32_to_f16; the synthetic f64 reference rounds K and V the same way.

Teacher-forced gate against llama.cpp (same 383 tokens): best token 97.4% (unchanged), mean KL 0.0077
(was 0.0082 with f32 cache), next-token NLL 1.2852 vs 1.2798. The conversions cost a little attention time
(2,000-token context, one noisy run: decode attention 9.9 ms against 7.7 ms with f32), which is the price
of halving the cache. The worker's default context rises to 32,768 tokens (1.6 GB).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 22:35:50 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 4231c20377 docs: document serving gpt-oss through the control plane; add an end-to-end smoke script (STRA-218)
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>
2026-10-14 22:24:50 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 eea344850d perf: run attention on AVX2 kernels, one pass over the keys and values per KV head (STRA-214)
Attention was scalar and latency bound. New kernels in cpu-sys (portable and AVX2 + FMA): scores for a
group of query heads against strided keys, weighted value sums for the group, and a vector exp for the
softmax (relative error below 3e-7). The 8 query heads that share a KV head are processed together over
blocks of 16 positions, so each key and value row is read into L1 once per group instead of once per head.
ops::attend_group_with_sink uses them through Dispatch; a group is bit-identical to its heads run one at a
time (test), and the kernels are checked against f64 references for odd widths, strides and block sizes.

Measured on gpt-oss-20b, 10 threads, 2,000 tokens of context (one run each, noisy machine): decode
attention 27.4 -> 14.5 -> 7.7 ms per token (per-head SIMD, then grouped), decode 116 -> 95 ms per token
(10.5 tokens/s, the same as at short context); prefill attention 8.9 -> 2.1 ms per token. Teacher-forced
quality gate against llama.cpp: best token 97.4% (was 97.1%), mean KL 0.0082 (was 0.0080).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 19:41:09 +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
Pavlo RatushnyiandClaude Sonnet 5.5 d661812b09 feat: add the gpt-oss tokenizer and the Harmony prompt renderer and parser (STRA-213)
leleka-tokenizer gains gguf_bpe: a byte-level BPE tokenizer built from the vocabulary in the GGUF file
(gpt2 model, gpt-4o pre-tokenizer), with special-token parsing that is off by default so user text cannot
forge markers, and a UTF-8-safe streaming decoder. Checked against llama.cpp's /tokenize on 67 strings: same
ids except the two documented differences (llama.cpp forges some Harmony markers from text; it splits
words at combining marks, which the o200k expression keeps together).

New leleka-harmony crate: render() reproduces the gpt-oss chat template (including its whitespace) and is
byte-identical to llama.cpp's /apply-template on ten conversations with many tool-schema shapes;
HarmonyParser turns generated tokens into reasoning, answer and tool-call events.

The oracle fixtures are test strings, token ids and rendered prompts only. The tokenizer oracle test needs
LELEKA_GPTOSS_GGUF and reports "skipped" without it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 19:08:24 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 c1444d98ac perf: run the CPU kernels from Rust std::arch instead of C (STRA-214)
The MXFP4, Q8_0, int8 and int4 kernels, the Q8_0 quantizer and the half conversions are now Rust
(cpu-sys/src/simd.rs), written operation for operation after the C versions. The C code stays only behind
the test-only feature c-reference, and tests/rust_vs_c.rs checks bit-identical results at the portable,
AVX2 and AVX-VNNI levels. A runtime build compiles no C.

Paired decode on gpt-oss-20b (40 tokens, 10 threads, 5 alternating rounds): median 98 ms per token for
both builds, identical tokens and first-step log-probabilities.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 18:32:31 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 fa921a2ced feat: add Q8_0 activation quantizer and Q8_0 x Q8_0 dot kernels (STRA-211)
Completes the Q8_0 side of the CPU runtime's kernel set: a float-to-Q8_0
quantizer (scale = amax / 127 as a half, quants rounded to nearest even and
clamped to [-127, 127]) and the Q8_0 x Q8_0 dot, each at scalar, AVX2 and AVX-VNNI
(the quantizer shares the AVX2 code). Tests: the quantizer is bit-identical across
levels and equal to the vendored ggml reference except on exact .5 ties; per-block
integer sums are exact; float results are within the stated tolerance of an f64
reference built from ggml's dequantizer; the portable half conversion equals the
F16C instruction on over a million values. Windows MSVC and Linux GCC, debug and
release. Replaces _cvtss_sh (not available in MSVC) with the packed conversion.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 16:01:32 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 efd4018a46 feat: add experimental pre-converted activation layout, topology helper and paired benchmarks (STRA-211)
Adds two EXPERIMENTAL AVX2 MXFP4 kernels that take the activation as f32
scales plus contiguous int8 quants (q8r, q8r4). q8r is tested bit-identical to
the ggml-layout kernel; q8r4 against the stated tolerance. Adds Windows core
topology and thread pinning (cpu-sys topology module) and three kernel-level
benchmarks that interleave variants and report paired ratios.

Findings, recorded in docs/experiments/2026-10-14-cpu-kernel-layout-and-pinning.md:
the chip has 2 fast cores and 10 slower ones; the new layout was faster for a
single thread (paired median 1.32x, 15 pairs) and inconclusive with many
threads; thread pinning did not beat the OS default. The machine was not in a
controlled state, so these are not accepted performance results.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:32:30 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 164bfa60b8 feat: add MXFP4 x Q8_0 dot kernels at scalar, AVX2 and AVX-VNNI (STRA-211)
The gpt-oss-20b experts are MXFP4, so the CPU runtime needs this dot product.
Blocks use ggml's byte layout, so GGUF tensors can be read in place. Per-block
integer sums are exact at every level; the float combination is checked against
an f64 reference built from the vendored ggml dequantizers (test-only
ggml-oracle feature) within a tolerance written before the run. Scale
conversion is compared exactly with ggml for every E8M0 code and every finite
half. AVX2 level now means AVX2 + FMA + F16C. ABI version 2.

Adds a kernel-level throughput example (bench_mxfp4); it is not an inference
benchmark and no end-to-end speed claim is made. Records the ggml upstream use
in docs/upstream-ggml.md.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:17:52 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 79e2e8d40e docs: pin Colibri upstream and start the port ledger (STRA-200)
Colibri (JustVugg/colibri, Apache-2.0) is an upstream source for the CPU
runtime, not a dependency. Record the pinned commit, archive and licence
digests, the porting rules, and a per-file ledger with adopt/adapt/reject
decisions. docs/upstream.md (Strata pin) is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:00:02 +02:00
Pavlo Ratushnyi 1662ac3bb5 docs: record reference laptop identity (STRA-107)
This adds revision 1 of the reference-laptop record for the Windows Core Ultra 7 265U laptop with the Intel AI Boost NPU: identity facts, state at capture, constraints, a drift rule and benchmark pre-conditions, each fact tied to a numbered read-only command run without elevation. Later benchmark and NPU work needs one citable hardware, driver and power identity, so results can be traced to a machine state and flagged stale when that state changes. The page carries one machine-readable block that reuses the vocabulary of the desktop hardware inventory, and the full raw capture stays outside Git and is referenced by its SHA-256 digest only. Power mode, CPU temperature, NPU generation and the NPU memory limit are marked UNVERIFIED rather than inferred, and the page makes no capability or performance claim.

Checks before this commit: no line over 120 characters (longest 118), the JSON block parses and agrees with the tables, 8 relative links and anchors resolve, git diff --check is clean, and the exclusion-list scan against the private capture values found zero matches. Independent reproduction of each documented command is still pending.
2026-10-07 15:51:41 +02:00
Pavlo Ratushnyi 4013e0c9bd Import tracked Strata Next source snapshot
Desktop foundation / core (ubuntu-latest) (push) Failing after 28s
Desktop foundation / core (macos-latest) (push) Canceled after 0s
Desktop foundation / core (windows-latest) (push) Canceled after 0s
Linux / verify (push) Canceled after 0s
Linux / keyless-cuda (push) Canceled after 0s
Linux / static-cuda-package (push) Canceled after 0s
Linux / hosted-cuda-package (push) Canceled after 0s
Linux / linux-static-cli (push) Canceled after 0s
Linux / linux-cli-container (push) Canceled after 0s
Linux / release-cli (push) Canceled after 0s
2026-10-05 18:15:08 +02:00