Commit Graph
67 Commits
Author SHA1 Message Date
Pavlo RatushnyiandClaude Opus 5.5 e0141e510a model-format: opt-in huge-page placement of the resident expert banks (LELEKA_HUGEPAGES)
LELEKA_HUGEPAGES=on|thp (off by default; LELEKA_BANK_THP=on now selects thp) places each of the 144
resident bank copies in its own 2 MiB-aligned anonymous mapping instead of a heap Vec: MAP_HUGETLB when
HugePages_Free covers the bank (mode on only; nothing reserved), else MADV_HUGEPAGE + MADV_POPULATE_WRITE.
After the bank load and the shard page-cache drop, before cuMemHostRegister, huge_pages::settle() reports
the coverage from /proc/self/smaps and MADV_COLLAPSEs any 2 MiB range that fell back (best effort).
Pure placement: the bytes are the file's (read_tensor_into, same bounds and size fences). No system
setting is read-write.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 00:11:36 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 4232adaf44 cuda-driver: opt-in LELEKA_DRAFT_VOCAB selects an upstream draft subset (en, cyrillic, fr or a file)
The MTP draft head projects over the rows listed in rt/draft_vocab.bin (106,299 ids). Upstream ships
draft_vocab_en.bin (40,525 ids, 65,774 head rows fewer: ~110 MiB of VRAM and a shorter draft GEMV, at the
price that CJK/Cyrillic tokens can never be proposed). LELEKA_DRAFT_VOCAB=en|cyrillic|fr|<path> picks one;
unset (or 0/off/default) keeps rt/draft_vocab.bin and reads, logs and changes nothing.

* a selected file must have the sha256 of a recorded upstream subset (a name: that name's digest);
  another digest, a symlink, a wrong size or a too-large file is refused (the arm fails to load)
* a file that does not exist falls back to rt/draft_vocab.bin with one `FALLBACK` log line
* the startup VRAM reserve follows the selected file's size, so the freed VRAM reaches the expert slots
* one `leleka-serve draft-vocab: ... subset=en ids=40525 sha256=... file=...` line per bind when set
* sha2 becomes a dependency of leleka-cuda-driver (already in the workspace)

Unit tests (CPU only): setting parsing, table consistency, default reads/logs nothing, missing file
falls back, wrong digest refused for a name and a path, accepted digest reads the selected ids and the
reserve probe sees its size, malformed/oversized/symlink refused, subset index <-> full id round trip
and ids outside a subset. A real-file test runs when LELEKA_TEST_DRAFT_VOCAB_DIR names a directory
with the upstream draft_vocab*.bin (digests, counts, en ascending and inside the default list).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-30 03:28:10 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 d096ecd8e8 kernel_ab example: KAB1 reader, bitwise or pre-declared-tolerance compare, COMPONENT_KERNEL record writer (STRA-289)
Rust half of the CPU kernel A/B, part 1: crates/native-cpu-expert/examples/kernel_ab.rs
(verify, compare, internal run-tree) over the public API only; sha2 as a dev-dependency.
lib.rs untouched, unsafe_code stays deny. Timing fields of the records are explicit
NOT_MEASURED markers (STRA-318).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-28 20:43:05 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 b3274c1130 Merge claude/port-gpu-bringup (CUDA runtime port, upstream sync) into main
Linux / keyless-cuda-gate (push) Skipped
Rust port / port-typecheck (push) Failing after 8s
Desktop foundation / core (ubuntu-latest) (push) Failing after 11s
Rust port / port-oracles (push) Failing after 11s
Rust port / port-linux-tests (push) Failing after 14s
Rust port / port-fast (push) Failing after 9s
Linux / verify (push) Failing after 17s
Linux / keyless-cuda (push) Skipped
Linux / static-cuda-package (push) Skipped
Linux / hosted-cuda-package (push) Skipped
Linux / linux-static-cli (push) Skipped
Linux / linux-cli-container (push) Skipped
Linux / release-cli (push) Skipped
Brings the Rust/CUDA port of the Strata mode17 serve path together with the
CPU/iGPU/NPU gpt-oss runtime that main gained meanwhile.

Control plane: the Qwen tokenizer is the implementation behind the Qwen35
variant of codec::TextCodec (qwen(), encode_prompt() widen the trait; QwenCodec
derefs to the tokenizer), so control-token marks, images, chat template, the
runtime backend and vision keep their behavior, while the gpt-oss/Harmony path
and the worker pool keep main's. Config carries the union of fields; extra_workers
is rejected together with runtime, lazy_load, idle_unload_s and vision; the
gpt-oss family refuses top_k/min_p/penalties (its GEN line has no such keys).
leleka-kar-codec takes f16_bits_to_f32 from leleka-quant-core (identical code).
Workspace members and default-members are the union of both sides.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-27 08:32:33 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 6fde2ff222 leleka.exe: the WSL2 front end (up/preflight/verify through wsl.exe with path translation and .wslconfig advice; status/reconfigure/down over loopback HTTP; doctor), Windows facts probe, native defaults, Windows preflight/plan, deploy tests pass on Windows and Linux
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-25 13:11:44 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 1bbb9d1b8e desktop-core and control-plane build and test natively on Windows: api-key init (hard-link publish, user profile ACL), atomic no-replace directory publish via MoveFileExW, tokenizer export without directory fsync, MSVC link stubs for the ggml bridge, Unix-only shell-script tests gated
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-25 12:45:21 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 34dca798f3 Windows: leleka-memory answers the governor from Win32 in /proc text, model-format maps files read-only and reads the KAR by seek_read, native-cpu-expert compiles with Win32 affinity/prefetch
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-25 12:16:24 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 6ec32e25af cuda-driver compiles on Windows: libc shim crate (dlopen family -> LoadLibrary, VirtualLock, page size, read-only file mapping), Windows arms for the file mapping and available-memory readers
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-25 12:06:52 +01:00
Pavlo Ratushnyi acabd3fc82 Merge branch 'claude/cp-latency' into claude/port-gpu-bringup 2026-10-24 02:00:07 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 f96074c360 perf(startup): verify shards and archive in parallel with read-ahead, verification stamps, attested sealed archive, parallel memfd fill, leleka verify
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 01:28:11 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 95340330ac cp-latency: fast tokenizer (scanner + id BPE + segment cache), pass the prompt text through, TCP_NODELAY on the runtime gRPC server, gRPC replay example
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 01:13:50 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 71320722f2 chore: lockfile entry for leleka-memory after the merges
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 05:09:56 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 7da6a63e61 feat(memory): leleka-memory crate: procfs/cgroup/PSI facts, inventory, load ledger, budget planner, pressure monitor, governor, memfd lock/residency guard, census
Model-free and CUDA-free. 64 unit tests (parsers, planner refusals with numbers, shed order and hysteresis, admission, sampler thread,
mlock/mincore/madvise over a descriptor, flatness check).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-18 01:20:21 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 d84e1a12c9 feat(deploy): leleka up/run - preflight, profiles, assets, install, supervisor, readiness
New crate leleka-deploy (binary leleka): idempotent one-command deployment with
preflight (driver, sm_120/sm_86, VRAM/RAM/disk, WSL2, cuBLAS 12, memfd), memory
profiles, plan/dry-run, stamped asset steps, systemd unit, and a native supervisor
that seals the KAR archive itself and hands it to the engine (no Python holder).
leleka-inference gains --kar-archive-file for the low-RAM read-only archive form.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-17 14:34:49 +02:00
Pavlo RatushnyiandClaude Opus 5.5 3ebcb3ffd6 experiment: one prompt prefilled by the iGPU and the NPU together; measured, no gain (STRA-220)
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>
2026-10-16 15:42:12 +02:00
Pavlo RatushnyiandClaude Opus 5.5 f3c4e122d8 experiment: real KAR codec quality on gpt-oss-20b and concurrent iGPU+NPU prefill (STRA-220)
The KAR codec moves unchanged from control-plane/src/kar_codec.rs into crates/kar-codec
(re-exported there, so the control plane's KAR tests are unchanged and pass). Probes, off
unless set: LELEKA_EXPERIMENTAL_KAR_LEVELS / _KAR_TENSORS for attention and output weights,
and LELEKA_EXPERIMENTAL_KAR_EXPERT_LEVELS / _KAR_EXPERT_LAYERS for the MXFP4 experts
(level 0 is a storage-only control). Teacher-forced against llama.cpp, baseline KL 0.016:
attention+output at 6.5/5.5/4.5 bits give KL 0.063/0.095/0.213 (uniform rounding was
0.071/0.112/0.270), and every tensor group fails alone; experts of 6 of 24 layers at 3.5
bits give KL 0.081 (control 0.018). No KAR rate passes the gate on this model. Corrects the
earlier doc claim that a KAR layout is the same as uniform rounding.

iGPU and NPU prefill run at the same time give 93-98 tok/s in total against 73-77 for the
faster device alone (2048 tokens each, two rounds).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 13:55:44 +02:00
Pavlo RatushnyiandClaude Opus 5.5 6c208972ba feat(experts): low-RAM mapped expert source (the Original's --mmap-experts, GGUF in place)
The serve stack's routed experts came only from `load_resident_expert_source`, a 50 GB RAM copy of the
144 shard-0 banks that `MappedExpertBank` then page-locks whole: impossible on a 32-48 GB PC.

* model-format: `ResidentTensor` storage is an owned copy or a read-only MAP_SHARED mapping of the verified
  shard (`VerifiedGgufFile::map_resident_tensor`, same descriptor, bounds and size checks);
  `Qwen4ExpArtifact::load_mapped_expert_source` builds the same bank catalog from mappings, no RAM
  admission (generate.cpp `src.set_gguf` + `FileExpertSource::open`). The crate's lint is relaxed from
  forbid to deny so exactly this mapping owner can allow its mmap/munmap/slice.
* cuda-driver: a lease of mapped banks makes `MappedExpertBank` pageable: no cuMemHostRegister; every
  consumer the Original serve stack uses (`cache_source` for the prompt copy ring, VRAM tier fills/swaps,
  PCIe staging) copies with cuMemcpyHtoDAsync from pageable memory; the zero-copy device aliases
  (`retained_span_handle`, `copy_triplet`) are refused.
* runtime: `ModelBinding::load_mapped_expert_source`.

The bytes are the file's, so consumers see what the resident copy holds. Unit test
`mapped_tensor_is_the_files_bytes_and_a_retained_owner`; model-format --lib 128 passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 11:27:08 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 edb2d49687 feat(control-plane): accept the harmless Codex hints (service_tier, user, text.verbosity, reasoning.effort minimal, summary none)
text.format becomes optional so a text object may carry only a verbosity. concise/detailed
summaries, max_tool_calls and other include values stay refused. New HTTP tests run a Codex-shaped
two-turn exchange with stateless replay and the tool_choice / parallel_tool_calls enforcement
through the runtime stack.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-16 03:06:03 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 c8601d0b2c feat(control-plane): runtime block selects the runtime backend; strata-next serves in front of leleka-inference
runtime.{address,token_env,tokenizer_dir,model,mode,max_context} are validated at load
(loopback only, credential from the environment and never printed, exclusive with
engine/native_model/mtp_pack/vision/gpu). serve spawns backend_worker over GrpcBackend.
The worker carries the runtime's output-token cap in WorkerStatus; a default budget never
exceeds it, an explicit request above it is refused. Request ids are UUIDs, as the
runtime contract requires.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-16 02:46:22 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 c9aad38caa refactor: extract the runtime gRPC client into leleka-runtime-client and add GrpcBackend
proto/runtime.proto, the wire conversions and the validated RuntimeClient move out of
strata-desktop-core so strata-next can use them; strata-desktop-core re-exports them
unchanged. GrpcBackend implements the Backend contract by attaching to a runtime an
operator already loaded (no Load/Unload RPC), re-reading epoch and handle before every
generation, and ending a generation without a terminal event on any transport or frame
error. 9 loopback HTTP/2 tests with a scripted runtime server.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-16 02:42:11 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 a4259d8f2b feat(control-plane): worker for a text-level engine behind the existing HTTP API
backend_worker drives any leleka_backend_api::Backend through the GenerationCommand
channel strata-next already uses. It maps the rendered prompt to the engine contract
(verified round trip of the ids), re-tokenizes text deltas with a byte-equality check,
recognises the stop literals, maps finish reasons, cancels on client disconnect,
guarantees a terminal event when the engine dies, and re-attaches by itself. What the
text contract cannot carry is refused. 23 HTTP tests over a scripted engine cover
Responses (JSON/SSE), Chat, tools, text.format, cancellation and engine faults.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-16 02:33:45 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 414169be0a feat(desktop-core): leleka-seal-exec seals the KAR archive for leleka-inference without Python
leleka-inference --kar-archive-fd needs a sealed memfd of the pinned length. The
bring-up used operator Python scripts outside the repo to make it; the production
path must not. leleka-seal-exec copies one regular file into a memfd with the
WRITE|GROW|SHRINK|SEAL seals (no close-on-exec, optional exact length pin),
substitutes {FD} in the command and execs it. Linux only; other hosts exit 2.

Tests: the copy has the properties open_sealed_archive_fd checks (regular,
unlinked, pinned size, all seals) and refuses writes, growth and shrinking; the
descriptor survives a real exec and is readable through /proc by the child.
rustix =1.1.5 is the version leleka-runtime already pins.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-16 01:59:26 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 8d96e9c44c perf: overlap weight expansion with NPU execution, batch products, SIMD half conversion, graph cache (STRA-207)
- service: BATCH n lets it see each product's successor and expand the next weights on a thread
  while the device runs the current one; buckets up to 4096; OpenVINO CACHE_DIR compile cache
- client: batched expert products, layout sized by batch, default batch 2048
- cpu-sys/cpu-kernels: AVX2 F16C f16_to_f32 kernel, exact for every half bit pattern
- npu-worker: memory admission before an NPU prefill (falls back to the CPU when RAM is short)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-15 12:22:13 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 b5d9a569b2 feat: add the NPU-assisted prefill client, the NPU worker and the scale-shift fix (STRA-207)
- 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>
2026-10-15 11:37:22 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 204ec34fbd feat: add the NPU service: OpenVINO C binding, shared-memory mappings and a matmul service for gpt-oss weights (STRA-207)
Decision (owner, 2026-10-15): the NPU is used through a separate service process so that the CPU runtime never
loads OpenVINO (STRA-199 v2 D1, E8).
- leleka-shm: read-only file mapping and a read-write region two processes map (recorded unsafe exception)
- leleka-openvino: OpenVINO C API loaded at run time (recorded unsafe exception, NPU runtime only)
- leleka-npu-service: reads the GGUF itself, expands Q8_0/MXFP4 blocks to int8 + half group scales, runs
  y = x . W^T on the device with the weights as run-time inputs, activations through the shared region
- tested against an f64 reference with real weights on CPU and NPU devices: relative rms error 2e-4 to 3e-4

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-15 10:56:29 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 f07302b944 feat: admit GPU prefills by free memory; the worker falls back to the CPU for that prompt (STRA-219)
PrefillAccelerator::admit lets an accelerator refuse a prompt without being disabled. The GPU prefill
estimates its footprint (two layers of weights, scratch, hidden states, caches, 1 GiB headroom; 1.6 GiB
estimated vs 2.0 GiB peak private bytes measured for 1024 tokens before the headroom was raised) and
compares it with a probe; the worker's probe is the OS's available memory (sysinfo). admission_check
exercises both outcomes on the real model. 1024-token prefill with the vec4 attention: 15.9 s (64.5 tok/s),
single unpaired run.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-15 00:48:48 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 afbff794a1 build: register leleka-igpu-worker in the workspace
The worker commit added the crate but not the workspace member entry and lock file update.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-15 00:43:44 +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 762fca1842 feat: add GPU buffers, a launch recorder, bias/accumulate products and RMSNorm+quantize to leleka-igpu (STRA-219, phase B)
- Buf, Recorder: device-resident arrays and batched kernel launches in one submission
- gemm epilogue: optional bias and accumulate into the existing output (residual add)
- rmsnorm_quant kernel: RMSNorm plus Q8_0 quantization per row; matches the CPU decoder's
  rms_norm to 1e-5 relative and the CPU quantizer exactly on the tested shapes

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 23:48:46 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 9a26ace643 feat: add the leleka-igpu crate with GPU matrix products over Q8_0 and MXFP4 weights (STRA-219, phase A)
New pure-Rust crate on wgpu 26 with generated WGSL kernels: C[m][n] = sum over 32-element blocks of the
exact int8 block sum (packed dot-product built-in) times the activation and weight block scales. Weights
are repacked at upload (ggml's unaligned 34- and 17-byte blocks become int8 or nibble words plus separate
half-float or E8M0 scale words); MXFP4 values are decoded in the shader from a nibble-packed magnitude table.
Every accumulator and operand is a named scalar (dynamically indexed private arrays spill on this GPU).

Checked against the CPU kernels: random Q8_0 and MXFP4 weights on awkward shapes (single block, ragged
tiles, 1 to 130 rows) and, with LELEKA_GPTOSS_GGUF set, real tensors of gpt-oss-20b (blk.3.attn_q Q8_0
4096 x 2880; blk.5 gate expert 11 and blk.23 down expert 31, MXFP4 2880 x 2880): all outputs within the
float32 accumulation bound, worst error 0.01-0.02 of it.

Speed (gemm_bench, reference iGPU, one run each): a 4x4-outputs-per-thread tile is best, about 0.7 TOPS
int8 including the block scales (MXFP4 2880x2880: 0.58 TOPS at 32 tokens, 0.68 at 64, 0.72 at 256;
Q8_0 4096x2880 at 256 tokens: 0.79); 8x8 spills registers (0.45). The CPU decoder's equivalent is about
0.25 TOPS. Small products use only ~45 workgroups; batching experts will fill the chip.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 23:27:03 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 c2290e1145 feat: serve gpt-oss through the control plane's Responses API (family adapter) (STRA-218)
Setting engine.gptoss_gguf (or STRATA_GPTOSS_GGUF) selects the gpt-oss family and takes the tokenizer from
that GGUF. Prompts: a Responses request (instructions, input items with reasoning, function calls and
outputs, tools, tool_choice, parallel_tool_calls, text.format, reasoning effort) is rendered as the Harmony
conversation by leleka-harmony; the same replay validation as the Qwen path, one call per assistant message
with its output, no custom tools. Output: a stateful HarmonyDecoder turns the generated tokens into the
reasoning / answer / <tool_call> markup that the existing code parses, so tool-name and argument
validation, history and the streaming events are reused; gpt-oss always reasons, the end-of-generation
markers <|return|> and <|call|> are the terminal tokens, and an open tool call is closed when the
generation ends.

Safety: the renderer can write its special markers as private-use sentinel characters (and replaces those
characters in caller text); the codec turns exactly those into special tokens. Marker-looking text from a
client, in messages, tool descriptions or tool output, stays ordinary text.

Side effect, deliberate: serde_json preserve_order is now on workspace-wide (the renderer needs the client's
property order), so tool-call argument objects keep the model's key order instead of alphabetical; one test
expectation changed accordingly. 52 responses tests and the new family tests pass; the 13 other
control-plane test failures on Windows predate this change.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 22:15:52 +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 d124b7c78d fix(desktop-core): minijinja deps and prompt render error conversion after the Jinja prompt port
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 16:44:36 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 ea7b4c9b83 feat: add the gpt-oss decoder on the CPU kernels and a read-only file mapping (STRA-212)
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>
2026-10-14 16:21:06 +02:00
Pavlo Ratushnyi 2d8d362d6b Merge branch 'claude/port-offline' into claude/port-main
# Conflicts:
#	Cargo.toml
#	control-plane/src/lib.rs
#	crates/context/Cargo.toml
#	crates/context/src/lib.rs
#	crates/model-format/src/qwen4exp_expert_source_bank.rs
2026-10-14 16:09:35 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 e4886247a5 feat: add GGUF reader with per-token byte inventory and benchmark tooling (STRA-210, STRA-209)
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>
2026-10-14 15:53:21 +02:00
Pavlo Ratushnyi 49f22a8daf Merge branch 'claude/port-api' into claude/port-main
# Conflicts:
#	Cargo.toml
2026-10-14 15:53:19 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 250fd3e65d feat(prompt): render the pinned chat template with minijinja instead of a hand-written Qwen format
minijinja =2.24.0 (+ minijinja-contrib pycompat for str methods), configured like serve/frontend.py ChatTemplate:
trim/lstrip blocks, no autoescape, raise_exception, Python tojson (json.dumps ensure_ascii=False) and str.strip trim.
All 10 chat_golden.json cases render byte for byte straight through the template (tool_calls, tool messages, no
generation prompt included). Ordered Json keeps object key order. scripts/offline/diff_chat_template.py: 12000
generated conversations vs jinja2 (identical renders, identical raise_exception messages); committed golden + test.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:53:16 +02:00
Pavlo Ratushnyi c16a050e52 Merge branch 'claude/port-experimental' into claude/port-main
# Conflicts:
#	Cargo.lock
#	Cargo.toml
#	crates/cuda-driver/Cargo.toml
#	crates/leleka-runtime/src/backend.rs
#	crates/leleka-runtime/src/lib.rs
2026-10-14 15:51:28 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 67071b5d30 feat(runtime): all-off experimental-mode config admitted at Load (selection rules, digest mixing, PTX probe, refusal until consumed)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:49:15 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 e80a915a47 feat(cuda-driver): experimental closed programs (opt-in, fail-closed pins, typed facades) with CPU-oracle tests
Six literal .cu ports get a pure admission/geometry module (every entry signature is
cross-checked against the .cu text), a Linux-gated driver facade, #[ignore]d GPU smokes
and zero-pin placeholder PTX. All modes are off by default; KAR's closed-launch ABI is
widened to 24 arguments with a 64-bit scalar.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:45:57 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 18d712eed5 feat(context): reuse the port-rope leleka-context crate and port setup.py's RAM/VRAM sizing rules
crates/context is taken verbatim from claude/port-rope (rope scaling incl. setup_resolve_rope/derived_factor, memory
plan, context policy). New setup_policy module: ram_ctx, ctx_ram_need, resident_budget_gib, low_ram_*; a golden grid
from 'import setup' (resolve_rope/derived_factor too, which the branch had only transcribed) checked bit for bit.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:45:55 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 3485221865 feat(offline-tools): port embd_bf16_pack, ple_fp8_pack, draft_vocab, make_profile, mtp_rt
New crate leleka-offline-tools wired as 'strata-next tools ...'. Every output is byte-identical to the unmodified
Python tool (scripts/offline/diff_tools.py: packs incl. refusal cases, 14 draft-vocab subsets x out/stats, make_profile
at 512/256/8 experts with ranked bases and traces, mtp_rt at the real H/FF geometry). Committed tiny goldens +
integration tests; mtp_rt's multi-MB input is regenerated from a shared splitmix64 rule.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:40:02 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 cce433339d feat(serving): forward all Original GEN sampling fields end to end
control-plane wire.rs builds GEN/GENI lines through RequestSampling::gen_keys plus
strata_tune and the per-request cvec switch (golden-tested against the real
StrataEngine.generate); Responses, Chat Completions and Messages accept and validate
top_k, min_p, repetition/frequency/presence penalties, penalty_last_n, seed and the
engine knobs with the Original's defaults and ranges; server-wide defaults (config
sampling block plus POST /settings shared values) merge under the request. The desktop
runtime gRPC contract carries the full sampling set and the gateway no longer refuses
temperature != 0. New crate leleka-serving-policy holds the pure Original policies
(shared settings, reasoning budget tracker, fixed-point sampling conversion) with
fixtures generated by running the Python handlers.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:17:04 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 594146a79e feat(experimental-ref): CPU references of FWHT-256, Q4_0/INT8 KV quantizers and every KV cell layout
New pure crate with the arithmetic of f16_bits.hpp, kv_q4.cu and kv_q8.cu, the
cell layouts and byte sizes of fp16/INT8/rotated INT8/Q4_0/K8V4/keyless pools
(identical per-cell figures to the memory planner: 2048/1056/576/816/528), and
the generate.cpp format-selection rules. Golden fixtures are produced by the
Original's own host code extracted verbatim with awk (FWHT, Q4_0 quantizer
under separate and fused multiply-add, INT8 K, kv_pool_bytes, kv_block_bytes).
Experimental formats are explicit; nothing is enabled by default.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:12:32 +02:00
Pavlo Ratushnyi cc5c5f17a5 Merge branch 'claude/port-rope' into claude/port-main
# Conflicts:
#	Cargo.toml
#	crates/leleka-runtime/Cargo.toml
2026-10-14 15:08:43 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 37620f1b60 feat: add CPU runtime kernel layer with AVX2 and AVX-VNNI dot products (STRA-202)
leleka-cpu-sys holds the C kernels (one translation unit per ISA level, built
by build.rs with cc) behind a checked FFI; it is the only unsafe code of the CPU
runtime and opts out of the workspace unsafe_code lint with a recorded exception.
leleka-cpu-kernels does safe run-time dispatch with a LELEKA_CPU_ISA override
that fails rather than silently changing level.

Ports the int8xint8 and int4xint8 dot products from Colibri c/idot.h at scalar,
AVX2 and AVX-VNNI. Tests compare every level with the C scalar kernel and an
independent i64 oracle (13 tests; Windows MSVC and Linux GCC 14.2). Activations
must be in [-127, 127]: -128 is outside the contract and a test pins that. No
performance claim: nothing was timed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 15:00:03 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 4b97a14097 feat(driver): size the native QSA stack from the serving context; ROPE-ARGS and n_blocks ABI
- serving_context: process-wide cell count + RoPE constants (default 262144 / identity, unchanged).
- qsa_prompt_kv/host/resolver/index/device/resident*: every 262144-linear literal (staging pools,
  mapped host bytes, page tables, pooled rows, score stride, position guards, kernel max_cells)
  now derives from leleka_context::geometry; identical at the default.
- .cu: the rotating-index kernels (qsa_append_first/blocks, qsa_decode_append, qsa_rope_rows,
  qsa_decode_rope) take the five RoPE constants as trailing arguments instead of baking identity;
  leleka_qsa_stream_reset takes n_blocks. Committed PTX is NOT regenerated: the launch code inspects
  the embedded PTX (ptx_abi) and refuses scaled RoPE / pages > 65536 against the frozen entries.
- MTP drafter bank stays frozen at 262144 (documented, refused by validate_existing_int8_bank).
- dense layouts/rings accept positions below MAX_CONTEXT_CELLS (524288).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 14:58:44 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 4d1594f71c fix(sampler): audit the Original-literal host sampler port against the C++ oracle
- SamplerParams moves to original_sampler_params.rs (pure) and is checked byte for
  byte against the Original struct (size, alignment, offsets, padding) and defaults.
- validate() no longer rejects top_p == 0 (the Original accepts it).
- Draft cell -1 (draft_first at position 0, counter 0) is accepted by
  coupled_draft_counter and OriginalSampler::sample_coupled.
- set_subset keeps the first index and ignores out-of-range ids like setup_coupled.
- Runtime penalty_rows / coupled helpers are compared with the Original header fixture;
  run_port_host_tests.sh runs these pure tests on macOS.

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