From ff1ad3aea1452cc07bb785ef2aedff270ad4f318 Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Tue, 3 Nov 2026 22:31:10 +0100 Subject: [PATCH] release 5090 v0.1 phase B: README, short release notes, profile/deploy text fixes, packager for the merged state Co-Authored-By: Claude Sonnet 5.5 --- README.md | 96 +- deploy/rust-runtime/profiles/rtx5090-32g.json | 2 +- docs/deploy.md | 854 +++++++++--------- docs/release/RELEASE-NOTES-5090-v0.1.md | 163 +--- docs/release/third-party-crates-5090-v0.1.tsv | 6 +- scripts/release/package-5090.sh | 19 +- 6 files changed, 543 insertions(+), 597 deletions(-) diff --git a/README.md b/README.md index 7fe7af1f..c3f2c9b5 100644 --- a/README.md +++ b/README.md @@ -1,44 +1,54 @@ -# Leleka / Strata Next +# Leleka -Leleka is the independent Rust NVIDIA inference runtime being developed from -this repository. The complete tracked Strata Next source tree was imported from -`paveldhq/strata-next` commit -`1263e88f8947b9796924eb7e8d8d7af08b589049`; see `docs/upstream.md` for the -pinned Strata engine provenance. The imported desktop application, Rust control -plane, deployment code, model tooling, tests, and reference engine are all here. +Leleka is a Rust/CUDA inference runtime for coding agents. Release **0.1** serves one model, **Qwen3.8-Flash-Next IQ3_S** (KAR level-2 PLE, MTP speculative +decode), on **one RTX 5090 (32 GB)** at **262,144 tokens of context**, to Codex CLI and other clients over the Responses, Chat Completions and Messages APIs. +It is a Rust/CUDA port of the Original mode17 serve path of [Strata](https://github.com/Niko1221/Strata) (reference copy in `engine/strata/`, pinned at +upstream `41cf05a0`, see `docs/upstream.md`). Serving needs no Python and no CUDA toolkit on the host. -The migration is staged: Leleka must eventually run without a Strata process, -Strata source, Python, or a separately installed CUDA Toolkit on the target -host. Until the replacement passes the same protocol, model-quality, and -operational gates, Strata remains the behavior baseline. No model family or -performance gain is claimed for Leleka until its real-model gates pass. +**Status of 0.1.** It runs real Codex sessions to completion and decodes about 155 tok/s on the 245k-token benchmark of the 5090 server (section "Numbers"). +It is **not a formally quality-gated profile**, only the RTX 5090 is supported, and the limits below are real. Release notes: `docs/release/RELEASE-NOTES-5090-v0.1.md`; +every gate and its evidence: `docs/release/5090-v0.1-checklist.md`. -## Repository layout +## Requirements -- `crates/backend-api/` — Leleka's versioned Rust backend contract. -- `crates/tokenizer/` — the Qwen35 byte-level BPE tokenizer extracted as a - backend-independent Rust crate. -- `desktop/`, `desktop-core/` — current desktop application and its Rust core. -- `control-plane/` — current Rust API, Responses handling, and worker supervisor. -- `engine/strata/` — pinned upstream Strata reference; retained during migration. -- `gpu/` — experimental optimization components, including KAR. -- `integrations/`, `manifests/`, `deploy/`, `scripts/` — client integration, - model profiles, packaging, and development/test tooling. -- `PROJECT_CHARTER.md`, `docs/` — requirements, provenance, decisions, and - performance/quality gates. +| | | +| --- | --- | +| GPU | RTX 5090 (sm_120, 32 GB), driver >= 595 (measured with 595.99.02). Any other GPU: not supported in 0.1 (an RTX 3080 laptop profile exists, experimental, not run for this release) | +| host | Linux x86_64, glibc >= 2.39 (measured: Ubuntu 26.04), >= 100 GiB RAM, a fast local NVMe, about 140 GB for the model volume | +| libraries | `libcuda.so.1` (driver) and `libcublas.so.12` (CUDA 12; `leleka up` fetches the pinned 12.9.1.4 redistributable if missing) | +| model | Qwen3.8-Flash-Next IQ3_S + KAR archive + MTP pack, digests pinned in the binary (`leleka verify`). **Obtaining and using the model under its own licence is the user's responsibility.** | -Model weights, request captures, credentials, local logs, and generated build -artifacts remain outside Git or under ignored paths. +## Install and run -## Current Leleka scope +From the unpacked release (`leleka-0.1.0-COMMIT12-5090-linux-x86_64.tar.xz`; check `SHA256SUMS`, `./bin/leleka version` shows the commit and the Strata pin): -Leleka currently has a versioned backend contract and a standalone Qwen35 BPE -tokenizer crate. The existing Rust control plane now consumes that shared -tokenizer crate instead of maintaining a second copy; its oracle-parity tests -remain in the workspace. Leleka still has no independent inference backend or -CUDA integration, so this does not yet serve a model independently. The -desktop app and the rest of the control plane remain available as migration -source in this repository. +```sh +./bin/leleka up --dry-run --assets /data/leleka # preflight + plan + the exact engine command; changes nothing +sudo ./install.sh --assets /data/leleka # prepare, install, start the systemd service, wait for /ready (or --foreground) +./bin/leleka status # ready?, uptime, restarts, GPU/RAM/throughput, expert tier ON/OFF +curl -H "Authorization: Bearer $(cat STATE/api-key)" http://127.0.0.1:8081/v1/models +``` + +The API listens on loopback only (use an SSH tunnel); the key is in `STATE/api-key`. Codex CLI: `wire_api = "responses"`, `base_url = "http://127.0.0.1:8081/v1"`, `web_search = "disabled"`. +Details, every flag, upgrade and rollback: `docs/deploy.md`, `docs/unattended.md` (running it as a boot-time service: `scripts/ops/`, installed by the owner of the machine, never by the release). +Upgrade: stop the service, keep a copy of `STATE/*.json`, unpack the new release, run its `install.sh` with the same flags. Rollback: restore the copies and run the previous release's `install.sh`. + +## Numbers (measured, paired, one workload) + +Decode tok/s on the frozen 245k-token corpus (5 turns x 300 output tokens, greedy, RTX 5090, Ryzen 9 9950X3D), ours against vanilla Strata 0.2.6 on fresh boots, vanilla in its good +huge-page state (`docs/experiments/baseline-pair-5090.md`, section 10, 3 balanced blocks): **ours 155.4** (sd 2.4), vanilla v1 (its shipped lossy defaults) 137.0 (ahead of it in 3 of 3 blocks, +13.5 %), +vanilla v2 (lossless-comparable) 144.7 (ahead in **2 of 3** blocks, +9.2 %; vanilla v2 is bimodal and ran 171.2 once, 10.8 % faster than ours). Later changes: the faster draft attention is bitwise identical and +shortens a round by 2.7 % (tok/s +0.5 % +- 0.6 %, not significant); the window policy default +1.1 % +- 1.2 % (not resolved, no speedup claimed); the single-copy memory layout +(`docs/kar-sparse-memfd.md`) is identical in output (2057/2057 logprob rows, 1036/1036 draft traces) and frees 36.6 GiB of RAM at 245k (MemAvailable 8.5 to 45.1 GiB; tok/s +0.58 %, n.s.). +These are decode speeds of a benchmark, not agent-task times. + +## Quality and limits + +* Not bit-identical to the Original; deviations are inside the Original's own rounding envelope where tested (`docs/quality-gate.md`), and **there is no 245k port-versus-Original equality gate yet** (STRA-337). + KAR level-2 PLE, chain kernels, prefill chunk 8192, request-end prefix checkpoints and the adaptive expert tier have no 256k gate. All evidence is greedy. +* Lossy modes are **off**: route tail skip gave +15 % decode but failed its quality gate; keyless KV failed too. Tool calls are the model's: malformed ones are refused, not repaired. +* One generation at a time (queue of 16); images and `reasoning_budget_tokens` are refused; RTX 3080 and Windows are not part of 0.1; no multi-hour soak on the release commit (post-release feedback). +* Cold start is dominated by reading the 55 GB archive from disk; with the O_DIRECT loader and the sparse copy the measured times are in the release notes. ## Observability @@ -62,14 +72,24 @@ What the service is doing, and why a request was slow or failed, is in its logs; tokens, tok/s), engine restarts and uptime, queue depth, VRAM and host memory, GPU clocks / temperature / power / throttle reasons, PCIe MB/s, speculative tokens per round, expert-tier entries by tier. Every label value comes from a fixed list. -## Development +## Repository layout -Run the Rust workspace tests and lint: +- `crates/` — the runtime: `leleka-runtime` (engine), `cuda-driver` (CUDA Driver API, sealed PTX), `leleka-memory` (memory governor), `obs` (logging), `deploy` (the `leleka` binary), model-format, tokenizer, sampler and CPU kernels. +- `control-plane/`, `desktop-core/` — the HTTP/Responses gateway (`strata-next`) and the engine/daemon processes. +- `engine/strata/` — the pinned upstream Strata, the reference (unmodified by Leleka). +- `deploy/`, `scripts/` — profiles, service templates, release packager (`scripts/release/`), test and measurement tooling (Python is allowed there, never in serving). +- `PROJECT_CHARTER.md`, `docs/` — requirements, provenance, decisions, gates and measurements. + +Model weights, request captures, credentials, logs and generated artifacts stay outside Git. + +## Development ```sh cargo test --workspace --locked cargo clippy --workspace --all-targets --all-features -- -D warnings +scripts/release/package-5090.sh check # the release gates; `package` builds the release set (docs/release/5090-v0.1-checklist.md) ``` -For the Linux release requirements, see [PROJECT_CHARTER.md](PROJECT_CHARTER.md) -and [the independent engine design](docs/architecture/independent-nvidia-engine.md). +## Licence + +MIT (`LICENSE`). A commercial licence is available on request. Third-party notices: `docs/release/licence-and-secrets-audit-5090-v0.1.md`; the Strata reference is MIT (`engine/strata/LICENSE`). diff --git a/deploy/rust-runtime/profiles/rtx5090-32g.json b/deploy/rust-runtime/profiles/rtx5090-32g.json index 966e938a..b4501296 100644 --- a/deploy/rust-runtime/profiles/rtx5090-32g.json +++ b/deploy/rust-runtime/profiles/rtx5090-32g.json @@ -1,6 +1,6 @@ { "name": "rtx5090-32g", - "description": "RTX 5090 class server (sm_120, 32 GB VRAM, >= 100 GiB RAM). Single copy of every model byte in host RAM: the 50 GB routed-expert bank is the one page-locked RAM copy (from GGUF shard 0), and of the 55 GB level-2 KAR archive only the 16.0 GB the serve path reads (the PLE rows, 2 extents) is copied once into a sealed sparse memfd (memfd_extents ple_only: holes elsewhere, verified against the pinned digest of the extents), read O_DIRECT so no page-cache copy remains. Reference-equivalent agent configuration (docs/e2e-run.md 7d; GPU budget 32,819,404,800 B (31,299 MiB) since the dense-slab commits, was 30 GiB: the slab saves physical bytes the Context never counted, so the budget must rise by about that much for the slot gain to appear, docs/experiments/vram-footprint-5090.md; expert tier auto-sized per layer from data/expert-profile.bin, adaptive speculative window with spec-min-p 0, MTP draft vocabulary, prefix cache 6144 MiB (explicit cap: what `auto` resolves to on this host, 5.7-6.1 GiB; unlike `auto` it cannot grow when RAM is freed) with request-end checkpoints (reply), chain kernels): weighted decode 129-130 tok/s in the reference-equivalent real Codex sessions on the 5090, +5 % from the adaptive window in the CRM replay. Prompt chunk and prefix-cache grid 8192 (paired 256k session on the 5090: TTFT sum 131 s at 2048 against 55-60 s at 8192, docs/upstream-port-plan.md). Prompt-routing seed OFF (engine_env LELEKA_ORIGINAL_SERVE_SEED=off, placement class, owner to confirm; docs/experiments/decode-tail-5090.md: +27 % decode at 45k-247k prompts). MTP draft attention = upstream pre75 chunk + merge v2 (engine_env LELEKA_SM120_ATTN_DAILY_MTP=1, bitwise identical on the replay gate, draft round 0.29 ms and whole round 0.37 ms shorter at 245k, docs/experiments/draft-round-5090.md). Not a formally quality-gated profile.", + "description": "RTX 5090 class server (sm_120, 32 GB VRAM, >= 100 GiB RAM). Single copy of every model byte in host RAM: the 50 GB routed-expert bank is the one page-locked RAM copy (from GGUF shard 0), and of the 55 GB level-2 KAR archive only the 16.0 GB the serve path reads (the PLE rows, 2 extents) is copied once into a sealed sparse memfd (memfd_extents ple_only: holes elsewhere, verified against the pinned digest of the extents), read O_DIRECT so no page-cache copy remains. Reference-equivalent agent configuration (docs/e2e-run.md 7d; GPU budget 32,819,404,800 B (31,299 MiB) since the dense-slab commits, was 30 GiB: the slab saves physical bytes the Context never counted, so the budget must rise by about that much for the slot gain to appear, docs/experiments/vram-footprint-5090.md; expert tier auto-sized per layer from data/expert-profile.bin, adaptive speculative window with spec-min-p 0, MTP draft vocabulary, prefix cache 6144 MiB (explicit cap: what `auto` resolves to on this host, 5.7-6.1 GiB; unlike `auto` it cannot grow when RAM is freed) with request-end checkpoints (reply), chain kernels): no speed claim is made in this text (the paired 245k series against vanilla Strata is docs/experiments/baseline-pair-5090.md). Prompt chunk and prefix-cache grid 8192 (paired 256k session on the 5090: TTFT sum 131 s at 2048 against 55-60 s at 8192, docs/upstream-port-plan.md). Prompt-routing seed OFF (engine_env LELEKA_ORIGINAL_SERVE_SEED=off, placement class, owner to confirm; docs/experiments/decode-tail-5090.md: +27 % decode at 45k-247k prompts). MTP draft attention = upstream pre75 chunk + merge v2 (engine_env LELEKA_SM120_ATTN_DAILY_MTP=1, bitwise identical on the replay gate, draft round 0.29 ms and whole round 0.37 ms shorter at 245k, docs/experiments/draft-round-5090.md). Not a formally quality-gated profile.", "select": {"sm_min": 120, "sm_max": 130, "vram_mib_min": 30000, "vram_mib_max": 1000000}, "gpu_budget_bytes": 32819404800, "spec_min_p": 0.0, diff --git a/docs/deploy.md b/docs/deploy.md index c326ef74..fa6a3082 100644 --- a/docs/deploy.md +++ b/docs/deploy.md @@ -1,427 +1,427 @@ -# One-command deployment: `leleka up` - -**Windows 11:** `leleka.exe` (WSL2 bridge and native engine) is described in [`windows.md`](windows.md). - -Status 2026-10-17, branch `claude/deploy` (base `claude/port-gpu-bringup` @ `5e0bd84`). This page describes the deployment -tool `leleka` (crate `crates/deploy`, no Python at run time), what it does, every flag, and what was and was not run to -check it. Results are in [section 10](#10-what-was-run-and-what-was-not); nothing here is a performance or model-quality -claim. Background: [`rust-runtime-run.md`](rust-runtime-run.md) (the processes), [`model-assets.md`](model-assets.md) (the model -commands `leleka` drives), [`laptop-profile.md`](laptop-profile.md), [`sm86-assets.md`](sm86-assets.md), -[`delivery-gap-audit.md`](delivery-gap-audit.md) section 5 (the packaging gaps this closes in part). - -## 1. Quickstart - -Server (Linux x86_64, NVIDIA driver >= 595, systemd), as root, from the unpacked release: - -```sh -tar -xJf leleka-VERSION-linux-x86_64.tar.xz && cd leleka-VERSION-linux-x86_64 -sudo ./install.sh --assets /data/leleka # preflight, fetch+verify, KAR archive, install, start, wait for ready -``` - -WSL2 laptop (RTX 3080 16 GB), as your user, in a terminal (WSL2 usually has no systemd): - -```sh -./install.sh --assets ~/leleka --foreground # keep the terminal open; Ctrl-C drains and stops -``` - -Both do the same thing, idempotently, and print the endpoint, model digest, GPU, the VRAM/RAM budget that was chosen, and the -log directory when the service answers `/ready`. Look first with `--dry-run`: it prints the preflight and the plan and changes nothing. - -```sh -./bin/leleka up --dry-run --assets /data/leleka -``` - -This is charter goal G2 (`PROJECT_CHARTER.md` section 6): one command, GPU and memory plan chosen automatically, external model volume, readiness only after the model is loaded, orderly stop and restart of the worker, no Python at run time. -Its acceptance test (a clean Linux GPU node, driver installed, one command, no re-download after a restart) has **not** been run; section 10 lists what was. - -Container: [section 7](#7-container-image). Build your own release: [section 8](#8-build-a-release-tarball). - -## 2. What `up` does - -| # | step | what happens | idempotency | -| --- | --- | --- | --- | -| 1 | preflight | driver >= 595, GPU architecture, VRAM free vs budget, RAM total/available, disk on each volume, WSL2 mounts, `libcublas.so.12`, `memfd_create`, ports, systemd, the six binaries | read-only; any FAIL stops before anything is changed | -| 2 | layout | state (0700), logs, run, stamps, assets | `mkdir -p` | -| 3 | binaries | copy `bin/*` to `PREFIX/bin`, SHA-256 checked against `MANIFEST.json` | skipped when identical; replaced by rename (safe for a running binary) | -| 3b | expert profile | the ranked VRAM expert tier's table `ASSETS/data/expert-profile.bin` (192 KiB, upstream Strata at the pinned commit): the upstream bytes are embedded in the `leleka` binary (`crates/deploy/data/expert-profile.bin`, MIT notice beside it) and written there on first start, so no network is needed; `--expert-profile-file PATH` installs your copy instead, and an https download from the pinned commit is only the fallback; SHA-256 `8f59b4aa...388975baf` is checked, the file is installed by rename, any other digest fails closed (a wrong file already there is moved aside, never deleted); `--no-expert-tier` is the explicit opt-out. Planned before the large downloads. `status`, `verify`, the ready summary and the supervisor log say `expert tier ON (sha256 ...)` or `WARNING expert tier OFF: reason` | skipped when the file has the pinned digest | -| 4 | cuBLAS 12 | uses what the host has; otherwise downloads the pinned NVIDIA 12.9.1.4 redistributable (SHA-256 pinned, resumable) into `PREFIX/lib/cublas` | skipped when `libcublas.so.12` and `libcublasLt.so.12` are found | -| 5 | secrets | two service tokens into `STATE/runtime.env` (0600), API key through `strata-next api-key init` | never rotated; only missing/invalid ones are created | -| 6 | model | `strata-next model fetch qwen-iq3-s` then `model verify` (resumable `.part` files, SHA-256) | stamped with size+mtime: skipped on re-runs unless `--reverify` | -| 7 | KAR archive | `strata-next model ensure-sharded-streamed qwen-iq3-s --levels 2` (level 2, the pinned 55,295,529,472-byte archive + provenance) | stamped; also checks the length the engine admits | -| 8 | MTP pack | `ASSETS/data/mtp-rt` must exist; `--mtp-pack` imports it from a directory or tarball | skipped when present | -| 9 | tokenizer | `model extract-tokenizer` from shard 1 | skipped when present | -| 10 | config | `leleka.json`, `daemon.json`, `strata.json`, `profile.json`, `runtime.env` | rewritten only when the content changes | -| 11 | service | systemd unit (system or user), `daemon-reload`, `enable`; none in foreground mode | rewritten only when the content changes; a changed unit restarts a running service | -| 12 | start / ready | start the unit (or run the supervisor in this terminal), poll `/ready` with the key, print the summary | an already ready service is left alone | - -The archive step runs `ensure-sharded-streamed`, which fetches and verifies the shards itself, so on a first run step 6 is folded into -step 7 (the plan says so). The strict verification of an *existing* archive re-derives the 708 GB virtual F32 stream and is slow; a -machine that already holds the archive can pass `--trust-archive`: the archive is accepted when it has the pinned length and a -provenance file, and the engine checks its SHA-256 and every CRC against the pinned digest at each load anyway. - -A failed run is resumable: fix the cause and run the same command; finished steps are skipped (downloads continue from `.part`). - -## 3. The processes and files - -```text -leleka run (supervisor, the systemd ExecStart or your terminal) - |- seals the KAR archive into a memfd ONCE (memfd profile) -- or hands the engine a read-only file (file profile) - |- leleka-daemon gateway for the typed lifecycle, 127.0.0.1:18080 - |- leleka-inference engine, gRPC 127.0.0.1:18766 (started through `leleka exec-inherit`, which passes the sealed fd) - |- leleka-cli load-mtp qwen-iq3 qwen4exp-kar-ple-mtp-v1 -> wait for model_ready (the engine verifies shards + archive here) - `- strata-next serve public API (Responses, Chat, Messages, tools, ...), 127.0.0.1:8081, bearer key -``` - -```text -PREFIX/bin/{leleka,strata-next,leleka-inference,leleka-daemon,leleka-cli,leleka-seal-exec} PREFIX/lib/cublas/ -STATE/{leleka.json,daemon.json,strata.json,profile.json,runtime.env,api-key} STATE/{logs,run/status.json,stamps,mtp-staging} -ASSETS/model/*.gguf ASSETS/qwen-iq3-s-l2-v4.kar(.provenance.json) ASSETS/data/mtp-rt/ ASSETS/tokenizer-assets/ -``` - -Defaults: root gets `/opt/leleka`, `/var/lib/leleka/state`, `/var/lib/leleka/assets`; a user gets `~/.local/share/leleka`, -`~/.local/state/leleka`, `~/.local/share/leleka/assets`. Environment: `LELEKA_PREFIX`, `LELEKA_STATE`, `LELEKA_ASSETS`. -**Put `--assets` on the big volume**: about 140 GB (shards 83.6 GB + archive 55.3 GB); the first run needs that plus slack. - -### The sealed KAR archive is made by the service - -The engine accepts the archive only as a sealed memfd (regular, unlinked, pinned length, `WRITE|GROW|SHRINK|SEAL`). Until now an operator -tool (`kar_holder.py` / `seal_exec.py`, outside the repository) did that. `leleka run` now does it natively: it copies the archive into a -sealed memfd once (the whole 55 GB, or for `rtx5090-32g` only the 16.0 GB extents the serve path reads; large O_DIRECT blocks on many threads, so the copy leaves nothing in the page cache), keeps the descriptor close-on-exec in the supervisor, and hands a duplicate -to each engine start through `leleka exec-inherit` (standard input in, a descriptor number >= 3 out). An engine restart therefore does -**not** copy 55 GB again, and the API, the gateway and the CLI never see the descriptor. `leleka-seal-exec` still ships for manual runs. -`--kar-fd N` (on `up` and `run`) reuses a descriptor inherited from a parent that already holds one (a holder, a test harness): no second copy, and its RAM is not demanded. - -The **file profile** (laptop) cannot afford 55 GB of shmem. `leleka-inference` gained `--kar-archive-file PATH --kar-provenance PATH` -(`InheritedKarArchive::open_read_only_file`, the form `docs/laptop-profile.md` measured in a bench): the archive stays an ordinary file; -it must be regular, single-link, owned by the service user and without write bits (`up` sets mode 0400). It is weaker than the seal (immutability rests on -the file system) and is selected only by that profile. The full SHA-256 and all CRCs are still checked at load. - -## 4. Memory profiles - -`--profile auto` (default) picks by the GPU `nvidia-smi` reports; `--profile NAME` or `--profile FILE.json` overrides it, and -`--gpu-budget-gib` / `--context-tokens` override single values. `leleka profiles` lists them, `leleka profiles show NAME` prints one to copy and edit. -The files live in [`deploy/rust-runtime/profiles/`](../deploy/rust-runtime/profiles/) and are embedded in the binary. - -| profile | selected for | GPU budget | context | KAR archive | routed experts | RAM floor (total / available at start) | other | -| --- | --- | --- | --- | --- | --- | --- | --- | -| `rtx5090-32g` | sm_12x, >= 30 GB VRAM | 32,819,404,800 B = 31,299 MiB (needs that much free at start: 31,299 of the 32,110 MiB an idle card reports; was 30 GiB, see [vram-footprint-5090](experiments/vram-footprint-5090.md)) | 262,144 | sealed **sparse** memfd (`memfd_extents: ple_only`): only the 16.0 GB of the archive the serve path reads (the PLE rows, 2 extents), holes elsewhere; read O_DIRECT, so no page-cache copy | `resident`: page-locked RAM copy (50.3 GB) | 100 GiB / 74 GB (113 GB for `memfd_extents: full`; 58 GB when `--kar-fd` supplies the archive) | one resident copy of every model byte in host RAM (`kar-sparse-memfd.md`) | -| `rtx3080-16g` | sm_80..119, 14-24 GB VRAM | 15 GiB (needs 14,500 MiB free) | 8,192 | read-only file | `mapped`: read-only mappings of shard 0 | 22 GiB / 10 GiB; advice `.wslconfig memory=32GB` | VRAM expert tier: `up` fetches `ASSETS/data/expert-profile.bin` (pinned SHA-256 `8f59b4aa...388975baf`; `--no-expert-tier` to run without) | -| `rtx5090-32g-file` (experimental, never auto-selected: `--profile rtx5090-32g-file`) | none (explicit name only) | as `rtx5090-32g` | 262,144 | read-only file (`kar_source: file`; no memfd, no holder; start reads about 1 MB of it when its verification stamp is current) | `resident` | 64 GiB / 62 GB (the 55 GB archive is page cache, not a charge) | as `rtx5090-32g` except an explicit `prefix_cache_mib` 6144; [`kar-file-source.md`](kar-file-source.md): what the file form reads, its integrity guarantees, the A/B (`scripts/e2e/decode/kar-file-ab.sh`, not run) | - -Both profiles also carry a `memory` section (prefix cache `auto`, soft/hard floors 4096/2048 MiB, reserve, lock and heal of the sealed memfd): the engine sizes its caches from the memory left after the fixed footprint, sheds and refuses under pressure, and refuses to start with numbers when the footprint does not fit ([`memory-safety.md`](memory-safety.md)). The unit sets `LimitMEMLOCK=infinity`, which is what lets the lock keep the 55 GB memfd out of swap. - -Both profiles run `--backend-mode original` and the level-2 archive; the routed-expert bank must be admitted before the Original stack opens, which `leleka-inference` now does from `--expert-source resident|mapped` (see section 10, finding 1). They select documented switches only (budget, context, archive form, the -`LELEKA_ORIGINAL_SERVE_*` environment); they are **not** tuned, not quality-gated and carry no speed claim. A GPU that fits neither -(a 24 GB 4090, say) gets an error that names the way out: write a profile file. Fields: see `crates/deploy/src/profile.rs` -(`gpu_budget_bytes`, `context_tokens`, `prefill_capacity`, `kv`, `kv_resident`, `prompt_cache`, `kar_source`, `min_*`, `engine_env` -restricted to `LELEKA_ORIGINAL_SERVE_*`); unknown fields are refused. - -One binary serves both architectures: the sealed sm_120 PTX is used as is on Blackwell, and the build with `--features sm86` -(every release) swaps in the sm_86 companion PTX on 8.6 <= cc < 12.0 cards ([`sm86-assets.md`](sm86-assets.md)). Preflight reads `MANIFEST.json` and refuses a -binary built without `sm86` on such a card. All PTX is embedded in the binaries (the release also ships the files and a `SHA256SUMS` for audit). - -## 4b. Resource presets - -`leleka up` computes what the runtime takes of the host (`crates/deploy/src/resources.rs`, a pure function of the probed host facts and the profile), prints it, and bakes it into `leleka.json` (the profile's budget and floors, and `LELEKA_ORIGINAL_SERVE_CPU_WORKERS`). Two presets: - -| | `dedicated` (default) | `workstation` | -| --- | --- | --- | -| purpose | the host belongs to the runtime | Docker, agents and the IDE share the machine | -| CPU expert workers | `min(cores - 2, 15)` | `min(cores - leave, 15)`, leave 4 cores (8 above 16 cores) | -| host RAM kept free | the profile's governor floors (server: soft 4 GiB, hard 2 GiB) | soft floor 8 / 12 / 16 GiB (hosts under 32 / under 64 / from 64 GiB RAM), hard floor half of it; the profile's floors are only raised. The governor sheds the prefix cache first, then refuses new requests with 503 `memory_pressure` | -| VRAM | the profile budget | `min(profile, free - 2 GiB)` rounded down to GiB; the expert tier is sized from what remains | - -The native expert pool takes at most 15 workers. **Measured cost of the preset on the 5090** (job 9p0, tic-tac-toe replay, 16 requests, 2 repeats, fixed window): default (30 GiB, 15 workers) 139.8 tok/s; 8 workers alone 136.4 (-2.4 %); 8 workers and a 27 GiB budget 119.6 (-14.5 %). **Host RAM of the server profile (live check plat-reconf-live):** the 121 GiB server holds the 51.5 GiB sealed archive and an engine with a fixed footprint of 53.5 GiB (the page-locked copy of the routed experts and the pools), which leaves 12-13 GiB available while it runs. The `workstation` preset asks the governor for 16 GiB plus its 2 GiB reserve, so on that host it is not reachable in the resident form: the planner now says so (and `leleka up` falls back to the mapped form, `leleka reconfigure --preset workstation` refuses and points to `leleka up`). A host with 192 GiB or more has room for it. The VRAM taken from the expert tier is what costs (about 4 % per GiB), so the workstation margin is 2 GiB, not more, and the workers are capped at 15 rather than 8. If the workstation target cannot be met (less than half of the profile's VRAM budget would remain) the preflight fails with the numbers; a RAM shortfall does not fail: when the pinned form (sealed archive plus engine, about 58 GiB on the server) would leave less than the free target, `up` switches the profile to the mapped form of the laptop profile: the archive stays a read-only file and the experts are memory-mapped from SSD/HDD, with `available - target - 8 GiB` of experts page-locked (`resident_budget_gib`, 0 on a small host). It prints a warning, because decode is slower than with everything in RAM. The same fallback applies to `dedicated` when the host cannot hold the pinned form at all. `--gpu-budget-gib` and explicit profile fields win over the preset. - -## 4c. What the runtime reports (`leleka status`) - -The engine samples itself once a second and records every request (`crates/leleka-memory/src/telemetry.rs`). The document travels -gRPC `Snapshot.telemetry_json` -> the gateway -> `GET /v1/status` `machine` -> `leleka status` (also `--json`): - -| block | figures | -| --- | --- | -| `gpu` | utilisation %, memory-bus %, VRAM used/total, power, SM clock, temperature, board name (NVML, loaded with `dlopen`; where `libnvidia-ml` cannot be loaded, WSL2 and containers, the engine polls `nvidia-smi` instead, at most every 2 s; absent when neither exists) | -| `ram` | host total/available, engine resident and pinned, swap in use | -| `cpu` | engine CPU in busy cores (of the cores this process may use), whole-system busy % | -| `throughput` | prefill tok/s (last request, running average, lifetime) and decode tok/s (same, plus the live rate of the request in flight) | -| `cache` | requests and how many reused a checkpoint, prompt tokens reused of all, the last request's reused/prompt tokens | -| `context` | tokens live in the session, the configured maximum, percent used; `phase` idle/prefill/decode; `request` (prompt and generated tokens, seconds) while one runs | - -Prefill rate counts the tokens actually prefilled (prompt minus reused). Rates are `null` until a request has been measured. - -## 4d. Changing the runtime settings (`leleka reconfigure`) - -The engine can be re-initialised while it runs: it closes its serve stack and opens a new one with other settings, **without reloading the -weights, the CUDA context or the sealed archive** (**7 s** on the 5090 instead of the 3-5 minute start, live job 9r1). The call waits for the request in flight; requests that arrive meanwhile wait in the -gateway queue. If the new stack cannot open (for example the VRAM -does not hold a larger context) the previous settings are reopened and the call answers `reconfigure refused: ...; the previous settings are back`. - -```sh -leleka reconfigure --context-tokens 131072 --prefix-cache-mib 20480 --prefix-cache-tail reply --cpu-workers 8 -leleka status # prints "settings in force" with the engine telemetry -``` - -| setting | meaning | note | -| --- | --- | --- | -| `--context-tokens N` | context length (prompt plus output of one request) | 1..262144; bounded by the VRAM left for the K/V window | -| `--prefill-capacity N` | prefill chunk (256 ... 8192) | 8192 prefills a cold 100k prompt about twice as fast as 2048; takes VRAM from the expert cache. The `rtx5090-32g` profile ships 8192 (with `--prefix-cache-block 8192`): 256k session TTFT sum 131 s at 2048 against 55-60 s | -| `--kv-resident N` | K/V cells per layer kept in VRAM | fixed for the life of the process: only the value in force is accepted (a different one needs a restart; 9r1 showed the engine refuses it) | -| `--prefix-cache-mib auto\|off\|N` | host-RAM budget of the cross-session prefix cache | `off` drops the cache | -| `--prefix-cache-tail off\|prompt\|reply` | request-end checkpoints | `docs/prefix-cache.md` | -| `--prefix-cache-block N`, `--prefix-retention-min N` | block / grid size, minutes an idle session is kept | | -| `--cpu-workers N` | CPU expert workers (1..=15, the native pool's limit; the engine default is 15) | the resources the engine takes on the host | -| `--spec-min-p P` | draft-probability floor | | - -The same call is `POST /v1/reconfigure` with the JSON document (`{"context_tokens": 131072, ...}`; same bearer key; the answer carries the -effective settings) and gRPC `Runtime.Reconfigure`. The prefix cache is rebuilt empty (its host images belong to the old stack), so the -next request of every session reads its prompt again once. - -**Keeping a change (`--persist`).** Without it a change lasts until the service restarts. With `--persist` the supervisor also writes the -result into `STATE/leleka.json` (profile fields: `context_tokens`, `prefill_capacity`, `kv_resident`, `spec_min_p`, -`memory.prefix_cache_{mib,tail,block}`, `memory.prefix_retention_min`, and `engine_env.LELEKA_ORIGINAL_SERVE_CPU_WORKERS` for the workers) and -regenerates `strata.json`, so a restart of the service, and a restart of a crashed engine, start with the new numbers. The file written is the -configuration in force, so a change made earlier without `--persist` in the same service life is written with it. With no supervisor running -the file is edited directly. - -**Budget and preset: restart in place.** The VRAM budget and the resource preset are fixed when the CUDA context is created, so the running -engine cannot reopen them. `leleka reconfigure --gpu-budget-gib 24 --preset workstation` (either alone, plus any runtime settings and -`--persist`) hands the request to the supervisor (a small file in `STATE/run/`, answered in `reconfigure-result.json`), which - -1. checks it with the resource planner (`resources.rs`) without disturbing the service, and refuses what cannot work even with the engine gone - (a budget above the card, the workstation preset on a card that is mostly taken, an explicit budget the preset cannot give, an invalid - runtime setting, a host too small to keep the sealed archive and the preset's free memory at once); -2. stops the engine process (SIGINT, then SIGKILL after the grace period) and checks again against what the host really has free; -3. starts the engine again with the new numbers (`--gpu-budget`, the preset's CPU workers and RAM floors, the runtime settings), handing it the - sealed archive descriptor the supervisor still holds (no second 55 GB copy, no second hash: the first engine already verified this memfd), - and loads the model (minutes); -4. keeps the gateway and the API in their processes and on their ports; requests that arrive during the restart see `/ready` 503. With - `--persist` and a new context the API process is restarted too (seconds), because `strata.json` carries the context it advertises. - -If the planner refuses after the stop, or the new engine does not come up, the previous settings are started again and the call answers -`... ; the previous settings are back` with a non-zero exit. A request that equals what is in force is answered at once. A planned restart does -not count against the crash-restart limit. The planner needs the supervisor to hold the archive (`kar_source: memfd`) and refuses a plan that -would switch the installation to the file-backed form: `leleka up` decides that. Going back from `workstation` to `dedicated` restores the -profile as `up` resolved it (`base_profile` in `leleka.json`, written since this feature; an older file can leave `workstation` only through -`leleka up --preset dedicated`). - -## 5. Flags - -`leleka up [OPTIONS]` (also accepted by `preflight`, `status`, `down`): - -| flag | meaning | -| --- | --- | -| `--dry-run` | print preflight and plan (and the exact engine command); change nothing; exit 1 if a check fails or a step is blocked | -| `--json` | machine-readable plan / summary on stdout (logs stay on stderr) | -| `--profile auto\|NAME\|FILE` | memory profile | -| `--gpu N` | CUDA device ordinal (default 0) | -| `--assets DIR` `--state-dir DIR` `--prefix DIR` | the three roots (section 3) | -| `--bin-src DIR` | where the six binaries come from (default: the directory of `leleka`, i.e. the release `bin/`) | -| `--mode auto\|system\|user\|foreground\|none`, `--foreground` | `auto`: root with systemd -> system unit; a user with a systemd user session -> user unit; otherwise foreground. `none` prepares and starts nothing | -| `--service-user NAME` | system unit only: the account the service runs as (default `leleka`, created with `useradd --system`; state and assets are chowned to it) | -| `--api-port` `--engine-port` `--daemon-port` | ports (defaults 8081, 18766, 18080) | -| `--api-bind IP` | API listen address, default `127.0.0.1`; `0.0.0.0` only inside a container whose port is published to the host's loopback or tunnelled (the bearer key is the only protection, no TLS). The engine and gateway are always loopback | -| `--preset dedicated\|workstation` | how much of the host the engine takes (env `LELEKA_PRESET`, section 4b; recorded in `leleka.json`) | -| `--gpu-budget-gib N` `--context-tokens N` | override one profile value | -| `--no-fetch` | never download or build; require verified files to exist | -| `--reverify` | ignore the stamps and hash everything again | -| `--trust-archive` | accept an existing pinned-length archive + provenance without the strict re-derivation (section 2) | -| `--mtp-pack PATH` | import the MTP pack (directory or `.tar/.tar.gz/.tgz/.tar.xz`, sub-directories searched) | -| `--expert-profile-file PATH` / `--no-expert-tier` | install the ranked expert table from this copy of the upstream `data/expert-profile.bin` instead of the embedded one (the pinned digest is still required) / run without the VRAM expert tier (much slower; reported as OFF) | -| `--cublas-dir DIR` / `--no-install-cublas` | use this CUDA 12 cuBLAS / fail instead of downloading it | -| `--kar-fd N` | an already sealed archive descriptor inherited from the parent (foreground or `--mode none` only) | -| `--timeout-s N` | wait this long for `/ready` (default 3600) | - -Other commands: `leleka verify` (full parallel hash of shards and archive, renews the stamps; section 6b), `leleka preflight` (checks only, exit 1 on FAIL), `leleka status` (cheap: no GPU probe; exit 0 only when ready; this is the container health check), -`leleka down` (stop the systemd unit), `leleka run --config STATE/leleka.json [--kar-fd N]` (the supervisor), `leleka profiles [show NAME]`. -`HF_TOKEN` in the environment is used only by `model fetch`, is sent only to `https://huggingface.co`, is removed from every child the supervisor starts, and is never printed or written. - -## 6. Operating it - -* systemd: `systemctl status leleka`, `journalctl -u leleka -f` (user unit: add `--user`; run `loginctl enable-linger USER` to start without a login). The unit has - `Restart=on-failure` with `RestartSec=30` growing to 10 minutes (`RestartSteps`), no start limit, and no restart after exit code 2 (configuration). The unattended - server setup (hardened unit, install script, lab mode) is in [`unattended.md`](unattended.md). -* The supervisor restarts a dead engine with the same sealed descriptor and loads the model again, waiting 5 s, 10 s, 20 s ... (at most 300 s) between attempts; - a start that fails counts as an attempt; after 6 in a row (the counter resets after 10 ready minutes) it exits 1 and systemd starts everything afresh. A hung engine is - found by the health check (`GET /metrics` every 10 s) and killed; see `unattended.md` section 5. The API process stays up and answers not-ready meanwhile. - A dead gateway (3) or API (5) is restarted too. -* `SIGTERM`/`SIGINT` drain: the API first (`shutdown_grace_s` 10), then the gateway and the engine (both handle SIGINT only, so the supervisor sends SIGINT), then SIGKILL after the grace. -* Logs: `STATE/logs/{leleka,engine,gateway,api,install}.log`; the supervisor copy-truncates any log past 16 MiB every 10 s and keeps 3 generations (`logs` in `leleka.json`). - Status: `STATE/run/status.json` (`phase`: sealing, starting_engine, loading, starting_api, ready, engine_restarting, draining, stopped, failed; also uptime, restarts and - their reason, the health judgement, log volume; rewritten every 30 s). `leleka status` renders it, `leleka verify --quick` checks the installation without reading the model. -* Use it: `curl -H "Authorization: Bearer $(cat STATE/api-key)" -H 'content-type: application/json' -d '{"model":"qwen-iq3","input":"hello","max_output_tokens":32}' http://127.0.0.1:8081/v1/responses`. - Remote clients: an SSH tunnel. Known limits of this API-over-engine path (4096 output tokens, 256 generations per engine epoch, no image input) are in [`api-over-rust-engine.md`](api-over-rust-engine.md). - -## 6b. Fast restarts: where a cold start went and what was changed - -A start used to hash 83.6 GB of shards and the 55 GB archive one after the other, each in a single thread that alternated -`read` and `update` (laptop, cold: shard 0 115-134 s, shard 1 64-96 s, archive 95-181 s; 265-400 s in all, 100-215 s of it system time in -`read`). Every engine now prints `leleka-load-time phase=... seconds=... total=...` lines on stderr (`STATE/logs/engine.log`), and -`leleka-inference --verify-only` runs just the source verification (no CUDA) so that phase can be measured anywhere. - -| change | where | effect | -| --- | --- | --- | -| shard 0, shard 1 and the archive are verified at the same time | `backend.rs` `verify_sources_parallel`; refusals consumed in the old order (shard 0, shard 1, binding) | wall = the slowest file, not the sum | -| a reader thread keeps 6 x 8 MiB chunks ahead of the hasher (`pread`, `FADV_SEQUENTIAL`, recycled buffers) | `model-format/src/readahead.rs`, used by `VerifiedGgufFile::open` and the archive scan | I/O and hashing overlap | -| archive scan: SHA-256 on one thread, per-section CRC-32 on another | `kar.rs` `verify_integrity_pipelined`; same verdicts and precedence (SHA mismatch before CRC failure), tested against the stream scan | the 55 GB pass costs the slower of the two | -| **verification stamps**: a file that matched its pinned digest and is unchanged (device, inode, size, mtime, **ctime**) is not hashed again | `model-format/src/verify_stamp.rs`, `leleka-inference --verify-stamps DIR` (the supervisor passes `STATE/stamps/engine`) | a restart hashes nothing that did not change | -| the supervisor copies the archive into the memfd with 32 threads reading 8 MiB `O_DIRECT` blocks (`model-format/src/bulk_read.rs`) and checks that the source did not change while it was copied | `sealed.rs` `seal_file_report` | 55 GB cold in 153 s on the 5090 server instead of 6-33 min (`unattended.md` section 4) | -| a sealed memfd that this supervisor already had verified (an earlier engine) or that was copied from a file whose `kar-source` stamp matched is not hashed again: `--kar-attested-by-stamp` | `supervisor.rs`, `verify_stamp::set_attested_archive` | engine restarts and service restarts skip the 55 GB hash | -| on the first start, a CPU-only `--verify-only` hashes the shards while the supervisor fills the memfd | `supervisor.rs` `spawn_shard_preverify` | the two big reads overlap | -| `leleka verify` | `app.rs` | hashes shards and archive in full, in parallel, renews every stamp | - -Stamp rules (fail closed). A stamp is one line per (kind, pinned digest) in a directory that must be owned by the service account and closed to -group and others; any difference in any field, an unreadable, malformed or extra-long stamp, a symlink, or a stamp directory that is not private means -"hash in full". `ctime` changes on every write, truncate, chmod, chown and rename and cannot be set from user space, so a rewritten file does not match even -when its `mtime` is restored (unit-tested). A stamp is recorded only if the file's identity is the same before and after the full hash, and it is keyed by the pinned -digest, so it never replaces the pin. A changed file is hashed in full and refused if it no longer matches. What a stamp cannot defend against is someone who can write both the stamp -directory and the model file as the service account; that account also owns the archive the engine maps. `--verify-rehash` / `leleka verify` ignore existing stamps; `"verify_stamps": false` in -`STATE/leleka.json` turns the whole mechanism off (every start hashes everything, in parallel). - -Measured so far (CPU-only `--verify-only`, laptop i9-11900H, WSL2 ext4, shards and archive evicted from the guest page cache first; the host may still cache the virtual disk): - -| run | shard 0 | shard 1 | archive | wall | -| --- | --- | --- | --- | --- | -| before: sequential, `read` + `update` in one thread | 115 s | 64 s | 95 s | 265 s (a first run with a colder host cache: 400 s) | -| after: parallel + read-ahead, no stamps | 74 s | 57 s | 74 s | 72 s | -| after: parallel, second sample (warmer host cache) | 47 s | 28 s | 47 s | 45-51 s | -| after: stamps current | 0.02 s | 0.01 s | 0.00 s | 0.02 s | - -The laptop reads at about 1 GB/s at best; the 5090 server numbers are in the holder jobs `9g1`-`9g6` (section 10). - -## 7. Container image - -[`deploy/Containerfile.rust-runtime`](../deploy/Containerfile.rust-runtime): Ubuntu 24.04 (glibc 2.39, the floor of the binaries) + the six binaries + cuBLAS 12.9.1.4 -(downloaded by BuildKit with `ADD --checksum`, only `libcublas.so.12*` and `libcublasLt.so.12*` kept) + the manifest/provenance. The sealed PTX is inside the binaries; `ldd` shows only libc, libm -and libgcc_s, and the engine `dlopen`s `libcuda.so.1` (injected by the NVIDIA Container Toolkit) and `libcublas.so.12`. Not in the image, by design: the model, the driver, any secret. Non-root (uid 10001), volumes `/models` and `/state`, -`HEALTHCHECK` = `leleka status`. - -```sh -tar -xJf leleka-VERSION-linux-x86_64.tar.xz && cd leleka-VERSION-linux-x86_64 -docker build -f /path/to/repo/deploy/Containerfile.rust-runtime --build-arg VERSION=VERSION -t leleka-runtime:VERSION . -# pin the base for a release: docker buildx imagetools inspect ubuntu:24.04 then --build-arg BASE=ubuntu:24.04@sha256:... - -docker run -d --name leleka --gpus all --restart unless-stopped \ - -v /data/leleka-models:/models -v leleka-state:/state -p 127.0.0.1:8081:8081 \ - leleka-runtime:VERSION # default command: up --foreground --no-install-cublas --api-bind 0.0.0.0 -docker logs -f leleka # first start: hours (download, verification, archive build); later starts: minutes -docker exec leleka cat /state/api-key -``` - -The memfd profile needs the host to give the container ~60 GB of RAM (no `--memory` below that; memfd is shmem charged to the container, not limited by `--shm-size`). Docker's default seccomp -profile allows `memfd_create`. Build is not run in CI; see section 10 for what was checked. - -## 8. Build a release tarball - -On Linux/WSL, from a tree with the toolchain pinned by `rust-toolchain.toml` (no CUDA toolkit is needed; the PTX is checked in): - -```sh -cargo build --release --locked -p strata-desktop-core --features sm86 \ - --bin leleka-inference --bin leleka-daemon --bin leleka-cli --bin leleka-seal-exec -cargo build --release --locked -p strata-control --bin strata-next -cargo build --release --locked -p leleka-deploy --bin leleka - -# provenance is made where git exists (an exported tree has no .git); the tree must be clean or --allow-dirty marks it -python3 scripts/package-release.py provenance --repo . --out provenance.json -python3 scripts/package-release.py package --repo . --target-dir target --provenance provenance.json --out dist -``` - -`dist/leleka-VERSION-COMMIT12-linux-x86_64.tar.xz` (+ `.sha256`) contains `bin/` (six binaries), `share/leleka/ptx/{sm_120,sm_86}` (the sealed PTX and `SHA256SUMS`), `share/leleka/{profiles,templates,docs}`, -`MANIFEST.json` (version, commit, `features`, SHA-256 of every binary, rustc/glibc of the builder), `PROVENANCE.json`, `SHA256SUMS` for every file, and `install.sh`. `--no-ptx` omits the PTX files (they are embedded anyway); -`--with-cublas DIR` bundles cuBLAS (NVIDIA's redistribution terms apply). -`PROVENANCE.json` records the git commit, whether the tree was dirty (and a digest of the diff), the `Cargo.lock` digest, and for `engine/strata`: the upstream URL and commit from [`upstream.md`](upstream.md), -the subtree tree id, the import commit, every later commit touching the subtree, and the diff since import (shortstat + digest). The diff against the upstream tree itself is computed only when the upstream commit is present -in the repository (`git fetch strata-upstream`); otherwise the record says so. `engine/strata` is not modified by this work. - -## 9. Troubleshooting - -| message (preflight / run) | cause and fix | -| --- | --- | -| `NVIDIA GPU: nvidia-smi was not found` | no driver. Linux: install the NVIDIA driver >= 595. WSL2: install the Windows driver (never a Linux driver inside WSL), `wsl --shutdown`, retry | -| `driver version: 580.x is older than 595` | the sealed PTX needs ISA 9.2 (CUDA 13.2): update the driver | -| `GPU memory: N MiB free but the engine needs M MiB` | another process holds VRAM (`nvidia-smi`); stop it or lower `--gpu-budget-gib` | -| `architecture: ... built WITHOUT the sm86 feature` | an RTX 30-series card needs a release made with `--features sm86` | -| `memory: ... available is below ...` | the sealed archive copy needs the whole 55 GB in RAM. Free memory, or use the file profile if the GPU fits it. On WSL2 put `[wsl2] memory=32GB swap=8GB` in `%UserProfile%\.wslconfig` and `wsl --shutdown` | -| `WSL2 file system: ... is on a Windows/network mount` | `/mnt/c` is 9p: far too slow for mapped reads. Use a path on the WSL ext4 disk | -| `cuBLAS 12: libcublas.so.12 ... not found` | let `up` download the pinned 12.9.1.4 (needs curl or wget, tar, xz), or `--cublas-dir DIR`, or `apt install libcublas12` | -| `disk space: assets ...: N GiB free, M needed` | nothing was downloaded yet; point `--assets` at a larger volume | -| `loopback ports: already in use` | another listener; `--api-port` / `--engine-port` / `--daemon-port` | -| `permission denied` on `/dev/nvidia*` in the system unit | the device nodes are not world-accessible: add the service user to the `video` (or `render`) group and restart the unit | -| `systemd: not running` | WSL2 without systemd or a container: `--foreground`, or enable systemd in `/etc/wsl.conf` | -| `step mtp-pack is blocked` | the MTP pack has no automated producer yet; copy `data/mtp-rt` from a machine that has it (`--mtp-pack` takes a directory or tarball) | -| `... has N bytes but the engine only admits the pinned 55295529472-byte level-2 archive` | the archive was built with another level or policy; the engine would refuse it. Rebuild with `--levels 2` | -| `step model failed: ... 401/403` | the repository needs a token: `export HF_TOKEN=...` (sent only to huggingface.co) | -| `load-mtp was refused` | read `STATE/logs/engine.log` (the engine prints a fixed code, never a path or a secret) | -| `the model was not ready within 1800 s` | the engine verifies 84 GB of shards and 55 GB of archive at load; a cold disk can need longer: raise `load_timeout_s` in `STATE/leleka.json` | -| a stale `Another supervisor is running for ...` | `leleka down` (systemd) or stop the other process; `STATE/run/status.json` names its pid | - -## 10. What was run and what was not - -All of this is bring-up evidence, not a performance or quality result: no paired A/B, one request, no token statistics beyond what is quoted. - -### Findings that the real run produced - -1. **The production `Load` of the Original path could not succeed.** `leleka-inference ... --backend-mode original` never admitted a routed-expert bank - (the serve smokes call `load_resident_expert_source()` themselves; `backend.rs` did that only for the `--experimental-optimized-*` modes), so the first real `load-mtp` - through the daemon failed in `OriginalServeStack::open` with `MoeWeightCache::new_original_prompt_arena: InputRead` (`leleka-load phase=OriginalStack class=BackendUnavailable` in - `engine.log`) and the engine process stayed up. Fixed here: `OriginalServeOptions.expert_source` and `--expert-source resident|mapped` (default `resident`, the smoke form); - `backend.rs` admits the chosen bank before the driver, as it does for the optimized modes. The profile files select `resident` (server) and `mapped` (laptop). -2. **The supervisor waited out the load timeout for a refused load.** The engine does not exit on a failed load; `leleka` now reads the operation record - (`leleka-cli operation`, state FAILED/INDETERMINATE) and stops with the last lines of `engine.log`. -3. `leleka-inference` had no way to take the archive as a read-only file (only the 55 GB sealed memfd); `--kar-archive-file` is new and was exercised on the laptop. - -### Real runs - -| where | what | result | -| --- | --- | --- | -| WSL2 laptop, RTX 3080 Laptop 16 GB, driver 617.42, Ubuntu 24.04 with systemd, RAM 40 GB (`.wslconfig`) | `leleka up` from the unpacked release (commit `e03d97d`, 30.7 MB tarball, sm86 build), user unit, real shards and archive (copied to the WSL ext4 disk), profile `rtx3080-16g` chosen by `auto` | preflight 13 ok / 1 warning (cuBLAS missing); cuBLAS 12.9.1.4 unpacked from the pinned archive (SHA-256 checked; **the download itself was not exercised**: the archive was placed in `PREFIX/lib` beforehand); fetch + verify of the real shards about 3 min (hash reuse, no download); tokens, configs, tokenizer, `systemctl --user enable/start`; **model loaded in 198 s, `/ready` 200**; one `POST /v1/responses` (59 input tokens, 16 output tokens, 21.4 s wall, stopped by `max_output_tokens`, text is the model's reasoning preamble) | -| same | peak during that request | VRAM 13,971 MiB; engine RSS 26.4 GB (anon 2.6, file-backed 19.9, shmem 4.0); the engine log shows 3,133 VRAM expert slots (the expert tier was on because `expert-profile.bin` had the pinned digest) | -| same | idempotence | a second `up` against the running service: 0.27 s, same systemd `MainPID`, every step `done`; `leleka down`: 1.9 s, no process left, VRAM back to 0 | -| same | engine killed with `kill -9` | phase `engine_restarting`, `/ready` false, the engine restarted and reloaded: ready again 293 s after the kill (load 286 s), restart counter 1, gateway and API processes unchanged, one request served afterwards | -| RTX 5090 server (Ubuntu 26.04, driver 595.99.02, 121 GB RAM) | `leleka up --dry-run` with the real assets and the real preflight | 12 checks ok; the plan names the exact engine command; nothing created. The real-model jobs `930-deploy-prepare.sh` and `931-deploy-serve.sh` are in the holder queue (they inherit the holder's sealed descriptor with `--kar-fd`); see "Server job" below for their state | - -### Tests (no GPU, no model) - -* `cargo test -p leleka-deploy --features test-fakes` (71 unit, 11 end-to-end, 4 recipe tests, all passing in WSL): unit tests (profiles, facts parsers, preflight on synthetic hosts - server, laptop under default WSL2 memory, old driver, busy GPU, - no cuBLAS, full disk, `/mnt/c`, no systemd -, plan, units, CLI, sealed memfd, stamps, HTTP), `tests/e2e.rs` against a test double of the five programs - (supervisor lifecycle with an inherited sealed descriptor and with a read-only file: ready, SIGKILL of the engine -> restart with API/gateway unchanged -> SIGTERM drain with every child gone; - an engine that cannot start; a refused load fails fast; weak tokens are exit code 2; `up` is idempotent, resumable after a deleted archive, never rotates secrets, `--trust-archive`, wrong-size archive refused; - `--dry-run` creates nothing; a failing preflight changes nothing), `tests/recipe.rs` (the Containerfile is non-root, has a health check, copies no model or secret; the cuBLAS pin agrees in three places; `install.sh` verifies before it runs). - `cargo clippy --all-targets -- -D warnings` and `cargo fmt --check` are clean. -* `cargo test -p strata-desktop-core --bin leleka-inference` (14 argument-parsing tests, including `--kar-archive-file` and `--expert-source`). -* Linux only for the process tests; the portable parts also run on Windows (`cargo test -p leleka-deploy`), where the POSIX-path tests are not meaningful. - -### Not done / open - -* **No container image was built.** Docker Desktop on this laptop does not start: its backend aborts on stale `AF_UNIX` socket files (`%LOCALAPPDATA%\Docker -un\dockerInference`, - `userAnalyticsOtlpHttp.sock`, dated 2025-06) that Windows refuses to delete without elevation (`Error 1920`). The recipe is checked statically (`tests/recipe.rs`) and by simulation: the `COPY` layout - rebuilt under `/opt/leleka` in WSL, `env -i`, the container's environment variables: `ldd` resolves every library from the base alone (libc, libm, libgcc_s), `libcublas.so.12` is found in - `PREFIX/lib/cublas`, `leleka status` answers in 2 ms; the content is 167 MB of binaries + 815 MB of cuBLAS = 982 MB before the Ubuntu base layer (no image digest exists). - Build it on a machine with a working engine (section 7) and record the digest and size. -* The **system-scope** unit (`useradd`, chown of state and assets, `/etc/systemd/system`) and the `curl` branch of the cuBLAS download have unit tests / renders but were not run for real. -* No clean Ubuntu 24.04 / 26.04 VM was installed from nothing; the first-ever archive build (`ensure-sharded-streamed` creating 55 GB) was not repeated. -* The MTP pack has no producer in the repository (`mtp_pack`); `up` needs it in `ASSETS/data/mtp-rt` or via `--mtp-pack`. -* Not measured: the load time of the server profile under the supervisor, the RAM peak of 55 GB memfd + 50 GB bank, anything about throughput. -* Native Windows is not a target. TLS and remote access are not part of this: use an SSH tunnel. - -### Server job (RTX 5090) - -Two holder jobs are queued on `rnr5090` (`~/work/gpu-runs/holder2/jobs/`), written to run after each other and to inherit the holder's sealed descriptor, so nothing is copied or downloaded: - -* `930-deploy-prepare.sh`: `up --dry-run`, then `up --mode none --kar-fd $LELEKA_STRA169_KAR_FD --trust-archive` against `/home/para/work/leleka/models/leleka-gates/assets` (real `model fetch`/`verify` of the existing shards by hash reuse, - tokens, configs, tokenizer extraction into `assets/tokenizer-assets`), then a second dry-run and a second `up` to show that nothing is redone. -* `931-deploy-serve.sh`: `up --foreground --kar-fd ...` with the real model (typed load, `/ready`), one request through the API, an unauthenticated request (must be refused), SIGTERM, the logs and a check that no process is left. - -The release is unpacked at `~/work/deploy-run/rel`, state is `~/work/deploy-run/state`. At the time of writing the holder was busy with earlier queue entries (the holder takes a snapshot of the job list per pass, so entries added later run in the next pass), so -**these two jobs had not run**; read `930-deploy-prepare.log` and `931-deploy-serve.log` next to the scripts. The strict re-verification of the existing archive (`ensure-sharded-streamed` without `--trust-archive`) was deliberately not queued: -it re-derives the 708 GB virtual F32 stream (the analysis tool was stopped after 13 minutes at the same step, `build-validation.md`). - -### Startup profile jobs (RTX 5090, queued) - -`~/work/gpu-runs/holder2/jobs/9g1`-`9g6` (templates in `scripts/startup-profile/`) measure the phases of a -supervised start on the real assets with the holder's sealed descriptor: `9g1` verification only, baseline binaries (warm, cold shards, warm); `9g2`/`9g3` a full start with the baseline binaries -(warm / shards evicted); `9g4` verification only, new binaries (without stamps, with stamps first and second run, `--verify-rehash`); `9g5`/`9g6` two consecutive starts with the new binaries -(the second one is the restart that uses the stamps), warm / cold. Each prints the `leleka-load-time` lines, the governor's load ledger of the stack opening, the supervisor's -`start_to_ready` seconds and two requests (the second shows the warm-up cost of the first). They are FIFO behind the other queue entries; at the time of writing none had run. -The baseline binaries are the commit `cceb4b4` build (phase lines and `--verify-only`, sequential verification); the new ones the final build of this branch. - +# One-command deployment: `leleka up` + +**Windows 11:** `leleka.exe` (WSL2 bridge and native engine) is described in [`windows.md`](windows.md). + +Written 2026-10-17 on branch `claude/deploy`; sections 1 and 4 re-checked for release 0.1 on 2026-11-03 (the acceptance run on the 5090 is in `docs/release/5090-v0.1-checklist.md` section 7). This page describes the deployment +tool `leleka` (crate `crates/deploy`, no Python at run time), what it does, every flag, and what was and was not run to +check it. Results are in [section 10](#10-what-was-run-and-what-was-not); nothing here is a performance or model-quality +claim. Background: [`rust-runtime-run.md`](rust-runtime-run.md) (the processes), [`model-assets.md`](model-assets.md) (the model +commands `leleka` drives), [`laptop-profile.md`](laptop-profile.md), [`sm86-assets.md`](sm86-assets.md), +[`delivery-gap-audit.md`](delivery-gap-audit.md) section 5 (the packaging gaps this closes in part). + +## 1. Quickstart + +Server (Linux x86_64, NVIDIA driver >= 595, systemd), as root, from the unpacked release: + +```sh +tar -xJf leleka-VERSION-COMMIT12-5090-linux-x86_64.tar.xz && cd leleka-VERSION-COMMIT12-5090-linux-x86_64 +sudo ./install.sh --assets /data/leleka # preflight, fetch+verify, KAR archive, install, start, wait for ready +``` + +WSL2 laptop (RTX 3080 16 GB), as your user, in a terminal (WSL2 usually has no systemd): + +```sh +./install.sh --assets ~/leleka --foreground # keep the terminal open; Ctrl-C drains and stops +``` + +Both do the same thing, idempotently, and print the endpoint, model digest, GPU, the VRAM/RAM budget that was chosen, and the +log directory when the service answers `/ready`. Look first with `--dry-run`: it prints the preflight and the plan and changes nothing. + +```sh +./bin/leleka up --dry-run --assets /data/leleka +``` + +This is charter goal G2 (`PROJECT_CHARTER.md` section 6): one command, GPU and memory plan chosen automatically, external model volume, readiness only after the model is loaded, orderly stop and restart of the worker, no Python at run time. +Its acceptance test (a clean Linux GPU node, driver installed, one command, no re-download after a restart) has **not** been run; section 10 lists what was. + +Container: [section 7](#7-container-image). Build your own release: [section 8](#8-build-a-release-tarball). + +## 2. What `up` does + +| # | step | what happens | idempotency | +| --- | --- | --- | --- | +| 1 | preflight | driver >= 595, GPU architecture, VRAM free vs budget, RAM total/available, disk on each volume, WSL2 mounts, `libcublas.so.12`, `memfd_create`, ports, systemd, the six binaries | read-only; any FAIL stops before anything is changed | +| 2 | layout | state (0700), logs, run, stamps, assets | `mkdir -p` | +| 3 | binaries | copy `bin/*` to `PREFIX/bin`, SHA-256 checked against `MANIFEST.json` | skipped when identical; replaced by rename (safe for a running binary) | +| 3b | expert profile | the ranked VRAM expert tier's table `ASSETS/data/expert-profile.bin` (192 KiB, upstream Strata at the pinned commit): the upstream bytes are embedded in the `leleka` binary (`crates/deploy/data/expert-profile.bin`, MIT notice beside it) and written there on first start, so no network is needed; `--expert-profile-file PATH` installs your copy instead, and an https download from the pinned commit is only the fallback; SHA-256 `8f59b4aa...388975baf` is checked, the file is installed by rename, any other digest fails closed (a wrong file already there is moved aside, never deleted); `--no-expert-tier` is the explicit opt-out. Planned before the large downloads. `status`, `verify`, the ready summary and the supervisor log say `expert tier ON (sha256 ...)` or `WARNING expert tier OFF: reason` | skipped when the file has the pinned digest | +| 4 | cuBLAS 12 | uses what the host has; otherwise downloads the pinned NVIDIA 12.9.1.4 redistributable (SHA-256 pinned, resumable) into `PREFIX/lib/cublas` | skipped when `libcublas.so.12` and `libcublasLt.so.12` are found | +| 5 | secrets | two service tokens into `STATE/runtime.env` (0600), API key through `strata-next api-key init` | never rotated; only missing/invalid ones are created | +| 6 | model | `strata-next model fetch qwen-iq3-s` then `model verify` (resumable `.part` files, SHA-256) | stamped with size+mtime: skipped on re-runs unless `--reverify` | +| 7 | KAR archive | `strata-next model ensure-sharded-streamed qwen-iq3-s --levels 2` (level 2, the pinned 55,295,529,472-byte archive + provenance) | stamped; also checks the length the engine admits | +| 8 | MTP pack | `ASSETS/data/mtp-rt` must exist; `--mtp-pack` imports it from a directory or tarball | skipped when present | +| 9 | tokenizer | `model extract-tokenizer` from shard 1 | skipped when present | +| 10 | config | `leleka.json`, `daemon.json`, `strata.json`, `profile.json`, `runtime.env` | rewritten only when the content changes | +| 11 | service | systemd unit (system or user), `daemon-reload`, `enable`; none in foreground mode | rewritten only when the content changes; a changed unit restarts a running service | +| 12 | start / ready | start the unit (or run the supervisor in this terminal), poll `/ready` with the key, print the summary | an already ready service is left alone | + +The archive step runs `ensure-sharded-streamed`, which fetches and verifies the shards itself, so on a first run step 6 is folded into +step 7 (the plan says so). The strict verification of an *existing* archive re-derives the 708 GB virtual F32 stream and is slow; a +machine that already holds the archive can pass `--trust-archive`: the archive is accepted when it has the pinned length and a +provenance file, and the engine checks its SHA-256 and every CRC against the pinned digest at each load anyway. + +A failed run is resumable: fix the cause and run the same command; finished steps are skipped (downloads continue from `.part`). + +## 3. The processes and files + +```text +leleka run (supervisor, the systemd ExecStart or your terminal) + |- seals the KAR archive into a memfd ONCE (memfd profile) -- or hands the engine a read-only file (file profile) + |- leleka-daemon gateway for the typed lifecycle, 127.0.0.1:18080 + |- leleka-inference engine, gRPC 127.0.0.1:18766 (started through `leleka exec-inherit`, which passes the sealed fd) + |- leleka-cli load-mtp qwen-iq3 qwen4exp-kar-ple-mtp-v1 -> wait for model_ready (the engine verifies shards + archive here) + `- strata-next serve public API (Responses, Chat, Messages, tools, ...), 127.0.0.1:8081, bearer key +``` + +```text +PREFIX/bin/{leleka,strata-next,leleka-inference,leleka-daemon,leleka-cli,leleka-seal-exec} PREFIX/lib/cublas/ +STATE/{leleka.json,daemon.json,strata.json,profile.json,runtime.env,api-key} STATE/{logs,run/status.json,stamps,mtp-staging} +ASSETS/model/*.gguf ASSETS/qwen-iq3-s-l2-v4.kar(.provenance.json) ASSETS/data/mtp-rt/ ASSETS/tokenizer-assets/ +``` + +Defaults: root gets `/opt/leleka`, `/var/lib/leleka/state`, `/var/lib/leleka/assets`; a user gets `~/.local/share/leleka`, +`~/.local/state/leleka`, `~/.local/share/leleka/assets`. Environment: `LELEKA_PREFIX`, `LELEKA_STATE`, `LELEKA_ASSETS`. +**Put `--assets` on the big volume**: about 140 GB (shards 83.6 GB + archive 55.3 GB); the first run needs that plus slack. + +### The sealed KAR archive is made by the service + +The engine accepts the archive only as a sealed memfd (regular, unlinked, pinned length, `WRITE|GROW|SHRINK|SEAL`). Until now an operator +tool (`kar_holder.py` / `seal_exec.py`, outside the repository) did that. `leleka run` now does it natively: it copies the archive into a +sealed memfd once (the whole 55 GB, or for `rtx5090-32g` only the 16.0 GB extents the serve path reads; large O_DIRECT blocks on many threads, so the copy leaves nothing in the page cache), keeps the descriptor close-on-exec in the supervisor, and hands a duplicate +to each engine start through `leleka exec-inherit` (standard input in, a descriptor number >= 3 out). An engine restart therefore does +**not** copy 55 GB again, and the API, the gateway and the CLI never see the descriptor. `leleka-seal-exec` still ships for manual runs. +`--kar-fd N` (on `up` and `run`) reuses a descriptor inherited from a parent that already holds one (a holder, a test harness): no second copy, and its RAM is not demanded. + +The **file profile** (laptop) cannot afford 55 GB of shmem. `leleka-inference` gained `--kar-archive-file PATH --kar-provenance PATH` +(`InheritedKarArchive::open_read_only_file`, the form `docs/laptop-profile.md` measured in a bench): the archive stays an ordinary file; +it must be regular, single-link, owned by the service user and without write bits (`up` sets mode 0400). It is weaker than the seal (immutability rests on +the file system) and is selected only by that profile. The full SHA-256 and all CRCs are still checked at load. + +## 4. Memory profiles + +`--profile auto` (default) picks by the GPU `nvidia-smi` reports; `--profile NAME` or `--profile FILE.json` overrides it, and +`--gpu-budget-gib` / `--context-tokens` override single values. `leleka profiles` lists them, `leleka profiles show NAME` prints one to copy and edit. +The files live in [`deploy/rust-runtime/profiles/`](../deploy/rust-runtime/profiles/) and are embedded in the binary. + +| profile | selected for | GPU budget | context | KAR archive | routed experts | RAM floor (total / available at start) | other | +| --- | --- | --- | --- | --- | --- | --- | --- | +| `rtx5090-32g` | sm_12x, >= 30 GB VRAM | 32,819,404,800 B = 31,299 MiB (needs that much free at start: 31,299 of the 32,110 MiB an idle card reports; was 30 GiB, see [vram-footprint-5090](experiments/vram-footprint-5090.md)) | 262,144 | sealed **sparse** memfd (`memfd_extents: ple_only`): only the 16.0 GB of the archive the serve path reads (the PLE rows, 2 extents), holes elsewhere; read O_DIRECT, so no page-cache copy | `resident`: page-locked RAM copy (50.3 GB) | 100 GiB / 74 GB (113 GB for `memfd_extents: full`; 58 GB when `--kar-fd` supplies the archive) | one resident copy of every model byte in host RAM (`kar-sparse-memfd.md`) | +| `rtx3080-16g` | sm_80..119, 14-24 GB VRAM | 15 GiB (needs 14,500 MiB free) | 8,192 | read-only file | `mapped`: read-only mappings of shard 0 | 22 GiB / 10 GiB; advice `.wslconfig memory=32GB` | VRAM expert tier: `up` fetches `ASSETS/data/expert-profile.bin` (pinned SHA-256 `8f59b4aa...388975baf`; `--no-expert-tier` to run without) | +| `rtx5090-32g-file` (experimental, never auto-selected: `--profile rtx5090-32g-file`) | none (explicit name only) | as `rtx5090-32g` | 262,144 | read-only file (`kar_source: file`; no memfd, no holder; start reads about 1 MB of it when its verification stamp is current) | `resident` | 64 GiB / 62 GB (the 55 GB archive is page cache, not a charge) | as `rtx5090-32g` except an explicit `prefix_cache_mib` 6144; [`kar-file-source.md`](kar-file-source.md): what the file form reads, its integrity guarantees, the A/B (`scripts/e2e/decode/kar-file-ab.sh`, not run) | + +Both profiles also carry a `memory` section (prefix cache `auto`, soft/hard floors 4096/2048 MiB, reserve, lock and heal of the sealed memfd): the engine sizes its caches from the memory left after the fixed footprint, sheds and refuses under pressure, and refuses to start with numbers when the footprint does not fit ([`memory-safety.md`](memory-safety.md)). The unit sets `LimitMEMLOCK=infinity`, which is what lets the lock keep the 55 GB memfd out of swap. + +Both profiles run `--backend-mode original` and the level-2 archive; the routed-expert bank must be admitted before the Original stack opens, which `leleka-inference` now does from `--expert-source resident|mapped` (see section 10, finding 1). They select documented switches only (budget, context, archive form, the +`LELEKA_ORIGINAL_SERVE_*` environment); they are **not** tuned, not quality-gated and carry no speed claim. A GPU that fits neither +(a 24 GB 4090, say) gets an error that names the way out: write a profile file. Fields: see `crates/deploy/src/profile.rs` +(`gpu_budget_bytes`, `context_tokens`, `prefill_capacity`, `kv`, `kv_resident`, `prompt_cache`, `kar_source`, `min_*`, `engine_env` +restricted to `LELEKA_ORIGINAL_SERVE_*`, `LELEKA_SM120_*` and `LELEKA_CHAIN`); unknown fields are refused. + +One binary serves both architectures: the sealed sm_120 PTX is used as is on Blackwell, and the build with `--features sm86` +(every release) swaps in the sm_86 companion PTX on 8.6 <= cc < 12.0 cards ([`sm86-assets.md`](sm86-assets.md)). Preflight reads `MANIFEST.json` and refuses a +binary built without `sm86` on such a card. All PTX is embedded in the binaries (the release also ships the files and a `SHA256SUMS` for audit). + +## 4b. Resource presets + +`leleka up` computes what the runtime takes of the host (`crates/deploy/src/resources.rs`, a pure function of the probed host facts and the profile), prints it, and bakes it into `leleka.json` (the profile's budget and floors, and `LELEKA_ORIGINAL_SERVE_CPU_WORKERS`). Two presets: + +| | `dedicated` (default) | `workstation` | +| --- | --- | --- | +| purpose | the host belongs to the runtime | Docker, agents and the IDE share the machine | +| CPU expert workers | `min(cores - 2, 15)` | `min(cores - leave, 15)`, leave 4 cores (8 above 16 cores) | +| host RAM kept free | the profile's governor floors (server: soft 4 GiB, hard 2 GiB) | soft floor 8 / 12 / 16 GiB (hosts under 32 / under 64 / from 64 GiB RAM), hard floor half of it; the profile's floors are only raised. The governor sheds the prefix cache first, then refuses new requests with 503 `memory_pressure` | +| VRAM | the profile budget | `min(profile, free - 2 GiB)` rounded down to GiB; the expert tier is sized from what remains | + +The native expert pool takes at most 15 workers. **Measured cost of the preset on the 5090** (job 9p0, tic-tac-toe replay, 16 requests, 2 repeats, fixed window): default (30 GiB, 15 workers) 139.8 tok/s; 8 workers alone 136.4 (-2.4 %); 8 workers and a 27 GiB budget 119.6 (-14.5 %). **Host RAM of the server profile (live check plat-reconf-live):** the 121 GiB server holds the 51.5 GiB sealed archive and an engine with a fixed footprint of 53.5 GiB (the page-locked copy of the routed experts and the pools), which leaves 12-13 GiB available while it runs. The `workstation` preset asks the governor for 16 GiB plus its 2 GiB reserve, so on that host it is not reachable in the resident form: the planner now says so (and `leleka up` falls back to the mapped form, `leleka reconfigure --preset workstation` refuses and points to `leleka up`). A host with 192 GiB or more has room for it. The VRAM taken from the expert tier is what costs (about 4 % per GiB), so the workstation margin is 2 GiB, not more, and the workers are capped at 15 rather than 8. If the workstation target cannot be met (less than half of the profile's VRAM budget would remain) the preflight fails with the numbers; a RAM shortfall does not fail: when the pinned form (sealed archive plus engine, about 58 GiB on the server) would leave less than the free target, `up` switches the profile to the mapped form of the laptop profile: the archive stays a read-only file and the experts are memory-mapped from SSD/HDD, with `available - target - 8 GiB` of experts page-locked (`resident_budget_gib`, 0 on a small host). It prints a warning, because decode is slower than with everything in RAM. The same fallback applies to `dedicated` when the host cannot hold the pinned form at all. `--gpu-budget-gib` and explicit profile fields win over the preset. + +## 4c. What the runtime reports (`leleka status`) + +The engine samples itself once a second and records every request (`crates/leleka-memory/src/telemetry.rs`). The document travels +gRPC `Snapshot.telemetry_json` -> the gateway -> `GET /v1/status` `machine` -> `leleka status` (also `--json`): + +| block | figures | +| --- | --- | +| `gpu` | utilisation %, memory-bus %, VRAM used/total, power, SM clock, temperature, board name (NVML, loaded with `dlopen`; where `libnvidia-ml` cannot be loaded, WSL2 and containers, the engine polls `nvidia-smi` instead, at most every 2 s; absent when neither exists) | +| `ram` | host total/available, engine resident and pinned, swap in use | +| `cpu` | engine CPU in busy cores (of the cores this process may use), whole-system busy % | +| `throughput` | prefill tok/s (last request, running average, lifetime) and decode tok/s (same, plus the live rate of the request in flight) | +| `cache` | requests and how many reused a checkpoint, prompt tokens reused of all, the last request's reused/prompt tokens | +| `context` | tokens live in the session, the configured maximum, percent used; `phase` idle/prefill/decode; `request` (prompt and generated tokens, seconds) while one runs | + +Prefill rate counts the tokens actually prefilled (prompt minus reused). Rates are `null` until a request has been measured. + +## 4d. Changing the runtime settings (`leleka reconfigure`) + +The engine can be re-initialised while it runs: it closes its serve stack and opens a new one with other settings, **without reloading the +weights, the CUDA context or the sealed archive** (**7 s** on the 5090 instead of the 3-5 minute start, live job 9r1). The call waits for the request in flight; requests that arrive meanwhile wait in the +gateway queue. If the new stack cannot open (for example the VRAM +does not hold a larger context) the previous settings are reopened and the call answers `reconfigure refused: ...; the previous settings are back`. + +```sh +leleka reconfigure --context-tokens 131072 --prefix-cache-mib 20480 --prefix-cache-tail reply --cpu-workers 8 +leleka status # prints "settings in force" with the engine telemetry +``` + +| setting | meaning | note | +| --- | --- | --- | +| `--context-tokens N` | context length (prompt plus output of one request) | 1..262144; bounded by the VRAM left for the K/V window | +| `--prefill-capacity N` | prefill chunk (256 ... 8192) | 8192 prefills a cold 100k prompt about twice as fast as 2048; takes VRAM from the expert cache. The `rtx5090-32g` profile ships 8192 (with `--prefix-cache-block 8192`): 256k session TTFT sum 131 s at 2048 against 55-60 s | +| `--kv-resident N` | K/V cells per layer kept in VRAM | fixed for the life of the process: only the value in force is accepted (a different one needs a restart; 9r1 showed the engine refuses it) | +| `--prefix-cache-mib auto\|off\|N` | host-RAM budget of the cross-session prefix cache | `off` drops the cache | +| `--prefix-cache-tail off\|prompt\|reply` | request-end checkpoints | `docs/prefix-cache.md` | +| `--prefix-cache-block N`, `--prefix-retention-min N` | block / grid size, minutes an idle session is kept | | +| `--cpu-workers N` | CPU expert workers (1..=15, the native pool's limit; the engine default is 15) | the resources the engine takes on the host | +| `--spec-min-p P` | draft-probability floor | | + +The same call is `POST /v1/reconfigure` with the JSON document (`{"context_tokens": 131072, ...}`; same bearer key; the answer carries the +effective settings) and gRPC `Runtime.Reconfigure`. The prefix cache is rebuilt empty (its host images belong to the old stack), so the +next request of every session reads its prompt again once. + +**Keeping a change (`--persist`).** Without it a change lasts until the service restarts. With `--persist` the supervisor also writes the +result into `STATE/leleka.json` (profile fields: `context_tokens`, `prefill_capacity`, `kv_resident`, `spec_min_p`, +`memory.prefix_cache_{mib,tail,block}`, `memory.prefix_retention_min`, and `engine_env.LELEKA_ORIGINAL_SERVE_CPU_WORKERS` for the workers) and +regenerates `strata.json`, so a restart of the service, and a restart of a crashed engine, start with the new numbers. The file written is the +configuration in force, so a change made earlier without `--persist` in the same service life is written with it. With no supervisor running +the file is edited directly. + +**Budget and preset: restart in place.** The VRAM budget and the resource preset are fixed when the CUDA context is created, so the running +engine cannot reopen them. `leleka reconfigure --gpu-budget-gib 24 --preset workstation` (either alone, plus any runtime settings and +`--persist`) hands the request to the supervisor (a small file in `STATE/run/`, answered in `reconfigure-result.json`), which + +1. checks it with the resource planner (`resources.rs`) without disturbing the service, and refuses what cannot work even with the engine gone + (a budget above the card, the workstation preset on a card that is mostly taken, an explicit budget the preset cannot give, an invalid + runtime setting, a host too small to keep the sealed archive and the preset's free memory at once); +2. stops the engine process (SIGINT, then SIGKILL after the grace period) and checks again against what the host really has free; +3. starts the engine again with the new numbers (`--gpu-budget`, the preset's CPU workers and RAM floors, the runtime settings), handing it the + sealed archive descriptor the supervisor still holds (no second 55 GB copy, no second hash: the first engine already verified this memfd), + and loads the model (minutes); +4. keeps the gateway and the API in their processes and on their ports; requests that arrive during the restart see `/ready` 503. With + `--persist` and a new context the API process is restarted too (seconds), because `strata.json` carries the context it advertises. + +If the planner refuses after the stop, or the new engine does not come up, the previous settings are started again and the call answers +`... ; the previous settings are back` with a non-zero exit. A request that equals what is in force is answered at once. A planned restart does +not count against the crash-restart limit. The planner needs the supervisor to hold the archive (`kar_source: memfd`) and refuses a plan that +would switch the installation to the file-backed form: `leleka up` decides that. Going back from `workstation` to `dedicated` restores the +profile as `up` resolved it (`base_profile` in `leleka.json`, written since this feature; an older file can leave `workstation` only through +`leleka up --preset dedicated`). + +## 5. Flags + +`leleka up [OPTIONS]` (also accepted by `preflight`, `status`, `down`): + +| flag | meaning | +| --- | --- | +| `--dry-run` | print preflight and plan (and the exact engine command); change nothing; exit 1 if a check fails or a step is blocked | +| `--json` | machine-readable plan / summary on stdout (logs stay on stderr) | +| `--profile auto\|NAME\|FILE` | memory profile | +| `--gpu N` | CUDA device ordinal (default 0) | +| `--assets DIR` `--state-dir DIR` `--prefix DIR` | the three roots (section 3) | +| `--bin-src DIR` | where the six binaries come from (default: the directory of `leleka`, i.e. the release `bin/`) | +| `--mode auto\|system\|user\|foreground\|none`, `--foreground` | `auto`: root with systemd -> system unit; a user with a systemd user session -> user unit; otherwise foreground. `none` prepares and starts nothing | +| `--service-user NAME` | system unit only: the account the service runs as (default `leleka`, created with `useradd --system`; state and assets are chowned to it) | +| `--api-port` `--engine-port` `--daemon-port` | ports (defaults 8081, 18766, 18080) | +| `--api-bind IP` | API listen address, default `127.0.0.1`; `0.0.0.0` only inside a container whose port is published to the host's loopback or tunnelled (the bearer key is the only protection, no TLS). The engine and gateway are always loopback | +| `--preset dedicated\|workstation` | how much of the host the engine takes (env `LELEKA_PRESET`, section 4b; recorded in `leleka.json`) | +| `--gpu-budget-gib N` `--context-tokens N` | override one profile value | +| `--no-fetch` | never download or build; require verified files to exist | +| `--reverify` | ignore the stamps and hash everything again | +| `--trust-archive` | accept an existing pinned-length archive + provenance without the strict re-derivation (section 2) | +| `--mtp-pack PATH` | import the MTP pack (directory or `.tar/.tar.gz/.tgz/.tar.xz`, sub-directories searched) | +| `--expert-profile-file PATH` / `--no-expert-tier` | install the ranked expert table from this copy of the upstream `data/expert-profile.bin` instead of the embedded one (the pinned digest is still required) / run without the VRAM expert tier (much slower; reported as OFF) | +| `--cublas-dir DIR` / `--no-install-cublas` | use this CUDA 12 cuBLAS / fail instead of downloading it | +| `--kar-fd N` | an already sealed archive descriptor inherited from the parent (foreground or `--mode none` only) | +| `--timeout-s N` | wait this long for `/ready` (default 3600) | + +Other commands: `leleka verify` (full parallel hash of shards and archive, renews the stamps; section 6b), `leleka preflight` (checks only, exit 1 on FAIL), `leleka status` (cheap: no GPU probe; exit 0 only when ready; this is the container health check), +`leleka down` (stop the systemd unit), `leleka run --config STATE/leleka.json [--kar-fd N]` (the supervisor), `leleka profiles [show NAME]`. +`HF_TOKEN` in the environment is used only by `model fetch`, is sent only to `https://huggingface.co`, is removed from every child the supervisor starts, and is never printed or written. + +## 6. Operating it + +* systemd: `systemctl status leleka`, `journalctl -u leleka -f` (user unit: add `--user`; run `loginctl enable-linger USER` to start without a login). The unit has + `Restart=on-failure` with `RestartSec=30` growing to 10 minutes (`RestartSteps`), no start limit, and no restart after exit code 2 (configuration). The unattended + server setup (hardened unit, install script, lab mode) is in [`unattended.md`](unattended.md). +* The supervisor restarts a dead engine with the same sealed descriptor and loads the model again, waiting 5 s, 10 s, 20 s ... (at most 300 s) between attempts; + a start that fails counts as an attempt; after 6 in a row (the counter resets after 10 ready minutes) it exits 1 and systemd starts everything afresh. A hung engine is + found by the health check (`GET /metrics` every 10 s) and killed; see `unattended.md` section 5. The API process stays up and answers not-ready meanwhile. + A dead gateway (3) or API (5) is restarted too. +* `SIGTERM`/`SIGINT` drain: the API first (`shutdown_grace_s` 10), then the gateway and the engine (both handle SIGINT only, so the supervisor sends SIGINT), then SIGKILL after the grace. +* Logs: `STATE/logs/{leleka,engine,gateway,api,install}.log`; the supervisor copy-truncates any log past 16 MiB every 10 s and keeps 3 generations (`logs` in `leleka.json`). + Status: `STATE/run/status.json` (`phase`: sealing, starting_engine, loading, starting_api, ready, engine_restarting, draining, stopped, failed; also uptime, restarts and + their reason, the health judgement, log volume; rewritten every 30 s). `leleka status` renders it, `leleka verify --quick` checks the installation without reading the model. +* Use it: `curl -H "Authorization: Bearer $(cat STATE/api-key)" -H 'content-type: application/json' -d '{"model":"qwen-iq3","input":"hello","max_output_tokens":32}' http://127.0.0.1:8081/v1/responses`. + Remote clients: an SSH tunnel. Known limits of this API-over-engine path (4096 output tokens, 256 generations per engine epoch, no image input) are in [`api-over-rust-engine.md`](api-over-rust-engine.md). + +## 6b. Fast restarts: where a cold start went and what was changed + +A start used to hash 83.6 GB of shards and the 55 GB archive one after the other, each in a single thread that alternated +`read` and `update` (laptop, cold: shard 0 115-134 s, shard 1 64-96 s, archive 95-181 s; 265-400 s in all, 100-215 s of it system time in +`read`). Every engine now prints `leleka-load-time phase=... seconds=... total=...` lines on stderr (`STATE/logs/engine.log`), and +`leleka-inference --verify-only` runs just the source verification (no CUDA) so that phase can be measured anywhere. + +| change | where | effect | +| --- | --- | --- | +| shard 0, shard 1 and the archive are verified at the same time | `backend.rs` `verify_sources_parallel`; refusals consumed in the old order (shard 0, shard 1, binding) | wall = the slowest file, not the sum | +| a reader thread keeps 6 x 8 MiB chunks ahead of the hasher (`pread`, `FADV_SEQUENTIAL`, recycled buffers) | `model-format/src/readahead.rs`, used by `VerifiedGgufFile::open` and the archive scan | I/O and hashing overlap | +| archive scan: SHA-256 on one thread, per-section CRC-32 on another | `kar.rs` `verify_integrity_pipelined`; same verdicts and precedence (SHA mismatch before CRC failure), tested against the stream scan | the 55 GB pass costs the slower of the two | +| **verification stamps**: a file that matched its pinned digest and is unchanged (device, inode, size, mtime, **ctime**) is not hashed again | `model-format/src/verify_stamp.rs`, `leleka-inference --verify-stamps DIR` (the supervisor passes `STATE/stamps/engine`) | a restart hashes nothing that did not change | +| the supervisor copies the archive into the memfd with 32 threads reading 8 MiB `O_DIRECT` blocks (`model-format/src/bulk_read.rs`) and checks that the source did not change while it was copied | `sealed.rs` `seal_file_report` | 55 GB cold in 153 s on the 5090 server instead of 6-33 min (`unattended.md` section 4) | +| a sealed memfd that this supervisor already had verified (an earlier engine) or that was copied from a file whose `kar-source` stamp matched is not hashed again: `--kar-attested-by-stamp` | `supervisor.rs`, `verify_stamp::set_attested_archive` | engine restarts and service restarts skip the 55 GB hash | +| on the first start, a CPU-only `--verify-only` hashes the shards while the supervisor fills the memfd | `supervisor.rs` `spawn_shard_preverify` | the two big reads overlap | +| `leleka verify` | `app.rs` | hashes shards and archive in full, in parallel, renews every stamp | + +Stamp rules (fail closed). A stamp is one line per (kind, pinned digest) in a directory that must be owned by the service account and closed to +group and others; any difference in any field, an unreadable, malformed or extra-long stamp, a symlink, or a stamp directory that is not private means +"hash in full". `ctime` changes on every write, truncate, chmod, chown and rename and cannot be set from user space, so a rewritten file does not match even +when its `mtime` is restored (unit-tested). A stamp is recorded only if the file's identity is the same before and after the full hash, and it is keyed by the pinned +digest, so it never replaces the pin. A changed file is hashed in full and refused if it no longer matches. What a stamp cannot defend against is someone who can write both the stamp +directory and the model file as the service account; that account also owns the archive the engine maps. `--verify-rehash` / `leleka verify` ignore existing stamps; `"verify_stamps": false` in +`STATE/leleka.json` turns the whole mechanism off (every start hashes everything, in parallel). + +Measured so far (CPU-only `--verify-only`, laptop i9-11900H, WSL2 ext4, shards and archive evicted from the guest page cache first; the host may still cache the virtual disk): + +| run | shard 0 | shard 1 | archive | wall | +| --- | --- | --- | --- | --- | +| before: sequential, `read` + `update` in one thread | 115 s | 64 s | 95 s | 265 s (a first run with a colder host cache: 400 s) | +| after: parallel + read-ahead, no stamps | 74 s | 57 s | 74 s | 72 s | +| after: parallel, second sample (warmer host cache) | 47 s | 28 s | 47 s | 45-51 s | +| after: stamps current | 0.02 s | 0.01 s | 0.00 s | 0.02 s | + +The laptop reads at about 1 GB/s at best; the 5090 server numbers are in the holder jobs `9g1`-`9g6` (section 10). + +## 7. Container image + +[`deploy/Containerfile.rust-runtime`](../deploy/Containerfile.rust-runtime): Ubuntu 24.04 (glibc 2.39, the floor of the binaries) + the six binaries + cuBLAS 12.9.1.4 +(downloaded by BuildKit with `ADD --checksum`, only `libcublas.so.12*` and `libcublasLt.so.12*` kept) + the manifest/provenance. The sealed PTX is inside the binaries; `ldd` shows only libc, libm +and libgcc_s, and the engine `dlopen`s `libcuda.so.1` (injected by the NVIDIA Container Toolkit) and `libcublas.so.12`. Not in the image, by design: the model, the driver, any secret. Non-root (uid 10001), volumes `/models` and `/state`, +`HEALTHCHECK` = `leleka status`. + +```sh +tar -xJf leleka-VERSION-linux-x86_64.tar.xz && cd leleka-VERSION-linux-x86_64 +docker build -f /path/to/repo/deploy/Containerfile.rust-runtime --build-arg VERSION=VERSION -t leleka-runtime:VERSION . +# pin the base for a release: docker buildx imagetools inspect ubuntu:24.04 then --build-arg BASE=ubuntu:24.04@sha256:... + +docker run -d --name leleka --gpus all --restart unless-stopped \ + -v /data/leleka-models:/models -v leleka-state:/state -p 127.0.0.1:8081:8081 \ + leleka-runtime:VERSION # default command: up --foreground --no-install-cublas --api-bind 0.0.0.0 +docker logs -f leleka # first start: hours (download, verification, archive build); later starts: minutes +docker exec leleka cat /state/api-key +``` + +The memfd profile needs the host to give the container ~60 GB of RAM (no `--memory` below that; memfd is shmem charged to the container, not limited by `--shm-size`). Docker's default seccomp +profile allows `memfd_create`. Build is not run in CI; see section 10 for what was checked. + +## 8. Build a release tarball + +On Linux/WSL, from a tree with the toolchain pinned by `rust-toolchain.toml` (no CUDA toolkit is needed; the PTX is checked in): + +```sh +cargo build --release --locked -p strata-desktop-core --features sm86 \ + --bin leleka-inference --bin leleka-daemon --bin leleka-cli --bin leleka-seal-exec +cargo build --release --locked -p strata-control --bin strata-next +cargo build --release --locked -p leleka-deploy --bin leleka + +# provenance is made where git exists (an exported tree has no .git); the tree must be clean or --allow-dirty marks it +python3 scripts/package-release.py provenance --repo . --out provenance.json +python3 scripts/package-release.py package --repo . --target-dir target --provenance provenance.json --out dist +``` + +`dist/leleka-VERSION-COMMIT12-linux-x86_64.tar.xz` (+ `.sha256`) contains `bin/` (six binaries), `share/leleka/ptx/{sm_120,sm_86}` (the sealed PTX and `SHA256SUMS`), `share/leleka/{profiles,templates,docs}`, +`MANIFEST.json` (version, commit, `features`, SHA-256 of every binary, rustc/glibc of the builder), `PROVENANCE.json`, `SHA256SUMS` for every file, and `install.sh`. `--no-ptx` omits the PTX files (they are embedded anyway); +`--with-cublas DIR` bundles cuBLAS (NVIDIA's redistribution terms apply). +`PROVENANCE.json` records the git commit, whether the tree was dirty (and a digest of the diff), the `Cargo.lock` digest, and for `engine/strata`: the upstream URL and commit from [`upstream.md`](upstream.md), +the subtree tree id, the import commit, every later commit touching the subtree, and the diff since import (shortstat + digest). The diff against the upstream tree itself is computed only when the upstream commit is present +in the repository (`git fetch strata-upstream`); otherwise the record says so. `engine/strata` is not modified by this work. + +## 9. Troubleshooting + +| message (preflight / run) | cause and fix | +| --- | --- | +| `NVIDIA GPU: nvidia-smi was not found` | no driver. Linux: install the NVIDIA driver >= 595. WSL2: install the Windows driver (never a Linux driver inside WSL), `wsl --shutdown`, retry | +| `driver version: 580.x is older than 595` | the sealed PTX needs ISA 9.2 (CUDA 13.2): update the driver | +| `GPU memory: N MiB free but the engine needs M MiB` | another process holds VRAM (`nvidia-smi`); stop it or lower `--gpu-budget-gib` | +| `architecture: ... built WITHOUT the sm86 feature` | an RTX 30-series card needs a release made with `--features sm86` | +| `memory: ... available is below ...` | the sealed archive copy needs the whole 55 GB in RAM. Free memory, or use the file profile if the GPU fits it. On WSL2 put `[wsl2] memory=32GB swap=8GB` in `%UserProfile%\.wslconfig` and `wsl --shutdown` | +| `WSL2 file system: ... is on a Windows/network mount` | `/mnt/c` is 9p: far too slow for mapped reads. Use a path on the WSL ext4 disk | +| `cuBLAS 12: libcublas.so.12 ... not found` | let `up` download the pinned 12.9.1.4 (needs curl or wget, tar, xz), or `--cublas-dir DIR`, or `apt install libcublas12` | +| `disk space: assets ...: N GiB free, M needed` | nothing was downloaded yet; point `--assets` at a larger volume | +| `loopback ports: already in use` | another listener; `--api-port` / `--engine-port` / `--daemon-port` | +| `permission denied` on `/dev/nvidia*` in the system unit | the device nodes are not world-accessible: add the service user to the `video` (or `render`) group and restart the unit | +| `systemd: not running` | WSL2 without systemd or a container: `--foreground`, or enable systemd in `/etc/wsl.conf` | +| `step mtp-pack is blocked` | the MTP pack has no automated producer yet; copy `data/mtp-rt` from a machine that has it (`--mtp-pack` takes a directory or tarball) | +| `... has N bytes but the engine only admits the pinned 55295529472-byte level-2 archive` | the archive was built with another level or policy; the engine would refuse it. Rebuild with `--levels 2` | +| `step model failed: ... 401/403` | the repository needs a token: `export HF_TOKEN=...` (sent only to huggingface.co) | +| `load-mtp was refused` | read `STATE/logs/engine.log` (the engine prints a fixed code, never a path or a secret) | +| `the model was not ready within 1800 s` | the engine verifies 84 GB of shards and 55 GB of archive at load; a cold disk can need longer: raise `load_timeout_s` in `STATE/leleka.json` | +| a stale `Another supervisor is running for ...` | `leleka down` (systemd) or stop the other process; `STATE/run/status.json` names its pid | + +## 10. What was run and what was not + +All of this is bring-up evidence, not a performance or quality result: no paired A/B, one request, no token statistics beyond what is quoted. + +### Findings that the real run produced + +1. **The production `Load` of the Original path could not succeed.** `leleka-inference ... --backend-mode original` never admitted a routed-expert bank + (the serve smokes call `load_resident_expert_source()` themselves; `backend.rs` did that only for the `--experimental-optimized-*` modes), so the first real `load-mtp` + through the daemon failed in `OriginalServeStack::open` with `MoeWeightCache::new_original_prompt_arena: InputRead` (`leleka-load phase=OriginalStack class=BackendUnavailable` in + `engine.log`) and the engine process stayed up. Fixed here: `OriginalServeOptions.expert_source` and `--expert-source resident|mapped` (default `resident`, the smoke form); + `backend.rs` admits the chosen bank before the driver, as it does for the optimized modes. The profile files select `resident` (server) and `mapped` (laptop). +2. **The supervisor waited out the load timeout for a refused load.** The engine does not exit on a failed load; `leleka` now reads the operation record + (`leleka-cli operation`, state FAILED/INDETERMINATE) and stops with the last lines of `engine.log`. +3. `leleka-inference` had no way to take the archive as a read-only file (only the 55 GB sealed memfd); `--kar-archive-file` is new and was exercised on the laptop. + +### Real runs + +| where | what | result | +| --- | --- | --- | +| WSL2 laptop, RTX 3080 Laptop 16 GB, driver 617.42, Ubuntu 24.04 with systemd, RAM 40 GB (`.wslconfig`) | `leleka up` from the unpacked release (commit `e03d97d`, 30.7 MB tarball, sm86 build), user unit, real shards and archive (copied to the WSL ext4 disk), profile `rtx3080-16g` chosen by `auto` | preflight 13 ok / 1 warning (cuBLAS missing); cuBLAS 12.9.1.4 unpacked from the pinned archive (SHA-256 checked; **the download itself was not exercised**: the archive was placed in `PREFIX/lib` beforehand); fetch + verify of the real shards about 3 min (hash reuse, no download); tokens, configs, tokenizer, `systemctl --user enable/start`; **model loaded in 198 s, `/ready` 200**; one `POST /v1/responses` (59 input tokens, 16 output tokens, 21.4 s wall, stopped by `max_output_tokens`, text is the model's reasoning preamble) | +| same | peak during that request | VRAM 13,971 MiB; engine RSS 26.4 GB (anon 2.6, file-backed 19.9, shmem 4.0); the engine log shows 3,133 VRAM expert slots (the expert tier was on because `expert-profile.bin` had the pinned digest) | +| same | idempotence | a second `up` against the running service: 0.27 s, same systemd `MainPID`, every step `done`; `leleka down`: 1.9 s, no process left, VRAM back to 0 | +| same | engine killed with `kill -9` | phase `engine_restarting`, `/ready` false, the engine restarted and reloaded: ready again 293 s after the kill (load 286 s), restart counter 1, gateway and API processes unchanged, one request served afterwards | +| RTX 5090 server (Ubuntu 26.04, driver 595.99.02, 121 GB RAM) | `leleka up --dry-run` with the real assets and the real preflight | 12 checks ok; the plan names the exact engine command; nothing created. The real-model jobs `930-deploy-prepare.sh` and `931-deploy-serve.sh` are in the holder queue (they inherit the holder's sealed descriptor with `--kar-fd`); see "Server job" below for their state | + +### Tests (no GPU, no model) + +* `cargo test -p leleka-deploy --features test-fakes` (71 unit, 11 end-to-end, 4 recipe tests, all passing in WSL): unit tests (profiles, facts parsers, preflight on synthetic hosts - server, laptop under default WSL2 memory, old driver, busy GPU, + no cuBLAS, full disk, `/mnt/c`, no systemd -, plan, units, CLI, sealed memfd, stamps, HTTP), `tests/e2e.rs` against a test double of the five programs + (supervisor lifecycle with an inherited sealed descriptor and with a read-only file: ready, SIGKILL of the engine -> restart with API/gateway unchanged -> SIGTERM drain with every child gone; + an engine that cannot start; a refused load fails fast; weak tokens are exit code 2; `up` is idempotent, resumable after a deleted archive, never rotates secrets, `--trust-archive`, wrong-size archive refused; + `--dry-run` creates nothing; a failing preflight changes nothing), `tests/recipe.rs` (the Containerfile is non-root, has a health check, copies no model or secret; the cuBLAS pin agrees in three places; `install.sh` verifies before it runs). + `cargo clippy --all-targets -- -D warnings` and `cargo fmt --check` are clean. +* `cargo test -p strata-desktop-core --bin leleka-inference` (14 argument-parsing tests, including `--kar-archive-file` and `--expert-source`). +* Linux only for the process tests; the portable parts also run on Windows (`cargo test -p leleka-deploy`), where the POSIX-path tests are not meaningful. + +### Not done / open + +* **No container image was built.** Docker Desktop on this laptop does not start: its backend aborts on stale `AF_UNIX` socket files (`%LOCALAPPDATA%\Docker +un\dockerInference`, + `userAnalyticsOtlpHttp.sock`, dated 2025-06) that Windows refuses to delete without elevation (`Error 1920`). The recipe is checked statically (`tests/recipe.rs`) and by simulation: the `COPY` layout + rebuilt under `/opt/leleka` in WSL, `env -i`, the container's environment variables: `ldd` resolves every library from the base alone (libc, libm, libgcc_s), `libcublas.so.12` is found in + `PREFIX/lib/cublas`, `leleka status` answers in 2 ms; the content is 167 MB of binaries + 815 MB of cuBLAS = 982 MB before the Ubuntu base layer (no image digest exists). + Build it on a machine with a working engine (section 7) and record the digest and size. +* The **system-scope** unit (`useradd`, chown of state and assets, `/etc/systemd/system`) and the `curl` branch of the cuBLAS download have unit tests / renders but were not run for real. +* No clean Ubuntu 24.04 / 26.04 VM was installed from nothing; the first-ever archive build (`ensure-sharded-streamed` creating 55 GB) was not repeated. +* The MTP pack has no producer in the repository (`mtp_pack`); `up` needs it in `ASSETS/data/mtp-rt` or via `--mtp-pack`. +* Not measured: the load time of the server profile under the supervisor, the RAM peak of 55 GB memfd + 50 GB bank, anything about throughput. +* Native Windows is not a target. TLS and remote access are not part of this: use an SSH tunnel. + +### Server job (RTX 5090) + +Two holder jobs are queued on `rnr5090` (`~/work/gpu-runs/holder2/jobs/`), written to run after each other and to inherit the holder's sealed descriptor, so nothing is copied or downloaded: + +* `930-deploy-prepare.sh`: `up --dry-run`, then `up --mode none --kar-fd $LELEKA_STRA169_KAR_FD --trust-archive` against `/home/para/work/leleka/models/leleka-gates/assets` (real `model fetch`/`verify` of the existing shards by hash reuse, + tokens, configs, tokenizer extraction into `assets/tokenizer-assets`), then a second dry-run and a second `up` to show that nothing is redone. +* `931-deploy-serve.sh`: `up --foreground --kar-fd ...` with the real model (typed load, `/ready`), one request through the API, an unauthenticated request (must be refused), SIGTERM, the logs and a check that no process is left. + +The release is unpacked at `~/work/deploy-run/rel`, state is `~/work/deploy-run/state`. At the time of writing the holder was busy with earlier queue entries (the holder takes a snapshot of the job list per pass, so entries added later run in the next pass), so +**these two jobs had not run**; read `930-deploy-prepare.log` and `931-deploy-serve.log` next to the scripts. The strict re-verification of the existing archive (`ensure-sharded-streamed` without `--trust-archive`) was deliberately not queued: +it re-derives the 708 GB virtual F32 stream (the analysis tool was stopped after 13 minutes at the same step, `build-validation.md`). + +### Startup profile jobs (RTX 5090, queued) + +`~/work/gpu-runs/holder2/jobs/9g1`-`9g6` (templates in `scripts/startup-profile/`) measure the phases of a +supervised start on the real assets with the holder's sealed descriptor: `9g1` verification only, baseline binaries (warm, cold shards, warm); `9g2`/`9g3` a full start with the baseline binaries +(warm / shards evicted); `9g4` verification only, new binaries (without stamps, with stamps first and second run, `--verify-rehash`); `9g5`/`9g6` two consecutive starts with the new binaries +(the second one is the restart that uses the stamps), warm / cold. Each prints the `leleka-load-time` lines, the governor's load ledger of the stack opening, the supervisor's +`start_to_ready` seconds and two requests (the second shows the warm-up cost of the first). They are FIFO behind the other queue entries; at the time of writing none had run. +The baseline binaries are the commit `cceb4b4` build (phase lines and `--verify-only`, sequential verification); the new ones the final build of this branch. + diff --git a/docs/release/RELEASE-NOTES-5090-v0.1.md b/docs/release/RELEASE-NOTES-5090-v0.1.md index e00affaf..ee8e3632 100644 --- a/docs/release/RELEASE-NOTES-5090-v0.1.md +++ b/docs/release/RELEASE-NOTES-5090-v0.1.md @@ -1,136 +1,71 @@ -# Leleka 0.1 for the RTX 5090: release notes (DRAFT, Phase A) +# Leleka 0.1 for the RTX 5090: release notes -Release `leleka-5090-v0.1`. Draft written on main `f9003b7ce` (2026-11-02). Cells marked `TBD` are filled from the release commit in Phase B; the packager refuses to -package while any `TBD` remains. Nothing here is a claim that was not measured: every number names the page it comes from. +Release `leleka-5090-v0.1`. Short on purpose: the details are in `README.md` and in the pages named below. Every number names its source. -## 1. What this is +## What it is -Leleka is a Rust/CUDA port of the **Original mode17 serve path** of Strata (the C++ engine under `engine/strata/`, pinned at upstream `41cf05a0`, engine 0.1.50) for one -model, **Qwen3.8-Flash-Next IQ3_S** with the KAR level-2 PLE archive and the MTP draft head, on **one RTX 5090 (32 GB)**, serving **one stream at 262,144 tokens of -context** to coding agents (Codex CLI) over the Responses, Chat Completions and Messages APIs. The serving path (engine process, gateway, API, supervisor) is Rust; **no Python -is needed to serve**. `engine/strata` is the reference and is not modified by this release. +A Rust/CUDA port of the Original mode17 serve path of Strata (reference `engine/strata/`, pinned at upstream `41cf05a0`, **not moved**: upstream is at 0.2.8) for Qwen3.8-Flash-Next IQ3_S + KAR level-2 PLE + +MTP, on one RTX 5090, one stream at 262,144 tokens, over Responses / Chat Completions / Messages. No Python and no CUDA toolkit on the serving host. **Not a formally quality-gated profile.** +Licence: MIT (`LICENSE`); a commercial licence is available on request. The model is not shipped; using it under its own licence is the user's responsibility. -It is a first release: it is fast on the workload it was measured on, it completes real Codex sessions, and its limits are listed in section 6. It is **not** a formally -quality-gated profile (the shipped `rtx5090-32g` profile says so in its own description), and the RTX 3080 laptop is **not part of this release**. +## Supported -## 2. Supported hardware and software (exact) +RTX 5090 (sm_120, 32,607 MiB), Ryzen 9 9950X3D class host with >= 100 GiB RAM (measured: 121 GB), Ubuntu 26.04.1 (kernel 7.0.0-38), NVIDIA driver >= 595 (measured 595.99.02), glibc >= 2.39, +about 140 GB model volume on a local NVMe. Built with Rust 1.99.0, `--locked`, sm_120 only. **Not supported, not run for this release:** RTX 3080 laptop / WSL2 serving, Windows native, other GPUs, containers (no image was built). -| | measured and supported | notes | -| --- | --- | --- | -| GPU | RTX 5090, 32,607 MiB, compute capability 12.0 (sm_120), PCIe 5 x16, power limit 600 W | the profile selects on `sm 120..130` and >= 30,000 MiB VRAM; needs 31,299 MiB free at start | -| CPU / RAM | Ryzen 9 9950X3D (16 cores), 121 GB RAM | profile floors: 100 GiB total, 113 GB available at start. While serving, the sealed 52 GB KAR memfd plus the 54-60 GB engine leave 7-13 GB available (`docs/e2e-run.md`) | -| OS | Ubuntu 26.04.1 LTS, kernel 7.0.0-38-generic | glibc >= 2.39 is the floor of the binaries (built on Ubuntu 24.04); other distributions are untested | -| driver | NVIDIA 595.99.02 (minimum 595: the sealed PTX needs ISA 9.2) | no CUDA toolkit is needed on the host; `libcuda.so.1` from the driver and `libcublas.so.12` + `libcublasLt.so.12` (CUDA 12) are loaded at run time | -| build | Rust 1.99.0 (`rust-toolchain.toml`), `cargo build --release --locked`, no sm86 feature; PTX sealed with nvcc 13.2.86 and checked in | | -| disk | about 140 GB for the model volume (shards 83.6 GB + archive 55.3 GB) plus logs and state | a fast local NVMe; see the cold-start note in section 6 | -| model | Qwen3.8-Flash-Next IQ3_S shards `4c1eb2ce...f7d2aca3` and `316b46f3...c161e113`, KAR level-2 archive `536d612c...1385afa5` (55,295,529,472 B), MTP pack digest-checked by its binding; the ranked expert table `data/expert-profile.bin` (196,632 B, sha256 `8f59b4aa...388975baf`) is pinned in the deploy crate but is **not in Git and not fetched by `leleka up`** (see section 6) | `leleka verify` re-hashes all of it against the pins | +## Package -**Not supported and not run for this release:** the RTX 3080 laptop and WSL2 serving (experimental, `docs/laptop-profile.md`), native Windows, any other GPU, containers -(no image was ever built), multi-GPU, images in requests (refused), `reasoning_budget_tokens`, `strata_tune` and control vectors (refused, fail closed), TLS (use an SSH tunnel). +`leleka-0.1.0-COMMIT12-5090-linux-x86_64.tar.xz` + `.sha256`: six binaries, the `rtx5090-32g` profile, service templates and the owner-run service scripts (`scripts/ops`, nothing installs itself), `install.sh`, +sealed sm_120 PTX with SHA-256, documents, licence texts, `MANIFEST.json`, `PROVENANCE.json`, `SHA256SUMS`. No weights, captures, credentials, logs or Python. `leleka version` prints the version, the commit (`clean`) and the Strata pin. +The ranked expert table is embedded in the binary; `leleka up` writes it to the model volume after checking its SHA-256 (`8f59b4aa...`). +Release commit `TBD`; package SHA-256 `TBD`; size `TBD`. -## 3. What is in the package +## Numbers -`leleka-0.1.0-COMMIT12-5090-linux-x86_64.tar.xz` (+ `.sha256`): six binaries (`leleka`, `strata-next`, `leleka-inference`, `leleka-daemon`, `leleka-cli`, `leleka-seal-exec`), -the `rtx5090-32g` profile, the service templates, `install.sh`, the sealed sm_120 PTX with SHA-256 (also embedded in the binaries), the documents this page cites, the licence texts of -the third-party material, the unattended-operation files when the release was built with them (**the owner installs the service; nothing in this release changes a system -setting on its own accord**), `MANIFEST.json`, `PROVENANCE.json` (git commit, `Cargo.lock` digest, Strata upstream commit and subtree id) and `SHA256SUMS`. It contains no -model weights, no KAR archive, no captures, no credentials, no logs and no Python. `leleka version` prints the version, the commit (`clean`) and the Strata pin. +Decode tok/s, frozen 245k corpus, 5 turns x 300 tokens, greedy, ours against vanilla Strata 0.2.6 / engine 0.1.50, fresh boots, vanilla in its good huge-page state (`docs/experiments/baseline-pair-5090.md` section 10, 3 balanced blocks): -Release commit `TBD`, package SHA-256 `TBD`, size `TBD`. Reproducibility of the six binaries at the same build path: `TBD` (the tarball itself is deterministic). +| arm | tok/s (sd) | block-paired, ours minus arm | +| --- | ---: | --- | +| ours | **155.4** (2.4) | | +| vanilla v1 (its shipped lossy defaults) | 137.0 (5.6) | +18.4 tok/s (+13.5 %), ahead in **3 of 3** blocks | +| vanilla v2 (lossless-comparable) | 144.7 (23.0) | +10.7 tok/s (+9.2 %), ahead in **2 of 3** blocks; v2 is bimodal, 171.2 once (ours 10.8 % behind in that block) | -## 4. Numbers (honest ones) +n = 3 blocks, wide intervals; pooled over 34 vanilla runs in its good state the lead is about 6 %. These are benchmark decode speeds, not agent-task times. +Later changes, each measured paired on the same workload: -All speed numbers are **decode tok/s** on the frozen 245k corpus: 5 turns, 300 output tokens each, greedy, final-turn input about 247k tokens, PCIe share 0.45 (the product default), prefix -cache auto, one request at a time, RTX 5090 + Ryzen 9 9950X3D, driver 595.99, ours built from main `ffd9322c7` (the code of `d29e3dba2`). The comparison arm is **vanilla Strata 0.2.6 / -engine 0.1.50** (`v1` = its shipped defaults, route tail skip ON and prefill CPU share ON, both lossy; `v2` = the same with both OFF, the lossless-comparable arm). Source: -`docs/experiments/baseline-pair-5090.md`. These are single-workload, 5-turn series, **not** agent-task wall times; real Codex sessions are in the last paragraph of this section. +* faster MTP draft attention (now default): bitwise identical, round -0.366 ms (-2.7 %, 12 of 12 blocks), tok/s +0.5 % +- 0.6 % (not significant) (`docs/experiments/draft-round-5090.md`); +* window policy, ceiling 0.60 (now default, `LELEKA_SPEC_POLICY=legacy` restores 0.9): tok/s +1.09 % +- 1.2 % (se 1.86, **not resolved: no speedup is claimed**) (`docs/experiments/window-policy-5090.md`); +* single-copy memory layout, sparse memfd (now default): output identical (2057/2057 logprob rows, 1036/1036 draft traces, 0 argmax flips), tok/s +0.58 % (n.s.), 6 blocks. -**The cleanest pairing (part e: one arm per fresh boot, page cache evicted so that vanilla gets its good huge-page state; 3 balanced blocks):** +Host RAM at the end of turn 5 of the 245k run (`docs/kar-sparse-memfd.md`, `runs/single-copy-ab`): -| arm | n | tok/s mean (sd) | range | tokens/round | ms/round | -| --- | ---: | ---: | --- | ---: | ---: | -| **ours (shipped defaults)** | 3 | **155.4 (2.4)** | 152.6 .. 157.0 | 2.11 | 13.57 | -| vanilla v1 (shipped lossy defaults) | 3 | 137.0 (5.6) | 130.6 .. 140.6 | 1.95 | 14.30 | -| vanilla v2 (lossless-comparable) | 3 | 144.7 (23.0) | 129.9 .. 171.2 | 1.94 | 13.61 | +| KAR source | MemAvailable | Shmem | tok/s | +| --- | ---: | ---: | ---: | +| full memfd (before) | 8.5 GiB | 55.2 GiB | 153.43 (sd 0.50) | +| **sparse memfd (default)** | **45.1 GiB (+36.6)** | 18.6 GiB | 154.33 (sd 2.14) | +| file source (experimental profile `rtx5090-32g-file`) | 59.9 GiB | 3.7 GiB | 82.73 (-46 %) | -Block-paired: ours - v1 **+18.4 tok/s (+13.5 %)**, ahead in 3 of 3 blocks. Ours - v2 **+10.7 tok/s (+9.2 %)**, ahead in **2 of 3 blocks**: in block 2 vanilla v2 ran 171.2 tok/s and ours 152.6, **ours was 10.8 % behind**. Vanilla has a -fast mode that nothing recorded explains (5 of 34 earlier vanilla runs were above 160 tok/s); ours does not (sd 1.6-2.5 in every series). With n = 3 blocks the intervals are wide. +Seal of the archive into RAM: sparse 28.4-29.3 s (14.9 GiB held), full 78.9-97.2 s (O_DIRECT, no page cache left). -On a 42 h-old machine (part d, 6 blocks) ours (155.6, sd 1.6) was ahead of vanilla v2 (132.9, sd 5.5) in 6 of 6 blocks (+17 %), but 5 of the 6 vanilla runs were in a partial huge-page state that -follows an ours run; pooled over all 34 vanilla runs the full-coverage vanilla mean is 146.9 (sd 12.5, best runs 160-174), so against vanilla's good state the lead is about 6 %, and ours is behind -vanilla's best single runs. Read "+9 to +13 % over vanilla in vanilla's good state, with high vanilla variance" and not "+17 %". +Release-commit acceptance on the 5090 (checklist section 7): `leleka up` to ready with the packaged binaries `TBD`; cold start (files evicted with `posix_fadvise DONTNEED`) `TBD`; real Codex smoke `TBD`. -**Draft-round change (`LELEKA_SM120_ATTN_DAILY_MTP=1`, now in the profile; `docs/experiments/draft-round-5090.md`):** bitwise identical (2057 of 2057 logprob rows and 1036 of 1036 draft traces, 0 argmax -flips; a model-free probe is byte-identical). Whole decode round **-0.366 ms (-2.7 %) in 12 of 12 paired blocks**. tok/s: **+0.5 % +- 0.6 %, not significant** with the shipped adaptive window, because the window -narrows when rounds get shorter; **+3.0 % in 5 of 5 blocks with the window held fixed** (not the shipped configuration). So the tok/s effect of this change depends on the window policy. `TBD`: the -adaptive-window default of `claude/window-policy` and its paired A/B on the release commit. +## Quality -**Real agent sessions (Codex CLI 0.163.0), reported separately and older:** on the 2026-10-17 code and the reference-equivalent configuration, tic-tac-toe 203 s and CRM 871 s, weighted decode -128.8 and 130.0 tok/s at 37k and 121k tokens of context (`docs/e2e-run.md` 7d); a 256k-class scripted session decoded about 105-109 tok/s at 100-220k tokens with TTFT 27-39 s (`docs/ledger.md`, job 9w2). -These predate most of the speed work and are not comparable with the table above (different workload, different code). Release-commit smoke result: `TBD`. Prefill: about 1.8k tok/s flat from 28k to 250k -tokens on the 2026-10-26 build (`docs/ledger.md`); the cross-session prefix cache re-reads only what changed (23,324 of 23,377 tokens reused on a 24k follow-up turn). +Lossy modes are **off**. Route tail skip gave +15.2 % decode but **failed its gate** (d_top1 p99 1.005 against a rounding-noise control of 0.3995, flips 2.77 % against 1.45 %), so no profile may set it; keyless KV failed too. +Against the Original (`docs/quality-gate.md`, 612 teacher-forced rows): pooled d_top1 p99 0.210 against the Original's own 0.197, flips 2.15 % against 2.22 %, one row outside the envelope (a `` position), +needle retrieval at 100k and 180k equal. **There is no 245k port-versus-Original equality gate yet** (STRA-337); chain kernels, prefill chunk 8192, request-end checkpoints, the adaptive tier and KAR level-2 PLE are tested +only at short or 30-70k contexts (`docs/experiments/2026-10-28-s6-1-lossy-audit.md`). All evidence is greedy. -**Cold start:** the first `/ready` after a boot is dominated by reading the 55 GB KAR archive; on this server buffered reads ran at 8-35 MB/s (a full fresh-boot cycle took 23-55 min, 10-39 min of it the -holder load). Release-commit cold start from boot to `/ready`: `TBD`. +## Known limits -## 5. Quality: what is gated and what is not +* Tool-call quality is the model's: malformed calls are refused, not repaired (4 of 98 generations in the first full run, 1 of 72 in a Codex session). +* One generation at a time (queue of 16, then 429); images, `reasoning_budget_tokens`, `strata_tune` are refused; output cap 32,768 tokens. +* Little RAM headroom: do not run anything big next to it. Cold start is dominated by the disk: the server's NVMe is a DRAM-less consumer drive (sustained writes stalled it three times; the server is on Wi-Fi only). +* No multi-hour soak on the release commit: the 1.5 h soak of the unattended work did not finish; post-release feedback after a week of real use replaces it. Not ported on purpose: the KAR routed-expert arm and the multi-GPU split (`docs/port-remaining.md`). +* Laptop RTX 3080: experimental, not run. -* **Lossy modes are OFF and are not in the package's profile.** Route tail skip (`LELEKA_ROUTE_TAIL_SKIP`) gave +15.2 % decode on a replay but **failed its quality gate on all three limits** (d_top1 p99 1.005 against the - rounding-noise control's 0.3995, max 5.81, argmax flips 2.77 % against 1.45 %; `docs/upstream-port-plan.md` row 3.1), so it stays an experimental flag that no profile may set. Vanilla ships it ON by default; ours - does not. Keyless/value-only KV failed its gate and is not shipped. `tool_call_recovery` (a regeneration on invalid output) is off. -* **Against the Original (`docs/quality-gate.md`, teacher-forced, 612 rows per arm, RTX 5090):** the port's deviation distribution equals the Original's own self-deviation (pooled d_top1 p99 0.210 against 0.197, argmax - flips 2.15 % against 2.22 %). One row of 612 per arm lies outside the Original's envelope (a `` position, d_top1 up to 1.36); it was localised to a high-gain row and not explained at the logit level. The - needle in a 100k and a 180k prompt is retrieved by both engines, with the same stop behaviour after a fix found by this gate. -* **The shipped profile as a whole is not bit-identical to the Original and has no 256k q_pair.** `LELEKA_CHAIN=all` (30-70k: flips 1.08 % against a rounding-noise control of 1.45 %), request-end prefix - checkpoints (`prefix_cache_tail=reply`, gated at about 70k), prefill chunk 8192 (one 16,000-token prompt answers differently from chunks 2048-6144; rounding or defect left open), the adaptive expert tier and the - window policy are each inside the rounding-noise envelope where they were tested and untested at 256k (`docs/experiments/2026-10-28-s6-1-lossy-audit.md`: 8 of 27 profile keys are "unknown until q_pair"). - The one bitwise item is the draft attention switch above. -* **KAR level-2 PLE** is a small numerical perturbation (about 1.6x the Original's other envelope arms on 6 prompts of at most 128 tokens; no perplexity, tool-call or long-context test): its quality status is - "pending" in `docs/model-assets.md`. -* **All identity, quality and speed evidence is greedy.** Sampled requests are accepted; they are not gated. +## Install, upgrade, rollback -## 6. Known limitations - -* **Tool-call quality is the model's.** A real Codex session saw malformed tool calls produced by the model (the server refuses them and nothing partial is published); there is no constrained decoding and no repair - step. Codex re-sends once or twice, then fails the turn (`docs/e2e-run.md` section 5; 4 of 98 generations in job 942, 1 of 72 in job 945d). -* **One generation at a time.** Requests queue (16 slots, then 429 with `Retry-After`); sessions are switched through the prefix cache, not batched. Cancel during prefill takes up to one prefill chunk (1.6 s measured with a 2048 chunk; the profile now uses 8192, not re-measured). -* **Memory headroom is small.** The profile needs the host to keep about 100+ GiB for the runtime; the `workstation` preset cannot reach its free-memory target in the resident form on a 121 GB host and falls back to the - mapped form, which is slower (`docs/deploy.md` 4b). Nothing else big should run on the server. -* **Cold start and the NVMe.** The server's root drive is a DRAM-less consumer NVMe: sustained **writes** stalled it three times (2026-10-28..30), buffered **reads** of the 55 GB archive run at a fraction of its - capability (the owner can raise the device readahead; this release changes no system setting). Do not copy trees or rsync on it; the safety net (hardware watchdog, rescue sshd) is the owner's. -* **`leleka up` on the 5090 has not been run end to end for real**: the one-command deploy path is covered by unit and end-to-end tests with a test double and by a run on the RTX 3080 laptop (2026-10-17); on the - server every measured run started the processes by hand inside a holder job (`docs/deploy.md` section 10, `docs/e2e-run.md`). `TBD`: what `claude/unattended` and the Phase B jobs closed. -* **The ranked expert table is an asset you must provide.** The profile's VRAM expert tier is sized from `data/expert-profile.bin` (upstream Strata's file, MIT, sha256 `8f59b4aa8873209dff11c11e37bcda9529a1335b724a1afeea37bf6388975baf`). It is not in Git (binary data are kept out by rule) and `leleka up` does not download it: without it `up` warns and the engine runs without the ranked tier, which is slower. The package carries it under `share/leleka/data/` only when it was built with `--expert-profile`: `TBD` (build decision). -* **API limits** (`docs/api-over-rust-engine.md`): images, `reasoning_budget_tokens`, `strata_tune`, `experimental_speed_projection` are refused; `usage.reasoning_tokens` is derived from re-tokenized text; the output cap is - 32,768 tokens; `/unload` is unsupported while the runtime is attached. -* **Not ported on purpose** (`docs/port-remaining.md`): the KAR routed/prefill expert arm of the earlier line (section 5 there), the multi-GPU layer split (section 6), the `/api-monitor` HTML page. -* **Stability evidence is short.** The soak behind the numbers is 40 consecutive requests (flat RSS and VRAM) plus two 15-25 minute Codex sessions on 2026-10-17 code and the 72-cell task matrix. `TBD`: the soak of - the unattended-operation work, if merged. -* **Variance of the comparison is vanilla's.** Do not read "ahead of vanilla" as a guarantee against its fast mode (section 4). - -## 7. Install, upgrade, rollback - -All commands are `leleka` subcommands (`leleka --help`); `docs/deploy.md` is the reference. The owner runs these; the packager and the notes never do. - -**Install** (Linux x86_64, root for the system unit): - -1. `sha256sum -c leleka-0.1.0-COMMIT12-5090-linux-x86_64.tar.xz.sha256`, then `tar -xJf` and `cd` into the directory; `sha256sum -c SHA256SUMS` (also run by `install.sh`); `./bin/leleka version` must show the commit and the Strata pin of the release. -2. `./bin/leleka up --dry-run --assets /data/leleka` prints the preflight, the plan and the exact engine command and changes nothing (any FAIL stops here). -3. `sudo ./install.sh --assets /data/leleka` (idempotent: preflight, fetch and verify, KAR archive, install, start, wait for ready); or `--foreground` in a terminal; or `--mode none` to prepare only. The MTP pack must be in - `ASSETS/data/mtp-rt` or passed with `--mtp-pack`. The first start copies the archive into a sealed memfd (needs the RAM above) and verifies 84 GB of shards and 55 GB of archive (stamps skip this on restarts). -4. `./bin/leleka status`; the API key is in `STATE/api-key` (mode 0600), the API listens on `127.0.0.1:8081`. Use an SSH tunnel for remote clients. If the release ships unattended-operation files - (`share/leleka/unattended/`), their README says what to copy where; installing a unit or changing a sysctl is a deliberate owner action. - -**Upgrade:** `leleka down` (or stop the unit), copy `STATE/{leleka,daemon,strata,profile}.json` somewhere safe, unpack the new release next to the old one, run its `./install.sh` with the same flags (binaries are replaced -by rename, configuration is rewritten only when the content changes, secrets are never rotated, the model volume is untouched), then `leleka version` and `leleka status`. `leleka reconfigure --persist` changes are in -`leleka.json` and survive. 0.1 has no state migration; a later release that needs one must say so. - -**Rollback:** `leleka down`, restore the saved `STATE/*.json`, run the **previous** release's `./install.sh` with the same flags (it copies its own `bin/`), `leleka status`. The model volume and the stamps are shared and -are not changed by an upgrade. The previous release directory is the rollback; keep it until the new one has served a real session. - -## 8. Verification and provenance - -* `scripts/release/package-5090.sh check|build|package|verify` (in the repository): gates, a deterministic archive, a `verify` of the unpacked package (digests, no forbidden content, `leleka version`). -* Licence and third-party audit and the secrets/PII scan: `docs/release/licence-and-secrets-audit-5090-v0.1.md` (a repository `LICENSE` is **missing at the time of this draft**; the release is blocked on it). -* Strata upstream: `https://github.com/Niko1221/Strata.git` at `41cf05a06a25dd29103b7b27a2279a3f60c21876`, kept deliberately although upstream is at 0.2.8; moving it is the next release's work (checklist section 3). -* The checklist with every gate, its evidence and its status: `docs/release/5090-v0.1-checklist.md`. +`README.md` has the commands: `leleka up --dry-run`, `sudo ./install.sh --assets DIR`, `leleka status`, `leleka verify --quick`, `leleka logs`, `leleka report`. Upgrade: stop, copy `STATE/*.json`, unpack the new release, run its +`install.sh` with the same flags (binaries replaced by rename, config rewritten only on change, secrets never rotated, model volume untouched). Rollback: restore the copies, run the previous release's `install.sh`. +There is no state migration in 0.1. diff --git a/docs/release/third-party-crates-5090-v0.1.tsv b/docs/release/third-party-crates-5090-v0.1.tsv index 021032d8..8ee73930 100644 --- a/docs/release/third-party-crates-5090-v0.1.tsv +++ b/docs/release/third-party-crates-5090-v0.1.tsv @@ -1,5 +1,5 @@ # Rust crates linked into the six shipped binaries (normal dependencies of leleka-deploy, strata-control, strata-desktop-core; x86_64-unknown-linux-gnu; default features) -# Cargo.lock sha256 (LF-normalised) 10d08d0c03448a8abec0ca3fc49595a0630dfa5bf1dfb2e2337bdbd2bdffd2b6 ; generated offline with cargo metadata --locked --offline on 2026-11-02, base f9003b7ce +# Cargo.lock sha256 (LF-normalised) 84b74b1d6a56c3245104dbb8f3bd78671991a55e4aed4cceae1bbfcc03218ade ; generated offline with cargo metadata --locked --offline on 2026-11-03, base 4cbbd2729 # name version SPDX licence expression (as declared by the crate) repository ahash 0.8.12 MIT OR Apache-2.0 https://github.com/tkaitchuck/ahash aho-corasick 1.1.5 Unlicense OR MIT https://github.com/BurntSushi/aho-corasick @@ -47,9 +47,9 @@ futures-macro 0.3.34 MIT OR Apache-2.0 https://github.com/rust-lang/futures-rs futures-sink 0.3.34 MIT OR Apache-2.0 https://github.com/rust-lang/futures-rs futures-task 0.3.34 MIT OR Apache-2.0 https://github.com/rust-lang/futures-rs futures-util 0.3.34 MIT OR Apache-2.0 https://github.com/rust-lang/futures-rs -getrandom 0.2.17 MIT OR Apache-2.0 https://github.com/rust-random/getrandom -getrandom 0.3.4 MIT OR Apache-2.0 https://github.com/rust-random/getrandom getrandom 0.4.3 MIT OR Apache-2.0 https://github.com/rust-random/getrandom +getrandom 0.3.4 MIT OR Apache-2.0 https://github.com/rust-random/getrandom +getrandom 0.2.17 MIT OR Apache-2.0 https://github.com/rust-random/getrandom h2 0.4.19 MIT https://github.com/hyperium/h2 hashbrown 0.17.1 MIT OR Apache-2.0 https://github.com/rust-lang/hashbrown heck 0.5.0 MIT OR Apache-2.0 https://github.com/withoutboats/heck diff --git a/scripts/release/package-5090.sh b/scripts/release/package-5090.sh index b707bd46..dce4f3dc 100644 --- a/scripts/release/package-5090.sh +++ b/scripts/release/package-5090.sh @@ -38,9 +38,8 @@ set -eu RELEASE_TAG=leleka-5090-v0.1 RELEASE_STRATA_PIN=41cf05a06a25dd29103b7b27a2279a3f60c21876 # docs/upstream.md; upstream 0.2.8 exists, the pin is NOT moved for this release BINARIES="leleka strata-next leleka-inference leleka-daemon leleka-cli leleka-seal-exec" -DOCS="docs/deploy.md docs/upstream.md docs/quality-gate.md docs/e2e-run.md docs/ledger.md docs/port-remaining.md docs/prefix-cache.md docs/rust-runtime-run.md docs/experiments/baseline-pair-5090.md docs/experiments/draft-round-5090.md docs/experiments/2026-10-28-s6-1-lossy-audit.md" -UNATTENDED_DEFAULTS="deploy/systemd deploy/unattended scripts/unattended deploy/rust-runtime/leleka.service" -EXPERT_PROFILE_SHA256=8f59b4aa8873209dff11c11e37bcda9529a1335b724a1afeea37bf6388975baf # crates/deploy/src/plan.rs EXPERT_PROFILE_SHA256 +DOCS="docs/deploy.md docs/upstream.md docs/quality-gate.md docs/e2e-run.md docs/ledger.md docs/port-remaining.md docs/prefix-cache.md docs/rust-runtime-run.md docs/experiments/baseline-pair-5090.md docs/experiments/draft-round-5090.md docs/experiments/2026-10-28-s6-1-lossy-audit.md docs/experiments/window-policy-5090.md docs/unattended.md docs/kar-sparse-memfd.md" +UNATTENDED_DEFAULTS="scripts/ops/README.md scripts/ops/install-leleka-service.sh scripts/ops/leleka.service scripts/ops/owner-wifi-stability.sh" MAX_TRACKED_BYTES=20000000 SECRET_RE='-----BEGIN [A-Z ]*PRIVATE KEY-----|AKIA[0-9A-Z]{16}|ghp_[A-Za-z0-9]{30,}|github_pat_[A-Za-z0-9_]{30,}|hf_[A-Za-z0-9]{30,}|sk-[A-Za-z0-9]{32,}|xox[abp]-[A-Za-z0-9-]{10,}|AIza[0-9A-Za-z_-]{35}|eyJ[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}\.' FORBIDDEN_NAME_RE='\.(gguf|kar2?|safetensors|pem|key|p12|pfx|jks|sqlite3?|db|log|jsonl|pcap|npz|npy|pt|pth|onnx)$|(^|/)(api-key|runtime\.env|\.env|id_rsa|id_ed25519|credentials)$' @@ -68,7 +67,6 @@ allow_dirty=0 rehearse=0 epoch= extra_unattended= -expert_profile= tarball_arg= while [ $# -gt 0 ]; do case "$1" in @@ -79,7 +77,6 @@ while [ $# -gt 0 ]; do --allow-dirty) allow_dirty=1; shift ;; --rehearse) rehearse=1; shift ;; --epoch) epoch=${2:?}; shift 2 ;; - --expert-profile) expert_profile=${2:?}; shift 2 ;; --unattended) extra_unattended="$extra_unattended ${2:?}"; shift 2 ;; -*) die "unknown option $1" ;; *) [ -z "$tarball_arg" ] || die "unexpected argument $1"; tarball_arg=$1; shift ;; @@ -215,8 +212,8 @@ gate_tracked_files() { gate_secrets() { [ "$mode" = repo ] || return 0 - hits=$(git grep -InE -e "$SECRET_RE" -- . ':!*.lock' 2>/dev/null | cut -d: -f1,2 | head -20 || true) - if [ -z "$hits" ]; then ok "no private key, cloud/VCS/HF token or JWT pattern in any tracked text file (matches are never printed)"; else bad "secret-like patterns at (file:line):"; printf '%s\n' "$hits"; fi + hits=$(git grep -InE -e "$SECRET_RE" -- . ':!*.lock' ':!crates/obs/src/redact.rs' 2>/dev/null | cut -d: -f1,2 | head -20 || true) + if [ -z "$hits" ]; then ok "no private key, cloud/VCS/HF token or JWT pattern in any tracked text file (matches are never printed; crates/obs/src/redact.rs is excluded: its unit tests hold synthetic token shapes for the redactor)"; else bad "secret-like patterns at (file:line):"; printf '%s\n' "$hits"; fi } gate_licence() { @@ -354,15 +351,9 @@ run_package() { [ -f "$d" ] || die "$d is missing" rel=${d#docs/}; mkdir -p "$stage/share/leleka/docs/$(dirname "$rel")"; cp "$d" "$stage/share/leleka/docs/$rel" done - if [ -n "$expert_profile" ]; then - [ -f "$expert_profile" ] || die "$expert_profile is not a file" - [ "$(sha256sum "$expert_profile" | awk '{print $1}')" = "$EXPERT_PROFILE_SHA256" ] || die "$expert_profile does not have the pinned SHA-256 $EXPERT_PROFILE_SHA256" - mkdir -p "$stage/share/leleka/data"; cp "$expert_profile" "$stage/share/leleka/data/expert-profile.bin" - else - note "no --expert-profile: no loose copy of data/expert-profile.bin is shipped; the leleka binary embeds the same bytes and `leleka up` installs them (sha256 checked)" - fi [ ! -f LICENSE ] || cp LICENSE "$stage/LICENSE" cp engine/strata/LICENSE "$stage/share/leleka/licenses/strata-MIT.txt" + cp crates/deploy/data/expert-profile.NOTICE "$stage/share/leleka/licenses/expert-profile-NOTICE.txt" cp crates/deploy/data/expert-profile.NOTICE "$stage/share/leleka/licenses/strata-expert-profile-NOTICE.txt" cp engine/strata/third_party/ggml/LICENSE "$stage/share/leleka/licenses/ggml-MIT.txt" cp engine/strata/third_party/project-maya/LICENSE "$stage/share/leleka/licenses/project-maya-MIT.txt"