Files
leleka/docs/e2e-run.md
T

38 KiB

End-to-end run of the production stack on the RTX 5090

Branch claude/e2e (cut from claude/port-gpu-bringup, merged with 0b0d128 = integrated head incl. claude/deploy), runs of 2026-10-17 on rnr5090 (Ubuntu 26.04, kernel 7.0.0-38, RTX 5090, driver 595.99.02, 121 GB RAM). Everything below is a functional and stability result of the current code, one sample per cell; it is not a performance or quality claim (charter rules: no paired A/B, no quality gate).

Stack under test, all four processes started inside a holder job (sealed KAR memfd inherited, MODEL.lock held by the holder):

python3 e2e_client.py (Codex-shaped Responses requests)   -- HTTP, Bearer test key -->  strata-next serve (runtime block)  127.0.0.1:8081
strata-next                                               -- gRPC, runtime token ---->  leleka-inference --backend-mode original  127.0.0.1:18766
leleka-cli load-mtp (through leleka-daemon 127.0.0.1:18080) loads the model; strata-next only attaches.

1. Binaries (built in WSL, never on the server)

cargo build --release --locked -p strata-desktop-core --bin leleka-inference --bin leleka-daemon --bin leleka-cli -p strata-control --bin strata-next -p leleka-deploy --bin leleka (rustc 1.99.0, WSL2 Ubuntu 24.04, CARGO_TARGET_DIR outside the tree), sm_120 default and --features strata-desktop-core/sm86. Only the first four were copied to rnr5090:~/work/leleka-e2e/bin-sm120/ (scp, mode 0755). The sm86 binaries were built and started with --help in WSL (RTX 3080 Laptop, cc 8.6, ldd: libc, libm, libgcc_s), not run against a model here.

Final build, tree 73e77f8 (= claude/port-gpu-bringup head 4f7c461-era merge + this branch; the Codex jobs 943b / 945 ran the earlier build listed second):

binary sm_120 bytes sm_120 sha256 sm86 bytes sm86 sha256
leleka-inference 69,249,120 0eb83374e9782ded5c2d8d62d2552b4efd8c37142ea62d3d2309f9fcfe40eb26 120,106,704 30e08783873e7dc952020a8f93cf9232ef7ccb4c7f07ed5a18fbb8b81e6f0a2d
leleka-daemon 23,340,736 f7908fc6f4d5924bb9b3ebbd1ef7e7158fcc8bdde72d5efe515a896973b17cbb 23,340,024 a73a1c0e8ecc7241436a81c2da85fa9b8ce6369712a7fbc1ad87a75e2ed1a63d
leleka-cli 10,462,568 19bf908a56e900677b46488a11c1860cc7e524a1d9615b72a1effa712b5f2d3b 10,462,472 8c44891388e859e8c1525bfa0fc8b8df10e3d24b73950470b0620f3bdb7b7f2c
strata-next 28,834,064 ce98d23fd4e9efcbd3c46ca322641c1cbec8b3af142762866467143b3533b9b7 28,834,048 2fa5573f1c2062e50e6e9e8c6e0a4af704906222ba3ef6f92efacc6f9721d0f2
leleka (deploy supervisor, not copied) 2,938,592 b2be6e21e19975387141f314ecc92c681bb8a91e48338b102ca432d96a87d053 2,938,592 same
leleka-runtime-tests (replay smoke, server: leleka-runtime-tests-73e77f8) 79,533,344 4d0b400d951f0f485a5b31c66c8952669b11a64323dc46896b937b4a1a49a321

Binaries of the Codex jobs 943b / 945 and the replay job 947 (the server copies in bin-sm120/): leleka-inference 484b7622274ec80cab5357dd304de41c5a311163161a5daf7e4771fe8f1c4eae, leleka-daemon 8d681a3a3a88d5b354481766998fc5a72780e8d0e942c57e3280baaecdd8d0bd, leleka-cli 8615325793196b3740a584916e70b09bedaa5c16a3e1d03ba955cae5749bbd0c, strata-next ac0bfa40215844148785680697c693c01616c7ec0bcb34f65e3623af849c0768, leleka-runtime-tests a4dfb8530b76a19e7114c64ee0ebf1062d9a52d533cb46310fd31a4d73bbfc2e. Cargo unifies features per build, so byte identity of strata-next / leleka-daemon between the sm_120 and sm86 builds is not expected. The leleka supervisor (native sealed memfd) is not used by these jobs: inside a holder job a second 55 GB memfd would not fit, so scripts/e2e/run-e2e.sh starts the same processes with the holder's descriptor (--kar-archive-fd $LELEKA_STRA169_KAR_FD), the flags of deploy/rust-runtime/profiles/rtx5090-32g.json (--gpu-budget 25769803776, --context-tokens 262144, resident expert source) and the bring-up expert-tier environment of the 98x jobs.

2. How to rerun

# on the laptop: build (WSL), copy the four binaries and scripts/e2e to rnr5090:~/work/leleka-e2e/ (see section 1)
# on the server: drop a holder job, e.g. ~/work/gpu-runs/holder2/jobs/942-e2e-full.sh (template: section 8)
E2E_BIN=$HOME/work/leleka-e2e/bin-sm120 E2E_OUT=$HOME/work/leleka-e2e/runs/NAME \
E2E_CLIENT_ARGS="--soak-n 40 --burst 20 --xlong-tokens 24000" bash ~/work/leleka-e2e/scripts/e2e/run-e2e.sh

run-e2e.sh refuses to start unless it inherited a sealed memfd and MODEL.lock exists, nothing else holds the GPU and no stack process is running; it generates the two service tokens and the API key into mode-0600 files (never printed), extracts the tokenizer assets, starts leleka-inference, leleka-daemon, runs leleka-cli load-mtp and fails fast on a leleka-load phase= line, starts strata-next, waits for /ready, runs scripts/e2e/e2e_client.py (or E2E_RUN_CMD, used by the Codex jobs), samples RSS/VRAM every 30 s (env.tsv), then stops with SIGINT and reports left-over processes and GPU applications. Logs and results.json are written under E2E_OUT (inference.log, strata-next.log, daemon.log, client.log, results.json, env.tsv); they stay out of Git. scripts/e2e/run-fake.sh + fake_llm_engine.py run the identical client against a scripted engine without GPU (465 checks pass); that is how the client's own checks were debugged.

3. Runs

job what result
940 first stack start load failed: new_original_prompt_arena: InputRead (defect 1); job aborted by me after 10 min (the runner then had no fail-fast)
941 after fix 1, LELEKA_BRINGUP_TRACE=1 load 390 s, all scenarios ran in 2 min, 11 checks failed (tool-call format of the model, test expectations, defects 3-5)
942 after fixes 3-6, soak 40, burst 20, xlong 24k load 371 s, 13 scenarios, 459 checks, 9 failed, 0 errors; all 9 are the model's malformed tool calls (section 5); no leaked process, GPU back to 2 MiB
946 queued: long scenario with tools off pending in the serial queue when this was written (section 9)

4. Results (job 942 unless noted; sm_120, --backend-mode original, prompt cache on (6), expert tier 2048 slots, adaptive)

Model load through leleka-cli load-mtp: 371 s (942), 390 s (941). After load: leleka-inference RSS 53.6 GB (49.6 anon + 3.8 shmem), VRAM 13.2 GB, host MemAvailable 14.3 GB (the sealed memfd holds 52 GB of shmem outside the process RSS).

scenario checks measured
endpoints (/health unauthenticated, /ready, /status, /metrics, /v1/models[/id], /api/health, /admin/lifecycle, 401 without or with a wrong key, 404 stored id) 12/12 all as specified; /status answers in < 2 s while a generation runs
simple (Codex-shaped: instructions + developer + environment + user items, 4 function tools, reasoning, include, text.verbosity, prompt_cache_key) 37/37 980-token prompt: TTFT 2.95 s first request (cold, graph capture), 0.36 s when repeated (973 reused); max_output_tokens: 24 -> response.incomplete, max_output_tokens, output_tokens == 24; /v1/responses/input_tokens equals usage.input_tokens exactly (tokenizer agreement with the engine; no the engine counted N input tokens, the control plane M line in any log)
tools (3 tools, stream + stateless replay of the output items and function_call_output) 99/102 all three first calls valid JSON, names declared, arguments schema-valid; continuation after the tool result produced prose (59 tok/s decode); turn 2 re-prefilled 170 / 88 / 108 of 1150 / 1070 / 1100 tokens (980-992 reused); the 3 failures: forced tool_choice, tool_choice: none (section 5)
multiturn (previous_response_id and full replay) 82/82 turn 2/3 of 329/358 prompt tokens: 294/322 reused, 35/36 re-prefilled, TTFT 0.69/0.72 s; replay path identical numbers; GET, input_items, DELETE, 404 after delete, continuing from a deleted id 404
long (8.5k tokens, tools declared) 28/34 the model answered with a malformed shell call 3 of 3 times -> response.failed (section 5); the cache numbers come from xlong, the tools-off rerun is job 946
xlong (23,331-token prompt) 25/25 prefill 18.0 s = 1,295 tok/s, one SSE : keep-alive comment during the prefill; follow-up turn: 23,324 reused, 53 re-prefilled, TTFT 0.88 s
cancel 42/42 disconnect mid-decode: engine idle again after 0.05 s, metrics.generation.cancelled +1, next request fine; disconnect during a 6,036-token prefill: idle after 1.6 s (cancel is polled per prefill chunk); re-sending the cancelled prompt re-prefills all 6,036 tokens (cached 0, TTFT 4.8 s)
parallel 35/35 the engine serves one generation at a time: B (stream) and C (JSON) sent while A (420 tokens, 5.3 s) ran were queued (/metrics: active=true, queue_used=2, queue_capacity=16), answered correctly in order, B's first text 1.26 s after A ended; a burst of 20 simultaneous requests gave 17 x 200 and 3 x 429 runtime_overloaded with Retry-After (max_in_flight_requests 17), all admitted ones completed (21.7 s)
invalid (24 bad requests) 52/52 400 with error.{message,type,code,param} for malformed JSON, missing/empty/mistyped fields, unknown field, zero/negative/above-cap max_output_tokens, sampling out of range, bad tool (no name, bad name, duplicate, undeclared tool_choice, hosted), image, reasoning_budget_tokens, bad effort, json_schema without schema, context overflow; 404 for unknown model and previous_response_id; no half-open SSE for an invalid streaming request
compat (Chat Completions, Messages, tool call over Chat) 3/3
determinism 2/2 greedy x3 identical; the seeded sampled pair matched in 942 and differed in 941 (C++ vs C): documented envelope of the adaptive expert tier (original-serve.md), recorded as a note, not a failure
reasoning (Codex default effort: medium, summary: auto) 26/26 reasoning item + message, reasoning_tokens 14 of 19, replay of the reasoning item accepted (981 of 1027 reused)
soak (40 consecutive requests, alternate stream/JSON, every 4th a tool call) 7/7 all 40 ok (10 tool calls schema-valid), latency 1.69 / 1.87 / 2.09 s (min/p50/max), decode 60.7 tok/s mean; leleka-inference RSS +0 MiB, strata-next +0, daemon +0, VRAM +0 MiB after warm-up; /metrics delta started 40 = completed 40

Whole job 942: 98 generations seen by strata-next (log line generation done:), 145,787 prompt tokens of which 30,878 reused (21 %; the low share comes from the soak and invalid-input requests, whose ~980-token system prefix is below the cache's --prompt-cache-root 2048 threshold and therefore never reused across unrelated prompts), TTFT median 1.63 s (p90 1.68 s, max 18.0 s), decode median 68.4 tok/s per request (10th-90th percentile 48.9-89.0), sum-weighted 68.5 tok/s over 1,791 tokens. Memory over the job (7 samples): inference VmRSS 53,611 -> 54,347 MiB (+0.7 GB while the 24k prompt was served, flat in the soak), VRAM 13,192 -> 13,424 MiB, MemAvailable 14.3 -> 13.5 GB, no growth trend.

Teardown (every job): SIGINT to strata-next, daemon, engine: all exited, pgrep empty, no GPU compute applications, free -m back to avail 68.8 GB; the one forced abort (job 940) also left nothing behind.

5. Findings

Defects fixed on this branch (each with a test)

# defect repro fix
1 leleka-inference --backend-mode original could not load: MoeWeightCache::new_original_prompt_arena: InputRead (the retained routed-expert bank was never admitted on the Original path; only the serve smoke did it) job 940 9b56aec; the integrated branch carried an equivalent fix (`--expert-source resident
2 at most 256 generations per runtime epoch, then every request failed with generation_capacity until the engine was restarted and loaded again (RuntimeServer request ledger and the engine Proxy.seen) api_over_runtime::documents_the_256_generations_per_runtime_epoch_limit (old test) b4d12bd: leleka_backend_api::RecentIds, a FIFO window of the 16,384 most recent ids; test serves_more_than_256_generations_in_one_runtime_epoch (300 requests) + 4 unit tests + the rewritten RPC test
3 client errors surfaced as server errors: a context overflow or max_output_tokens above the runtime cap was queued and refused by the worker as 502 generation_failed (SSE: response.failed after a 200) invalid[...] rows of job 941 f5925f3: 400 context_length_exceeded / invalid_output_limit before queueing; tests a_prompt_that_cannot_fit_the_context_is_a_400..., the_runtimes_output_cap_...
4 the default output budget (context - prompt) ignored the engine's 8-token margin, so a prompt close to the context failed at the worker same f5925f3 (default leaves the margin)
5 reasoning_budget_tokens, strata_tune, experimental_speed_projection and sampling finer than the fixed point were 502 after queueing invalid[reasoning_budget_tokens] = 502 in job 941 af3beab: 400 unsupported_request_field / invalid_sampling_precision for a text-level engine; test text_the_contract_cannot_carry_is_refused_not_dropped
6 no operator-visible trace of why a generation failed or how a request went strata-next.log had one line af3beab, da187a9: generation failed: <client-visible message> and one generation done: finish= prompt_tokens= reused= generated= prompt_ms= decode_ms= line per request; STRATA_DEBUG_FAILED_OUTPUT=1 additionally logs the generated text of a failed tool turn (operator debugging only)

All of cargo test -p strata-control (274 lib + integration, 28 in backend_worker_http), -p strata-desktop-core, -p leleka-runtime-client, -p leleka-backend-api and the 10 runtime-stack HTTP smokes (scripts/test-api-over-runtime.py) pass on Linux after these changes.

Model-origin tool-call failures (not fixed, repro below)

Every failed generation of job 942 (4 of 98) was a malformed tool call produced by the model, correctly refused by the server (the full stream is response.failed with the message; nothing partial is published as a call):

  • <function=shell> with <command>["ls"]</command> instead of <parameter=command> -> tool call has an invalid parameter or is incomplete (forced-choice test).
  • shell with command a plain string (ls /workspace/leleka, grep -rn "tools" ... | head -50) where Codex's schema wants an array of strings -> function call arguments violate schema: "..." is not of type "array" (3 of 3 attempts in the 8.5k-token long scenario; the same tool with a short context was called correctly 5 of 5 times in tools and the soak).
  • forced tool_choice to update_plan: the model called another tool -> generated tool does not match forced tool choice; there is no constrained decoding anywhere in the stack, so forcing is only validated afterwards.

This is the quality risk for a real Codex session (the model may emit the string form of shell.command once the context grows). The stack has no repair step: a daemon-side "one regeneration on invalid output" exists only in leleka-daemon's experimental tool adapter. Candidate fixes (not implemented, need the quality gate of AGENTS.md): schema-driven constrained decoding for tool arguments, or a bounded retry in backend_worker.

Observations for other workstreams

  • Prefix reuse works across turns of one conversation (294/329, 322/358 tokens; 23,324 of 23,377 on the 24k prompt; engine reused= agrees) and across a stateless replay. It does not help unrelated requests that share a ~1k-token system prefix (root checkpoint needs 2048 tokens), nor a re-sent prompt whose first attempt was cancelled in prefill.
  • Cancel during prefill takes up to one prefill chunk (1.6 s here, chunk 2048).
  • MemAvailable stays at 13-14 GB while serving (52 GB sealed memfd + 54 GB engine RSS on a 121 GB host): no headroom for a second large process.
  • A job costs 6 min of model load before the first request; the serial holder queue (stale per-pass snapshot) delayed every job of this branch by 1-4 hours.
  • The golden fixtures in control-plane/tests/fixtures/golden hold Python-server HTTP-surface and GEN line goldens produced with a fake engine, no model-generated tool calls, so model tool-call output could not be compared with the Original server through them; tool-call integrity is checked by parsing (JSON arguments, declared name, schema validation), by delta == done == item equality in the stream, and by the 216-case tool-policy smoke.

6. Contract checks (what is verified where)

requirement check result
tool-call JSON integrity every call: name in the declared set, arguments parses as an object, schema-valid, call_id present; streamed argument deltas == arguments.done == final item pass for all successful calls (3 + 1 forced-none excluded + 10 in soak + chat)
streaming event order first response.created, strictly increasing consecutive sequence_number, event: name == data.type, every added item done, exactly one terminal event and it is last, text deltas == output_text.done == final message pass for every stream of the runs (about 60 streams)
usage counts usage.total == input + output, input_tokens == /input_tokens endpoint, output_tokens == engine count (24 for a 24-token limit), cached_tokens == engine reused= pass
stop reasons stop -> completed; length -> incomplete + max_output_tokens; cancelled -> no terminal for the closed client, cancelled metric pass
cache reuse across turns usage.input_tokens_details.cached_tokens per turn, table above pass
cancel frees the engine /metrics active=false after 0.05 s (decode) / 1.6 s (prefill) pass
no leaked processes pgrep, nvidia-smi --query-compute-apps after every job none
memory stable over 40+ requests env.tsv, soak samples +0 MiB RSS, +0 MiB VRAM

7. The real Codex CLI (0.163.0) against the stack

Operator-approved downloads, made by the coordinator and verified: Codex CLI rust-v0.163.0 codex-x86_64-unknown-linux-musl (unpacked binary sha256 399ff69c431c066e40de318fba45c2b07f45a76b19939d247ee4828fc70c4215, codex --version = codex-cli 0.163.0), three.js 0.170.0 (three.module.min.js, sha256 08fd7545d13d2c7fb65ab691530a802dafefd638596501854f267d0fb13c39e7), and on the laptop Node 22.16 + Playwright 1.49.1 + Chromium 131 (the server has no node or browser: the agent verifies with Python only, and the six browser checks run afterwards on the laptop). Config: isolated CODEX_HOME, wire_api = "responses", approval_policy = "never", sandbox_mode = "workspace-write" (no network), effort medium, model_context_window = 262144, web_search = "disabled", key from a freshly generated test key in E2E_API_KEY. The engine ran with the shipped options (KAR PLE level 2, --backend-mode original, spec_min_p 0, expert tier 2048 slots adaptive, INT8 K+V 32768 resident cells), greedy (Codex sends no sampling and the config has no sampling block: the Original server's default too), profiling on (LELEKA_SERVE_PROFILE=1, LELEKA_BRINGUP_TRACE=1), engine capture on. Prompts: tic-tac-toe scripts/e2e/codex/prompt-threejs.txt sha256 f57248412f69b4a6a76aab00c2ff33ee3ce676849768f847d412c7e9e9d8a074 (own equivalent of the old private prompt, without the LeaseVibe part); CRM prompt-crm.txt sha256 2ab4d92db393334f1ac953086116cefb9744b522b98bfd4ea6efd7e02e319af9 (phase 1 build, phase 2 seven-item refactor-and-extend to make the agent read and edit many files).

What Codex needed from the stack, found before spending GPU time (a mock /v1/responses server, scripts/e2e/codex/mock_responses.py): its default request carries the hosted tool {"type":"web_search"} (refused with 400 by design, so web_search = "disabled" is part of the config, as scripts/install-qwen-native.py already does), a namespace tool multi_agent_v1 (10 KB, accepted), exec_command (a string cmd parameter, not the array command of the older shell tool: the "shell.command as a string" failure of section 5 cannot occur with this Codex), write_stdin, view_image, goal tools, parallel_tool_calls: true, a 17 KB developer message, include: [reasoning.encrypted_content]; about 9.3k tokens before the first user word. apply_patch is a shell command (apply_patch <<EOF), not a Lark custom tool. Nothing else had to be added to the Responses surface.

tic-tac-toe 943b (default conversation cache) CRM 945 (prefix cache --prefix-cache-mib auto)
first attempt job 943 ended after 4 min: defect 7 below none
outcome Codex exit 0 after 918 s, 51 requests, index.html 10,778 bytes sha256 8f3e24b0a3fc6018607b93b584cf8d1b2e29df4a330121fd5d65dbffea76aaff Codex exit 0 after 1,526 s, 84 requests, 2,391 lines of Python in 8 modules, 139 tests (green), README, CODE_REVIEW.md
functional verdict 6/6 shared browser checks (laptop, real mouse clicks, software GL): loads without page error, visible WebGL canvas, row win, moves blocked after the win, restart to empty board, draw; the agent's own check_game.py passed 64 checks acceptance script crm_acceptance.py 21/21 (server and laptop): CRUD, search, stage filter, notes, pipeline, 400/404, SET NULL on delete, its own unittest suite
Codex tokens (events) input 2,474,932 / cached 2,392,367 (96.7 %) / output 56,553 (reasoning 32,835) input 6,016,105 / cached 5,801,984 (96.4 %) / output 96,081
context reached 82,315 tokens 123,239 tokens (not the typical 180k)
weighted decode tok/s (tokens after the first / decode time) 71.7 (56,502 tokens / 788 s); per-request median 68.5 74.8 (95,997 tokens / 1,283 s); median 73.6
reference (earlier vanilla Strata, same host and task shape) native 115.7, KAR PLE 150.1-150.3 same
wall-time shares time to first text 12.1 % (111 s), decode 85.9 %, agent+tools between requests 2.0 % (18 s, of which commands 12 s), queue 0 14.9 % (228 s), 84.1 %, 1.0 % (15 s), 0
tokens per verify round (accepted drafts + 1) 2.92 (median 2.96) 3.36 (median 3.50)
expert entries per request: VRAM / PCIe / CPU 49 % / 23 % / 28 % (median) 43 % / 27 % / 30 %
decode tok/s by context (median) 66 (4-16k), 71 (16-48k), 67 (48-96k) 65 (4-16k), 79 (16-48k), 74 (48-96k), 68 (96k+)
re-prefilled tokens (total / per request) 82,565 of 2,474,932 / median about 1.1k 214,121 of 6,016,105 / median about 2.2k
ideal (only the new suffix re-read) 26.4k tokens: prefill about 24 s instead of 75 s 28.4k tokens: about 27 s instead of 202 s
engine prefill rate 388 (64-512 tokens) / 873 (512-2k) / 1,158 (2k-8k) tok/s 995 / 1,038 / 1,140 tok/s
memory engine RSS 53.6 -> 55.0 GB, VRAM 13.2 -> 13.6 GB, MemAvailable 14.4 -> 12.8 GB RSS 53.7 -> 60.4 GB, VRAM 13.3 -> 13.7 GB, MemAvailable 14.0 -> 7.4 GB (flat from about minute 10)
tool-call failures none at the API (0 generation failed); 5 of 53 commands exited non-zero (missing node, a malformed apply_patch heredoc, grep, a probe, git status), all handled by the agent none at the API; 2 of 60 commands exited 1: a malformed apply_patch ("must end with *** End Patch") that Codex returned to the model, which re-sent it correctly

Reading: a real agent session is dominated by decode (84-86 % of wall time). The engine reuses 96.5 % of the prompt, close to the 98-99 % of the vanilla runs, yet both sessions decode at 72-75 tok/s against 116-150 for the vanilla runs on the same host. Decode speed is flat from 4k to 123k of context, so the gap is not a context effect; what differs is the engine configuration (shipped spec_min_p 0, tier hits 43-49 % from VRAM) and the accepted drafts per round (2.9-3.4 tokens per verify round); suffix-draft share is not logged. The prefix cache (CRM) served 83 of 84 prompts from a stored checkpoint (hits=83 misses=1, 7.3 of a 7.5 GiB budget used, 23 evictions) but resumes at a 2048-token grid node, so every turn re-reads the partial block (about 2.2k tokens per turn against a roughly 340-token real suffix); the conversation cache of the tic-tac-toe run re-read about 1.1k per turn.

MemAvailable dips: the CRM session's 7.4 GB minimum is the prefix cache filling its auto budget (75 % of available minus 4 GiB at open = 7,476 MiB, used 7,330 MiB) plus 6.7 GB of engine RSS growth over the session; it stayed above the cache's 3 GiB insertion floor (4.4 GiB headroom at the minimum), the cache evicted inside its budget, nothing was shed and nothing failed. The memory-safety agent was given these numbers.

Defect 7 (fixed: output cap 4096 -> 32768). Job 943: at 14.3k context the model wrote the whole index.html in one tool call; the runtime facade cut every generation at 4,096 tokens (the Original server has no such cap: max_tokens 0 = the rest of the context). Codex saw response.failed ("tool parameter is incomplete"), reconnected twice with the identical request (greedy, same cut) and then turn.failed ("incomplete: max_output_tokens"), exit 1. The decoded captured tokens show a coherent design monologue followed by an unfinished HTML file, not a repetition loop. leleka_backend_api::MAX_OUTPUT_TOKENS = 32768 is now the single cap of RuntimeServer, the engine request check, strata-next's runtime default and the leleka-deploy generated config. Also fixed on the way: /v1/status always carried prefix_cache: null, which broke the http_surface golden after the prefix-cache merge.

Does Codex recover by itself? Tool-level errors: yes (a rejected apply_patch came back as a tool result and the model corrected it; failed commands were retried or worked around). A truncated generation: no (Codex re-sends the identical request twice, which is deterministic under greedy decoding, then fails the turn). The model-side shell.command-as-string failure of section 5 did not occur because this Codex has no such tool.

CUPTI hook. The tracer of claude/ledger (~/work/cupti-trace/libleleka_cupti_trace.so, trigger file ~/work/codex-e2e/cupti/cupti.trigger, helper scripts/e2e/cupti_trigger.sh) was injected into the engine of job 945 and stayed armed and idle (nobody fired a window during the 25-minute session); the 943b run had it off. Armed-idle overhead is therefore not measured separately.

Per-request data. docs/e2e-data/{943b,945}-trace.csv (one row per generation: prompt / reused / re-prefilled tokens, TTFT, decode tokens and tok/s, rounds, tokens per round, tier shares, prefix-cache resume, gap before the request and the command time inside it, RSS / VRAM / MemAvailable), *-analysis.txt (the session report of scripts/e2e/analyze_session.py: time shares, context growth, prefill cost against context, slowest requests with causes, ideal against actual) and *-env.tsv (10 s samples). Captures of the prompt and generated token ids for offline replay are private: rnr5090:~/work/codex-e2e/capture/{943b-codex-ttt,945-codex-crm}/.

Replay. Both sessions were captured by the engine (LELEKA_CAPTURE_DIR: prompt ids and generated ids of every completed request, plus sampling fields) and are replayable offline by the ignored test original_serve_replay_smoke (crates/engine-qwen35-cuda/src/backend_original_serve_replay.rs; greedy, recorded output length as the budget, one stack, requests in order, so the conversation or prefix cache behaves as in the live session). Job 947-e2e-replay.sh (template scripts/e2e/codex/jobs/) replays 943b with the conversation cache and 945 with LELEKA_REPLAY_PREFIX_MIB=auto; its logs go to rnr5090:~/work/leleka-e2e/runs/947-replay/{ttt,crm}.log (REPLAY #n ... per request, REPLAY SUMMARY weighted_decode_tok_s=...). It had not run when this was written: the serial queue was held by a long ledger job (9003, running more than three hours), so there is no replay number in this report; the live numbers above are the baseline to compare it with. The adaptive-spec and decode-parity agents were told where the corpora and the harness are.

7b. Reference-equivalent reruns (943c, 945c) and replay arms (948): queued, not run when this was written

The sessions above ran the shipped options, which are not the configuration of the reference runs (115.7 / ~150 tok/s: the Original with --spec 4 --spec-min-p 0.5, INT8 K+V with 32,768 resident cells, the automatic per-layer expert cache of about 9,971 slots). Differences found:

setting jobs 943b / 945 (shipped) reference / reruns 943c, 945c
expert cache LELEKA_ORIGINAL_SERVE_EXPERT_SLOTS=2048 (run-e2e default, 43-49 % of entries from VRAM) auto, per layer, profile of the 98x/990 jobs, --gpu-budget 30 GiB (as the 98x auto-cache jobs)
--spec-min-p not passed (engine default 0 = full window) 0.5
MTP draft vocabulary not bound: leleka-inference was started without --mtp-rt-dir, so rt_directory was None and the MTP chain step drafted over the full 248k-row head (about +0.18 ms per step, 3-4 steps per round; ledger agent) bound: --mtp-rt-dir /home/para/work/leleka/models/leleka-gates/assets/data/mtp-rt (draft_vocab.bin, 106,299 rows, the Original's)
MTP depth / seed / tier adaptation depth 4 (Original default), seed and adaptive tier at the head defaults same

Confirmed from the command lines in run-e2e.sh at the time: 943b and 945 had no --mtp-rt-dir. Changes made: run-e2e.sh now always passes --mtp-rt-dir $A/data/mtp-rt (E2E_NO_RT_DIR=1 reproduces the old behaviour); leleka-deploy generates --mtp-rt-dir <mtp pack> in the engine command (test server_engine_command_matches_the_documented_one updated) so leleka up binds the draft vocabulary; the replay test honours LELEKA_ORIGINAL_SERVE_RT_DIR. Jobs (all in jobs/PRIORITY below the adaptive-spec and ledger jobs): 943c-e2e-codex-ttt (conversation cache) and 945c-e2e-codex-crm (--prefix-cache-mib auto), both with auto slots, --spec-min-p 0.5, the draft vocabulary, the head build, CUPTI off; 948-e2e-replay-arms (first 30 requests of the 943b capture, four arms: 2048 / auto slots x spec_min_p 0 / 0.5, plus auto + 0.5 without the draft vocabulary, each with weighted decode tok/s, tokens per round and tier shares); 947-e2e-replay is the baseline replay of the full 943b and 945 captures with the shipped options. Results go to rnr5090:~/work/leleka-e2e/runs/{943c-codex-ttt,945c-codex-crm,947-replay,948-replay-arms}/; if the sessions reach 115+ tok/s the production profile (deploy/rust-runtime/profiles/rtx5090-32g.json) should carry: expert slots auto per layer with the shipped profile file, --spec-min-p 0.5, --gpu-budget as the 98x auto-cache jobs (30 GiB), and the draft vocabulary (done).

Result of the first reference-config attempt (jobs 943c / 945c) and the defect it exposed (defect 8, fixed). Both runs ended with Codex exit 1, but not because of Codex or its sandbox (the Rejected(... rm -f ...) line in codex.err of 945c is the Codex exec policy refusing one rm -f command; the agent carried on) and not because of model quality: the engine returned leleka-serve request failed: class=CudaExecution for every attempt of one request (Codex re-sent it twice, then failed the turn). 943c died on its very first request (9,358-token prompt), 945c on request 24 (71.7k-token prompt) after 23 good requests. The engine trace shows the same chain both times: draft ring open -> fallback reason: RegionTooSmall (a prompt whose tail is only a few tokens takes the scalar draft-KV fallback) -> scalar draft-kv matrix EmbeddingNorm: buffer is not the retained one -> InvalidProjectionShape -> CudaExecution. The fallback verifies that the retained scalar MTP weights are the very buffers of the pinned pack's MoE cache; with --mtp-rt-dir (the Original's draft vocabulary, the newly bound option) the retained weights come from the RT bank and are separate allocations, so the identity check could never pass. In the earlier runs (no --mtp-rt-dir) the same fallback completed (after scalar fallback -> Completed). Fix (fix(runtime): scalar draft-KV fallback checks its weights against the retained MTP owner): record_original_scalar_draft_kv now compares against RetainedOriginalMtpWeights::matrix (the owner the scalar weights were built from, for either source). It needs a GPU to be proven; jobs 943d and 945d (identical to 943c / 945c, new binaries) are at the top of jobs/PRIORITY.

What the 23 good requests of 945c already show (reference config: 8,419 auto-sized slots per layer, --spec-min-p 0.5, draft vocabulary, prefix cache, context 18k -> 69k): weighted decode 138.8 tok/s (55,857 tokens / 402.5 s; per-request median 131.6) against 74.8 for the same task with the shipped options, expert entries from VRAM 83 % (PCIe 7 %) against 43 %, tokens per verify round 3.21 against 3.36 (the speed-up comes from the tier and the shorter draft step, not from more accepted drafts), decode by context 110 (4-16k), 140 (16-48k), 125 tok/s (48-96k), ttft 1.2-2.9 s, 90.7 % of the prompt reused. That is inside the 115.7-150 reference band, so the 72-75 tok/s of the first sessions was a configuration difference: the production profile should carry expert slots auto per layer (with the shipped profile file), --spec-min-p 0.5, --gpu-budget 30 GiB and the draft vocabulary (already generated by leleka up). 943c produced no completed request (0 numbers).

7d. Reference-config sessions, complete runs (jobs 943d, 945d; binaries with the scalar draft-KV fix)

Config: expert cache auto (8,419 slots per layer, 20.9 GiB, profile of the 98x jobs), --spec-min-p 0.5, --mtp-rt-dir (106k-row draft vocabulary), MTP depth 4, INT8 K+V 32,768 cells, --gpu-budget 30 GiB, seed and adaptive tier at the head defaults, greedy; 943d with the default conversation cache, 945d with --prefix-cache-mib auto. Both Codex runs ended on their own (codex exit status 0: the agent declared the task done).

shipped options (943b / 945) reference config (943d / 945d)
tic-tac-toe: wall time, requests, context 918 s, 51, 82k 203 s, 20, 37k
tic-tac-toe: weighted decode tok/s 71.7 128.8 (20,291 tokens / 157.6 s; median 122.4)
tic-tac-toe: tokens per round / VRAM tier share / reuse 2.92 / 49 % / 96.7 % 2.78 / 84 % / 92.1 %
tic-tac-toe: time shares (first text / decode / agent idle) 12.1 / 85.9 / 2.0 % 20.6 / 78.0 / 1.4 %
tic-tac-toe: deliverable index.html 10,778 B, 6/6 browser checks index.html 9,226 B sha256 8b2f7122b0024b4b04d15695ef7c6d8bfcc7f882ccdd761ec47f3a7500bd66af, 6/6 browser checks (laptop)
CRM: wall time, requests, context 1,526 s, 84, 123k 871 s, 72, 121k
CRM: weighted decode tok/s 74.8 130.0 (89,651 tokens / 689.8 s; median 119.8)
CRM: decode median by context (4-16k / 16-48k / 48-96k / 96k+) 65 / 79 / 74 / 68 133 / 132 / 121 / 114
CRM: tokens per round / VRAM tier share / reuse 3.36 / 43 % / 96.4 % 3.06 / 81 % / 96.1 % (197k of 5.11M tokens re-prefilled; ideal 33k)
CRM: time shares (first text / decode / agent idle) 14.9 / 84.1 / 1.0 % 19.2 / 79.2 / 1.6 %
CRM: memory RSS 53.7 -> 60.4 GB, MemAvailable min 7.4 GB RSS 53.6 -> 59.4 GB, MemAvailable min 8.3 GB, VRAM 30.4 -> 30.8 GB of 31.8 GB
CRM: deliverable 21/21 acceptance, 139 tests acceptance fails (see below); its own 125 tests pass

Reading: the configuration, not the engine, was the gap. With the reference-equivalent options a real Codex session decodes at 129-130 tok/s weighted (reference: 115.7 native / ~150 KAR PLE; the vanilla runs had a different, longer-lived tier history, and one sample each carries no confidence interval), the tier serves 81-84 % of the expert entries from VRAM, and the decode rate degrades slowly with context (133 tok/s at 4-16k to 114 at 96k+). Tokens per round fell slightly (2.8-3.1 against 2.9-3.4), so the gain is the tier plus the shorter draft step. The prefix cache still re-reads about 2.7k tokens per turn (a 2048-token grid step plus the reply), six times the ideal suffix.

Why the sessions stopped, and what is left. Neither run died of an engine error any more (the scalar draft-KV fix works: both resumed past the fallback that killed 943c / 945c). The harness's client rc=9 of 943d is the runner's own code for "no node/Playwright on the server, browser checks not run" (the Codex exit was 0; the six checks were run on the laptop: 6/6); run-codex.sh no longer turns that into a failure. One generation failed in 945d (request 5): the model emitted a native-style call to a function named apply_patch, which is not a declared tool (Codex 0.163 exposes apply_patch as a shell command); strata-next refused it (undeclared function in tool call: apply_patch), Codex reconnected, and the retried request produced a valid call, so the session carried on (1 of 72 generations; a model-format error, the same class as section 5). The 945d CRM does not pass acceptance for a bug the model wrote: handlers.py defines CRMHandler.handle(self, method), which overrides socketserver.BaseRequestHandler.handle, so every real HTTP request raises TypeError: handle() missing 1 required positional argument: 'method' and the connection is dropped; the agent's 125 unit tests call the handlers in-process, never start a server, and passed, and its final message said both phases were green. This is a task-quality result of one greedy trajectory (the shipped-options run of the same prompt produced a working app); a different engine configuration changes numeric rounding and therefore the trajectory, and no engine fault was found in it. No rerun was made.

8. Job template

set -uo pipefail
export E2E_BIN=$HOME/work/leleka-e2e/bin-sm120 E2E_OUT=$HOME/work/leleka-e2e/runs/942-full
export E2E_CLIENT_ARGS="--soak-n 40 --burst 20 --xlong-tokens 24000"
rm -rf $E2E_OUT; sha256sum $E2E_BIN/*
bash $HOME/work/leleka-e2e/scripts/e2e/run-e2e.sh; echo "run-e2e rc=$?"

9. Open at the time of writing

  • Job 946 (E2E_SCENARIOS=long, tools off) did run later but is not analysed here; its row (8.5k-token turn-1 TTFT, suffix and shared-prefix reuse) is not in section 4. The 24k-token xlong scenario covers cache reuse.
  • Job 947 (replay of both Codex captures): queued, see section 7.
  • Codex runs at the typical 180k context, with the CUPTI tracer fired in a window, and with Qwen-style sampling instead of greedy.
  • Daemon-side items from delivery-gap-audit.md not exercised here: SIGTERM drain, engine restart/re-attach under load, leleka up.