Files
leleka/docs/rust-runtime-run.md
T
Pavlo RatushnyiandClaude Sonnet 5.5 e77c9e529e docs: delivery gap audit, Rust runtime run recipe, example gateway config and systemd templates
docs/delivery-gap-audit.md: host test counts, Python audit, Codex-direct and
deployment gaps with file:line, recommended tasks with acceptance criteria.
docs/rust-runtime-run.md: leleka-seal-exec + leleka-inference (--backend-mode original)
behind leleka-daemon, what was executed without a model or GPU context.
desktop-core/examples/daemon.original.json and deploy/rust-runtime/*: configuration
and user-unit templates (systemd-analyze --user verify only; not run with the model).

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

9.5 KiB

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.

Processes

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 execs 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

cd <checkout>   # 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. 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.

{
  "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/ (runtime.env.example, two user units).

Commands (bring-up server paths)

A=/home/para/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.

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.