# Running the Rust runtime (`leleka-inference` + `leleka-daemon`, Original serve path) Status 2026-10-16, branch `claude/m2-control-plane`. This page records how the Rust engine process and the gateway are started against the model assets, and what was and was not executed to check it. **No model load, no inference and no GPU context was involved in any check on this page**; it makes no performance or quality claim. The model-facing steps (`load-mtp`, a real `/v1/responses`) belong to the GPU bring-up and are written down here from the code, not from a run. > **One command instead of the manual steps below:** `leleka up` ([`deploy.md`](deploy.md)) preflights the host, fetches and verifies the > model, builds the archive, installs, creates the sealed KAR descriptor itself (no `kar_holder.py`), loads the model and waits for readiness. > This page stays the reference for what each process does. ## Processes ```text client (curl / Codex) --HTTP /v1/responses, Bearer LELEKA_GATEWAY_TOKEN--> leleka-daemon 127.0.0.1:18080 leleka-daemon --gRPC, Bearer LELEKA_RUNTIME_TOKEN-----------------> leleka-inference 127.0.0.1:18766 leleka-inference --CUDA driver API (dlopen libcuda.so.1, libcublas.so.12), no Python anywhere leleka-cli --HTTP /runtime/{status,load,unload,operation}-------> leleka-daemon (typed lifecycle control) ``` `leleka-seal-exec` is a launcher, not a daemon: it copies the KAR archive into a sealed memfd and `exec`s `leleka-inference` with the descriptor number substituted for `{FD}`. All four binaries live in `desktop-core/` (package `strata-desktop-core`). `leleka-inference` starts with model admission closed; its CUDA owner thread waits for an explicit `Load` and creates no CUDA context before it. ## Host prerequisites | item | requirement | source | | --- | --- | --- | | OS / CPU | Linux x86_64, glibc (built and tested on Ubuntu 26.04, glibc 2.43, g++ 15.2) | `backend.rs` refuses other targets | | NVIDIA driver | `libcuda.so.1` from driver >= 595 (the bring-up host has 595.99.02) | `cuda-driver/src/api.rs` dlopen | | cuBLAS | **CUDA 12** `libcublas.so.12` and `libcublasLt.so.12` on `LD_LIBRARY_PATH` | `cuda-driver/src/ple_batch_ffi.rs:147` dlopen by name | | build | Rust 1.99.0 (`rust-toolchain.toml`), a C compiler; no nvcc, no CMake, no Python (PTX is checked in and pinned) | `ldd` of the debug binary: libc, libm, libgcc_s only | | RAM | the sealed memfd is the whole archive: 55,295,529,472 bytes of shmem for as long as the process lives | `PINNED_ARCHIVE_BYTES` | The bring-up host uses the CUDA 12.9.1.4 redistributable (`https://developer.download.nvidia.com/compute/cuda/redist/libcublas/linux-x86_64/libcublas-linux-x86_64-12.9.1.4-archive.tar.xz`, archive sha256 `546addc4a9d82b8f23aa9ba9274b6bc0429a63008a31c759884ac24880796057`) unpacked to `~/cuda-toolkits/cublas-12.9.1.4/lib`. Ubuntu 26.04 also ships `libcublas12` 12.4.5.8 (multiverse). Which cuBLAS version the PLE batch GEMM must be pinned to for numerical reproducibility is not decided anywhere in the repository. ## Build ```sh cd # branch claude/m2-control-plane cargo build --release --locked -p strata-desktop-core \ --bin leleka-inference --bin leleka-daemon --bin leleka-cli --bin leleka-seal-exec # binaries: target/release/{leleka-inference,leleka-daemon,leleka-cli,leleka-seal-exec} ``` (The debug profile of the same four binaries is what the checks below used.) ## Files Gateway configuration: [`desktop-core/examples/daemon.original.json`](../desktop-core/examples/daemon.original.json). The runtime member `id` is the model name clients send. `artifact_digest` is the digest of the pinned IQ3_S shard pair (`crates/leleka-runtime/src/backend.rs` `MODEL_DIGEST`); the daemon refuses a runtime whose loaded descriptor differs. ```json { "schema_version": 1, "listen": "127.0.0.1:18080", "token_env": "LELEKA_GATEWAY_TOKEN", "runtimes": [ {"id": "qwen-iq3", "address": "127.0.0.1:18766", "token_env": "LELEKA_RUNTIME_TOKEN", "artifact_digest": "sha256:80d5e3333801cedbca81a5c19c24ed6bb48fd56977acd190318f66b23a1766a3"} ] } ``` Environment (both tokens: 32..4096 printable ASCII bytes, different values, never in argv or Git): `LELEKA_RUNTIME_TOKEN`, `LELEKA_GATEWAY_TOKEN`, and `LD_LIBRARY_PATH` including the CUDA 12 cuBLAS directory. Templates: [`deploy/rust-runtime/`](../deploy/rust-runtime/) (`runtime.env.example`, two user units). ## Commands (bring-up server paths) ```sh A=/home/para/work/leleka/models/leleka-gates/assets S=$HOME/leleka-run # private state; staging must be mode 0700 install -d -m 0700 "$S" "$S/mtp-staging" export LD_LIBRARY_PATH=$HOME/cuda-toolkits/cublas-12.9.1.4/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} export LELEKA_RUNTIME_TOKEN=... LELEKA_GATEWAY_TOKEN=... # from a private env file, not typed # 1. engine (copies 55 GB into a sealed memfd first, then execs leleka-inference with that fd) leleka-seal-exec --file $A/qwen-iq3-s-l2-v4.kar --expect-bytes 55295529472 -- \ leleka-inference --listen 127.0.0.1:18766 --token-env LELEKA_RUNTIME_TOKEN \ --shard0 $A/model/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00001-of-00002.gguf \ --shard1 $A/model/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00002-of-00002.gguf \ --gpu 0 --gpu-budget 25769803776 --context-tokens 262144 \ --kar-archive-fd {FD} --kar-provenance $A/qwen-iq3-s-l2-v4.kar.provenance.json \ --mtp-pack $A/data/mtp-rt --mtp-staging $S/mtp-staging \ --backend-mode original # 2. gateway leleka-daemon --config desktop-core/examples/daemon.original.json # 3. explicit load (the Original serve path requires the KAR PLE MTP profile); returns "accepted" at once leleka-cli --config desktop-core/examples/daemon.original.json load-mtp qwen-iq3 qwen4exp-kar-ple-mtp-v1 leleka-cli --config desktop-core/examples/daemon.original.json status # repeat until "model_ready": true leleka-cli --config desktop-core/examples/daemon.original.json models # lists qwen-iq3 only when ready # 4. request curl -N -H "Authorization: Bearer $LELEKA_GATEWAY_TOKEN" -H 'content-type: application/json' \ -d '{"model":"qwen-iq3","input":"hello","max_output_tokens":64,"stream":true}' http://127.0.0.1:18080/v1/responses ``` Notes taken from the code: * `--gpu-budget` 25769803776 is 24 GiB, the default of the bring-up serve smoke (`BUDGET`), not a tuned value. * `--context-tokens` must be 1..=262144 for `--backend-mode original` (the MTP drafter bank is frozen at the trained context). 2x256K and 1x512K are outside this path. * `{FD}` must appear in the command; the descriptor is 3 or higher, has no close-on-exec and carries WRITE|GROW|SHRINK|SEAL. `leleka-inference` reopens it through `/proc/self/fd/N`, so it needs `/proc`. * `--backend-mode original` never falls back; `auto` also picks the Original path when the configuration is eligible and prints `backend=preview (reason)` on stderr otherwise; `preview` is the Rust-native decoder chain. Record the mode used. * Optional: `--original-prefill-capacity` (256, 512, 1024, 2048, 3072, 4096, 6144, 8192; default 2048), `--mtp-rt-dir`, `--spec-min-p`. * `load-mtp` is asynchronous (the daemon's `leleka-cli` HTTP timeout is 10 s). A lost answer is reconciled with `leleka-cli ... operation MODEL OPERATION_UUID EPOCH`; the CLI prints both before it sends. It never retries. * After an engine restart the model is **not** loaded again automatically; issue `load-mtp` again (new epoch). * `leleka-inference` and `leleka-daemon` shut down gracefully on SIGINT only (observed: the daemon exits 0 on SIGINT and with status 143 on SIGTERM); under systemd use `KillSignal=SIGINT`, as the templates do. ## The full API in front of the runtime: `strata-next` with a `runtime` block `leleka-daemon` serves only a narrow text subset of `/v1/responses`. For Codex and the rest of the native API (Responses with stored responses, tools, `text.format`, reasoning; Chat Completions; Messages; `input_tokens`; drain; metrics) run `strata-next` with a `runtime` block instead of an `engine` child. Design and limits: [`api-over-rust-engine.md`](api-over-rust-engine.md). ```text client / Codex --HTTP, Bearer STRATA api key--> strata-next 127.0.0.1:8081 strata-next --gRPC, Bearer LELEKA_RUNTIME_TOKEN--> leleka-inference 127.0.0.1:18766 (the same process the daemon talks to) ``` Order (steps 1 and 3 of the commands above are unchanged; the daemon is optional and only needed for `leleka-cli`): ```sh # 1. engine, as above 2. (optional) leleka-daemon 3. explicit load: leleka-cli ... load-mtp qwen-iq3 qwen4exp-kar-ple-mtp-v1 # 4. the tokenizer assets strata-next counts tokens with (same GGUF the engine loads; written once, offline): strata-next model extract-tokenizer $A/model/Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00001-of-00002.gguf --output $S/tokenizer-assets # 5. the API export LELEKA_RUNTIME_TOKEN=... # same value the engine was started with; 32..4096 printable ASCII bytes strata-next serve --config control-plane/config.runtime.example.json # edit tokenizer_dir (= $S/tokenizer-assets/tokenizer) and api_key_file strata-next wait-ready --url http://127.0.0.1:8081 --model qwen-iq3 --key-file /etc/leleka/api-key ``` `runtime.model` and `runtime.mode` name what the engine must have loaded (here the pinned IQ3_S artifact and the experimental `qwen4exp-kar-ple-mtp-v1` mode). `strata-next` **only attaches**: it never sends Load or Unload, so an HTTP request cannot start a 55 GB load. If the runtime has nothing loaded, another artifact, or another mode, `/ready` stays 503 (worker `starting` or `restarting`) and the reason is logged (`waiting for the engine: ...`); when the runtime restarts, readiness drops within `runtime.health_interval_s` and returns by itself once the operator has loaded the model again. `/unload` answers `unsupported`. What a client can rely on, and what it cannot (verified with a scripted engine only; no model has run through this path): * `max_output_tokens` above `runtime.max_output_tokens` (default 32768, the runtime facade's own cap, `leleka_backend_api::MAX_OUTPUT_TOKENS`; it was 4096 until the Codex e2e run showed single turns that write a whole file need more) is refused with a message; an omitted value is clamped to that cap instead of the usual 32768. * The runtime keeps a bounded window (16384) of recent generation identities to refuse a replayed id; it no longer ends after 256 generations. * Images, `reasoning_budget_tokens`, `strata_tune` and `experimental_speed_projection` are refused: the text contract cannot carry them. * `usage.output_tokens` is the engine's count; `reasoning_tokens` is approximate. * Credential handling: the runtime token comes from the environment variable named by `token_env`, is never printed, and the address must be a loopback `ip:port`. ## What was executed for this page (host-side, no model, no GPU context) Host: Ubuntu 26.04.1, kernel 7.0.0-38, driver 595.99.02, RTX 5090 idle apart from the bring-up job, which was left alone. Debug build of the four binaries; `leleka-inference` was started with a **sparse** sealed memfd of the pinned length (no RAM used) and the real `*.provenance.json`, and stopped before any `Load`. | check | result | | --- | --- | | `leleka-cli validate` on the example config | `configuration_valid` | | `leleka-inference ... --backend-mode original` with the sealed sparse fd, the real provenance (SHA-256 verified), real shard/MTP paths | starts, listens on 127.0.0.1:18766, silent on stderr; same for `auto` (no `backend=preview` line) and `preview` | | same with an unsealed fd | `inherited KAR descriptor is not a pinned sealed archive` | | same without `--mtp-pack` | `Original serve cannot start: the Original path needs the MTP pack` then `original_serve_unavailable` | | daemon + inference, before `Load` | `/runtime/status`: `connected: true`, `model_ready: false`; `/v1/models`: empty list; no token: 401 | | `POST /v1/responses` valid text body, model not loaded | 503 `model_not_ready` | | body with `previous_response_id`, `tools`, `text.format` json_schema, or a Codex-shaped body (`reasoning`, `include`, `parallel_tool_calls`, `tool_choice`) | 400 `unsupported_request_field` (see `delivery-gap-audit.md`, section 4) | | `max_output_tokens` 99999 | 400 `invalid_output_limit` | Request validation, SSE ordering and finish reasons through the real HTTP/2 gateway are covered by the project's own synthetic backend (`desktop-core/tests/runtime_gateway_sdet.rs`: `actual_http2_text_maps_single_ordered_sse_terminal`, `accepted_faults_missing_terminal_and_tool_reason_fail_without_retry`, `daemon_http_disconnect_cancels_one_runtime_generation`) and, for the full Responses surface, through `strata-next` against scripted engines (`control-plane` tests, `scripts/test-live-responses-replay.py`, `scripts/smoke-*.py`; results in `delivery-gap-audit.md`, section 1). The synthetic fixtures are not recorded Codex traffic. ## Not covered here `Load`, any generation, the numerical behaviour of the Original path, systemd operation of the two unit templates (they pass `systemd-analyze --user verify` only), containers, and any throughput or latency figure.