49 Commits
Author SHA1 Message Date
Pavlo Ratushnyi 7c000ce93f CI workflows (oracle numpy pin per interpreter, copy-source test harness), ignore rules, root files without docs/ links; AGENTS.md is a local pointer to the MCP (STRA-382) 2026-11-23 09:34:33 +01:00
Pavlo Ratushnyi 94592f4fa0 wip: rename strata-next/strata-control/strata-desktop-core (to be squashed in the final rename commit) 2026-11-14 20:30:41 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 51b45b82d8 leleka-memory loses libc and windows-sys: PageLocking and ProcSource ports, OS adapters in the new L3 crate leleka-memory-os
The two baselined forbidden-dep violations are gone. FdMapping keeps the bounds checks and lock bookkeeping as safe Rust over plain addresses;
mmap/mlock/mincore/madvise/munmap/setrlimit are LinuxPageLocking, the Win32 host facts are WindowsProc, the glibc heap trim moved verbatim.
Governor::real is replaced by leleka_memory_os::real_governor (the page-locking adapter is part of it). No behaviour change.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-13 17:46:38 +01:00
Pavlo Ratushnyi 40896ba217 STRA-338 S24: peel the pure host-side models out of cuda-driver into leleka-cuda-model
New L1 crate crates/cuda-model (leleka-cuda-model, forbid(unsafe_code), depends on leleka-context only) holds:
Error/Result with Display, DenseFormat, RoutedFormat, ProjectionKind (+ layout/alignment/required_modes), ProjectionSpec,
the Bf16/Q5K/Q6K projection shapes, bringup_trace_enabled, and the modules serving_context, host_profile, command_profile,
original_mtp_loader, original_prefill_schedule, qsa_prompt_attention_select, original_expert_slots, native_flash_attn,
s_gemv_legacy, device_arena, mmq_original_prefill_misc (moved with git mv; code unchanged apart from pub visibility and
#[inline] on the tiny cached-switch readers, host_profile::add split into an inlined gate and a cold body).

leleka-cuda-driver re-exports every item at its old path, so no use path in the driver, engine-qwen35-cuda or
native-parity-bench changes. Tests moved with their modules; they read the .cu sources and oracle fixtures of the driver
through driver_source!; the one loader test that needs the driver's session geometry stays in the driver.

Housekeeping: workspace members/default-members, Cargo.lock, architecture.json (L1), hexagonal.md, ci-coverage.json,
check-local.sh, port.yml, linux-tests/run.sh, AGENTS.md. architecture-baseline.json: the source ratchets of the moved code
change crate key (dyn-trait driver 56 to 49 + model 3, env-read 72 to 67 + 5, process-global 110 to 99 + 11), regenerated
with --allow-increase for the new keys only; per-pattern totals do not rise. limits-baseline.json is unchanged: no moved
function is over a limit.
2026-11-07 17:40:24 +01:00
Pavlo Ratushnyi a4ceeab69c STRA-338 S22: the Qwen3.5 CUDA engine moves to the adapter crate leleka-engine-qwen35-cuda (L3, edges to cuda-driver, model-format, native-cpu-expert declared); leleka-runtime is a one-line facade over it; scripts, CI and the baseline follow the path. Test fixes found on the way: the digest pin test reads backend/config.rs, the bring-up print gate understands rustfmt-split cfg attributes and the settings snapshot guards 2026-11-06 11:34:15 +01:00
Pavlo Ratushnyi e049e24fe3 STRA-338 S20: EngineFamily seam in leleka-engine-core, Qwen35Cuda family in leleka-runtime, the scripted engine as leleka-engine-fake; the inference binary and the full-chain test start their engines through spawn::<F>. Ratchets raised by the Box<dyn Backend> signatures of the seam (core +2, fake +1, runtime +1) and 2 test lines: the Backend trait object is the process boundary the gRPC server already held 2026-11-06 11:20:57 +01:00
Pavlo Ratushnyi 38eb771a44 STRA-338 S19a: the cross-session prefix cache and the pure memory admission move to the new leleka-engine-core crate (L2); leleka-runtime re-exports them under the old paths 2026-11-06 10:54:33 +01:00
Pavlo Ratushnyi ff6cb3dcbf STRA-338 S21: leleka-gateway-domain (layer L2): the pure gateway domain leaves strata-control
New crate crates/gateway-domain, the first member of layer L2 in architecture.json (L2 is now a pure layer: tokio, axum,
reqwest, libc and the other adapter crates are forbidden dependencies there). It depends on serde, serde_json,
leleka-sampler-ref and leleka-tokenizer only. Moved out of control-plane/src with git mv, content unchanged apart from
paths: sampling (request sampling extensions, validation) and EngineTune (was in wire.rs), reasoning_budget (the budget
driver and its tests), codec (Family, TextCodec, TokenDecoder, QwenCodec), json_order, and the Chat Completions
translation (chat_completions: Request -> Responses request, reply fields; the axum handlers stay in chat.rs).
strata-control re-exports codec, json_order, reasoning_budget and sampling under their old paths, and wire.rs re-exports
EngineTune, so no caller and no test outside the moved modules changed. 4 new tests cover the chat translation.

Architecture gate: layer entry added; dyn-trait:leleka-gateway-domain = 5 appears because the five dyn in the moved
code (Box<dyn TokenDecoder>, Box<dyn Iterator> in the budget driver, &dyn Fn, ...) change crate; dyn-trait:strata-control
fell 21 -> 16 in the same step, so the total is unchanged (--allow-increase was needed for the new per-crate key only).
Test outcomes: 597 ok / 2 ignored before, 615 ok / 2 ignored after (18 new tests); the 13 moved tests keep their ids in the
new crate and their outcome.
2026-11-05 20:42:48 +01:00
Pavlo Ratushnyi 6155c871b0 worker-protocol: one crate for both ends of the gateway/worker line protocol (STRA-338 S9)
New dependency-free crate crates/worker-protocol (L0): events (Event, Done, Finish, parse_line, moved from control-plane/src/wire.rs),
command (GEN/STOP/QUIT parser, moved from cpu-worker/src/protocol.rs) and lines (READY/T/PP/REUSED/ERR/DONE writers, moved from
cpu-worker). Finish was defined twice (gateway and worker) and is now one enum with a word(). wire.rs re-exports the event types and
cpu-worker/protocol.rs re-exports the old paths, so no caller changes. The gateway's rich GEN writer (golden-tested against the Python
server) stays in wire.rs. New golden: every line the worker writes round-trips through the gateway parser.

Verified (host): cargo test leleka-worker-protocol 8/8, cpu-worker, strata-control all green (0 failed); the 6 moved tests keep their
bodies; clippy -D warnings clean on the new crate; fmt clean.
2026-11-05 13:37:05 +01:00
Pavlo Ratushnyi 7b1922d116 gateway-text: prompt, response_tools and tool_output become one crate; desktop-core no longer compiles them twice (STRA-338 S8)
control-plane/src/{prompt,response_tools,tool_output}.rs (pure text logic: pinned chat template renderer, tool catalog, tool-call
parser) move by git mv to the new leaf crate crates/gateway-text. strata-control re-exports them under the same module paths
(crate::prompt, crate::tool_output keep working for tests and callers); strata-desktop-core replaces its three #[path] includes with
imports. The leleka-runtime GPU proof modules that hash prompt.rs follow the new location. The only text change in the moved files is
the relative include_str path to engine/strata. serde_json features (preserve_order + float_roundtrip) equal what both hosts already
got through unification.

Verified: cargo test strata-control + strata-desktop-core + gateway-text on the host: 504 tests, 0 failed; the 30 tests that vanish
are exactly the duplicate runtime_prompt/runtime_tool_catalog/runtime_tool_parser copies of the same 30 tests (11+2+17), which now run
once. WSL x86_64-linux cargo check --tests leleka-runtime: 62 warnings, unchanged. fmt clean on the new crate.
2026-11-05 13:32:35 +01:00
Pavlo Ratushnyi 0aab895444 native-cpu-expert: drop the production edge to cuda-driver; CPU-vs-CUDA parity bench moves to leleka-native-parity-bench (STRA-338 S11)
rust_bench_cuda.rs and the native_expert_parity bin (the only users of leleka-cuda-driver in the CPU expert adapter) become the new
tool crate crates/native-parity-bench (L4, cargo-checked in the product gate). leleka-native-cpu-expert no longer depends on
leleka-cuda-driver; the architecture baseline drops that violation. Code moved byte-for-byte except the use paths.

Verified (WSL x86_64-linux): cargo check --all-targets for the new crate, native-cpu-expert and leleka-runtime; cargo test -p
leleka-native-cpu-expert all ok (22+2+4+... tests, 0 failed); check-architecture and check-ci-coverage pass.
2026-11-05 13:20:39 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 fb10bf0e70 observability: structured bounded logs, per-request record, metrics, leleka logs / report
* crates/obs (leleka-obs, std only): one event per line (JSON under `leleka run`, key=value on a terminal, the lab's plain lines when a
  binary is started by hand into a file), UTC ms timestamp, level, component, event, flat fields; prompt/completion text and credentials
  never appear (key classes + value scrub + registered secrets), per-event token buckets with a `suppressed` count, value and line caps,
  histogram with Prometheus exposition, size-capped file sink for requests.log.
* control-plane: `observe` middleware gives every generation request an id (x-leleka-request-id header) and a session tag (hash of the
  client's session header); the worker marks engine start / first token / terminal / error on it and one record is written at request end
  (tokens, cached prefix, queue wait, TTFT, prefill/decode tok/s, finish, error class, engine restart, GPU clock/temp/throttle). All
  elog! lines go through the log layer (sampled per call site). /metrics?format=prometheus gains request counters and histograms, engine
  lost/attached counters, uptime and supervisor restarts, PCIe, memory clock, throttle reasons, speculative tokens per round, expert-tier
  entries by tier and hit ratio.
* engine: one structured line per request with the same id (rounds, tokens per round, expert-tier share served from VRAM/PCIe/CPU for that
  request); telemetry gains spec / expert_tier / last_request; NVML sampler reads PCIe throughput, memory clock, throttle reasons.
* supervisor: structured events (engine exit, health, restarts), secrets registered with the log layer, children get LELEKA_REQUEST_LOG,
  LELEKA_STATUS_FILE, LELEKA_PROFILE and JSON logging; runtime-client and gateway log connect/probe failures as sampled events.
* leleka logs (--tail/--since/--level/--component/--source/--request/--follow), leleka report (sanitized support bundle, written only with
  --yes, nothing sent anywhere), request statistics in leleka status / verify --quick.
* generation, sampling and kernels are untouched; the lab scripts keep their plain lines (LELEKA_LOG_FORMAT=legacy or a hand-started binary).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-02 23:25:24 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 7c779d279c License: MIT (LICENSE file; workspace, quant-core, strata-control, strata-desktop-core)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-02 21:29:43 +01:00
Pavlo RatushnyiandClaude Sonnet 5.5 22bb8366f9 build: opt-in release-lto profile for paired A/B builds (not the default, unmeasured)
The workspace has no [profile] section; shipped binaries are the cargo release default (no LTO, 16 codegen units).
release-lto adds fat LTO and one codegen unit and nothing else. No target-cpu: the CPU kernels pick GGML arithmetic
branches with cfg!(target_feature), so target-cpu would change bits. See docs/experiments/parity-audit-5090.md.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 01:37:40 +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 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 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 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 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 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 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 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 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 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 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 e69c3e66d4 refactor: move pure rope/plan/policy modules into leleka-context, add cell geometry
The source-port runtime no longer builds on macOS, so the pure arithmetic and its
golden tests live in a platform-independent crate shared by the driver and runtime.
leleka_runtime::{rope_scaling,memory_plan,context_policy} stay as re-exports.
geometry.rs derives every frozen 262144-cell byte literal from the cell count.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 14:50:09 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 45bad22b88 feat(sampler-ref): CPU reference of the Original sampler chain with host-oracle fixtures
New pure-Rust crate leleka-sampler-ref: Philox draw, penalties -> top_k ->
top_p -> min_p -> temperature -> inverse-CDF pick, greedy argmax, coupled-draft
counter/ring math, penalty_rows, exact-match acceptance, and the request-level
SamplingParams validation with the Original's GEN defaults and wire keys.

Golden fixtures come from compiling the Original's sampler_parity.cpp host
reference (included unmodified) and sampler/coupled_draft headers with clang++
(-ffp-contract=off), plus the verbatim StrataEngine.sampling_keys lifted from
server.py. No GPU, no speed or quality claim.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 14:42:51 +02:00
Pavlo RatushnyiandClaude Sonnet 5.5 7f896a8bb8 import: Original-literal source-port snapshot (frozen 2026-10-12 06:36, uncompiled together, no GPU run)
Snapshot of target/stra169-direct-port-integration/source-port (without target/), now the tracked base for the full Strata Rust port.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-14 14:38:46 +02:00
Pavlo Ratushnyi 44374a269a STRA-175: register private runtime workspace bootstrap
Register the dependency-free runtime package and its private physical module map in the existing workspace. This phase intentionally references the contract and leaf shells delivered by the sequential phase B and makes no standalone build or model readiness claim.
2026-10-09 14:39:45 +02:00
Pavlo Ratushnyi 7e61ab8007 STRA-102 implement independent CUDA Driver context and buffers
Linux / keyless-cuda-gate (pull_request) Skipped
Linux / verify (pull_request) Failing after 42s
Linux / keyless-cuda (pull_request) Skipped
Linux / static-cuda-package (pull_request) Skipped
Linux / hosted-cuda-package (pull_request) Skipped
Linux / linux-static-cli (pull_request) Skipped
Linux / linux-cli-container (pull_request) Skipped
Linux / release-cli (pull_request) Skipped
2026-10-07 23:09:48 +02:00
Pavlo Ratushnyi a498381cb7 refactor(model): extract independent Rust IQ3 decoding core
Linux / keyless-cuda (pull_request) Skipped
Linux / static-cuda-package (pull_request) Skipped
Linux / hosted-cuda-package (pull_request) Skipped
Linux / keyless-cuda-gate (pull_request) Skipped
Linux / verify (pull_request) Successful in 5m16s
Linux / linux-cli-container (pull_request) Successful in 5m19s
Linux / release-cli (pull_request) Skipped
Linux / linux-static-cli (pull_request) Failing after 7m35s
2026-10-07 20:53:25 +02:00
Pavlo Ratushnyi c6a3fc7e42 feat(engine): extract Rust GGUF foundation and enforce model capability tuples 2026-10-07 20:33:15 +02:00
Pavlo Ratushnyi fef5fca6fd refactor: extract Qwen tokenizer into Leleka crate
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:24:43 +02:00
Pavlo Ratushnyi 4013e0c9bd Import tracked Strata Next source snapshot
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
Desktop foundation / core (ubuntu-latest) (push) Failing after 28s
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
Pavlo Ratushnyi 1e98febce6 feat: add versioned inference backend contract 2026-10-05 18:04:20 +02:00