Files
leleka/docs/experiments/codex-lossy-delta.md
T
2026-10-31 09:15:33 +01:00

94 lines
12 KiB
Markdown

# Codex lossy-vs-lossless delta study (vanilla Strata 0.2.6 and our port, RTX 5090)
Branch `claude/codex-lossy-delta` (from main `e1bd61f5`). Question of the owner: with the real Codex CLI on realistic tasks, how much worse is the
lossy mode (route tail skip) than the lossless one, for vanilla and for our port. The orchestrator judges the DELTA by re-reading the sessions:
"small" = the task still completes with less than 5 % extra agent rounds (rounds = model requests), "large" = 5 % or more extra rounds, or the
task fails where the lossless variant completes it. This page fixes the design; it contains no result. Numbers go to `runs/codex-lossy-delta/_index/`.
## 1. Variants (same machine `rnr5090`, RTX 5090, 256k context, same model files, Codex CLI 0.163.0 sha256 `399ff69c...c4215`)
| id | stack | setting | check before the first cell |
| --- | --- | --- | --- |
| V1 | vanilla Strata 0.2.6 (launcher `~/work/vanilla-strata/control`, engine 0.1.50 `ae49d5da...4776`, `launch --model iq3_s --context 256k --kv int8 --vision off --parallel 1 --tune skip`) | shipped defaults: `STRATA_ROUTE_TAIL_SKIP=7` ON by default, `STRATA_PREFILL_CPU_SHARE=auto` | engine.log has `STRATA_ROUTE_TAIL_SKIP=7 is ON (default)` (block.py stops the block otherwise) |
| V2 | same vanilla | `STRATA_ROUTE_TAIL_SKIP=0 STRATA_PREFILL_CPU_SHARE=0` (both lossy defaults off, recorded in `stack.json`) | no `is ON` line; no `CPU share` line |
| V3 | our port, binaries `bin-main` = main `e1bd61f5` built in WSL (sha256 in `bin-main/COMMIT.txt`), `rtx5090-32g` profile shape (expert slots auto, GPU budget 32,819,404,800, spec-min-p 0, prefix cache auto/reply/8192, chain kernels, prompt-routing seed OFF, MTP draft vocabulary, ranked upstream expert profile `8f59b4aa...`) | `LELEKA_ROUTE_TAIL_SKIP=7` (EXPERIMENTAL, changes the output) | engine log (first decode) has `EXPERIMENTAL route tail skip is ON` |
| V4 | same binaries and shape | skip off (main default) | no such line |
Vanilla runs untraced (no `STRATA_DECODE_TIMING`), ours with `LELEKA_SERVE_PROFILE=1` only (the per-request `expert tier ... route tail skip` line carries our skip counters). The ours shape is the one of the paired A/B jobs
(`decode/dt/jobs/speedtrain3-ab.sh`, `ours()`), run through the same `run-e2e.sh` as the earlier Codex jobs 943d/945d (copy in `run-e2e/`, state dir `codex-lossy-delta/w`).
Sampling: Codex sends none. Vanilla would then use the model card's sampling (thinking: T 1.0, top_p 0.95, top_k 20) and ours is greedy. The logging proxy therefore
injects `"temperature": 0` into every `/v1/responses` request for ALL variants (greedy on both; recorded per request in `proxy/rounds.jsonl` as `fwd_sampling`). The proxy also maps the model name Codex sees (`qwen-local`,
identical in every variant, so Codex builds identical requests) to the engine's own id. The adaptive expert tier and the prefix cache are not bit-exact run to run, so greedy does not mean reproducible (measured by the pilot).
## 2. What is captured, identically for the four stacks
`scripts/e2e/codex/delta/logproxy.py` sits between Codex and the Responses endpoint of either stack. Per cell it writes `proxy/rounds.jsonl` (one line per HTTP request: timings, sizes, sha256, usage, output item summary) and, gzip-ed, every request body exactly as Codex
sent it, the forwarded body when the proxy changed it, and every response body exactly as received (`rounds/NNNN.{req.json,fwd.json,resp.sse}.gz`). Beside it: Codex's own rollout
(`codex-home/sessions/**/rollout-*.jsonl`), `codex-events.jsonl` (`codex exec --json` with arrival times), `codex.err`, the engine-log slice of the cell (`engine-slice.log`), the final workspace, `acceptance.log`, `cell.json`. The block directory
`V?/_stack-<tag>/` holds `inference.log` or `engine.log`, `strata-next.log`, `stack.json` (versions, env, warm-up, skip-state check, uptime, boot id), `mon.csv` (GPU temperature, clocks, power every 10 s), `memsample.txt`.
`delta/index.py` renders every session into `transcript.md` (round by round: new tool outputs, reasoning, calls, messages) and builds `_index/{index.csv,rounds.csv,index.md}`.
Round = one POST `/responses` (counted by the proxy, retries and failed attempts included; completed and failed ones are listed separately). Codex's own tool-call count is in the index too.
## 3. Tasks (`scripts/e2e/codex/tasks/`, frozen with `MANIFEST.sha256`, read-only on the server)
| id | kind | what the agent does | acceptance (`accept.py`, exit 0 = done) | author's round estimate |
| --- | --- | --- | --- | --- |
| ttt | create | Three.js tic-tac-toe in one file (prompt of jobs 943*, unchanged) | STATIC checks on the server (file, relative import of the vendored three, WebGL renderer, raycaster, `#status`, `#restart`, win/draw logic, no network). The six real-click browser checks (`hidden/check_ttt.mjs`) need Node + Playwright, which the server lacks: run later over the stored workspaces and reported separately | 15-60 |
| crm | create | CRM web app, two phases (prompt of jobs 945*, unchanged) | 21 REST checks + the app's own tests (`hidden/crm_acceptance.py` on a copy) | 60-110 |
| fixbug-ledger | bugfix | 6 seeded bugs in a 12-module bookkeeping library, 133 tests, 13 fail | pristine tests untouched and green + 34 hidden behaviour tests | 15-40 |
| feature-query | feature | implement the `where` query language of `SPEC.md` for a small table store, CLI flag, tests, README | existing tests, ~250 hidden spec cases, the agent's >= 25 tests pass, README | 20-45 |
| refactor-shop | refactor | 8-step refactor of a 22-module legacy shop library by `REFACTOR.md`, 119 tests stay green | pristine tests (with the `Cust` rename) + 26 static and behaviour checks | 35-60 |
| debuglog-sched | debug | find the id-reuse bug of a job scheduler from a 4,730-line (417 KB) log, fix, regression test, `FINDINGS.md` | visible + regression tests, two hidden stress simulations (zero lost jobs), `FINDINGS.md` content | 20-50 |
| smoke-mini | bugfix | 2 bugs in a 120-line package; pipeline smoke only, not in the matrix | pristine tests + hidden cases | 6-14 |
Every task has an exact prompt (between the marker lines of `task.md`), a seed workspace (copied byte for byte, digest `SEEDTREE` in the manifest, checked by `cell.py` before Codex starts), an acceptance script that does not know the variant, hidden files that never enter the workspace, and a reference
solution used only by `tasks/selftest.py` (acceptance FAILS on the bare seed and PASSES on seed + reference; verified for all 7 on Python 3.9 and 3.12, and it never modifies the workspace). The reference solutions are NOT installed on the server. The workspace Codex works in lives in
`codex-lossy-delta/_active/ws`, away from earlier results, and is moved into the cell afterwards. The Codex sandbox is `workspace-write` without network (`approval_policy = never`), as in the earlier jobs; it can still read the file system, which is a residual risk shared by all variants.
The Rust-crate idea of the owner's list was replaced by Python (the server has no Rust toolchain and the agent could not build); `gcc`/`make` exist but no C task was written.
Limits, identical for all variants and cells: wall limit 2,400 s per cell, cap 150 model requests (the proxy answers 503 beyond it and the runner stops Codex; the cell is recorded as `round_cap`), Codex `model_reasoning_effort = medium`, `model_context_window = 262144`.
A cell that hits a limit counts as not completed, its rounds are the rounds it used.
## 4. Order, repeats and the stack life
One block = one stack start of one variant (model load: ours about 7-8 min, vanilla about 4-5 min) followed by several cells, so a cell does not pay a load. The engine therefore carries its expert-tier history and its prefix cache from one cell to the next
(Codex's first ~9k tokens are common to all tasks); this is identical for the four variants but means cells are not independent. The warm-up request before the first cell is the same for all.
Block order per repetition is a small balanced design that keeps the lossy/lossless pair of an engine adjacent and alternates which comes first: rep 1 V1 V2 V3 V4, rep 2 V2 V1 V4 V3, rep 3 V3 V4 V1 V2, rep 4 V4 V3 V2 V1; the task order inside a block rotates with the repetition.
Server drift (vanilla was 13.5-16 ms/round at uptime 11-13 h on 2026-10-29 and 10.1-11.7 ms/round after fresh boots) is recorded per block (`uptime_s_at_block`, `boot_id`, GPU clocks), not removed.
## 5. GPU-hour estimate and the cut
Per cell (lossless, 130 tok/s): ttt 4-15 min (943d: 203 s), crm 15-25 min (945d: 871 s), the four new tasks 6-20 min each (author estimates, unmeasured on this model). Per block: model load 5-8 min, shutdown 1 min, warm-up 1 min.
| design | blocks | cell time per block | total |
| --- | --- | --- | --- |
| full: 6 tasks x 3 repeats x 4 variants | 12 | 65-130 min | 14-27 GPU-h |
| pilot + smoke (queued first): smoke-mini x1 + fixbug-ledger x2 per variant | 4 | 20-30 min | about 2 GPU-h |
The full design exceeds the 10 h budget, so the matrix is cut AFTER the pilot, from measured cell times, by this rule: keep every task but give each cell the n that fits 8 GPU-h (pilot excluded): first drop CRM to n=1 per variant, then the long tasks to n=2, never below n=3 for the
short tasks (fixbug-ledger, ttt, feature-query) unless the pilot shows bit-identical repeats. What was cut is stated in the second report.
## 6. What delta the data can resolve
A 5 % difference of the mean round count is not resolvable with 2-3 repeats of agent sessions unless the sessions are reproducible. The index prints the measured run-to-run CV of the round count (same variant, same task) and the relative difference two cell means of n repeats can resolve
(`2.8 * CV * sqrt(2/n)`, two-sided alpha 0.05, power 0.8). With a CV of 25 % that is about 57 % at n=3 for one task, about 23 % when the six tasks are pooled; with sessions that repeat exactly the per-cell delta is exact but is a statement about one trajectory. The index therefore reports, for each task, the lossy
and lossless round counts of every repeat, the paired difference by repeat, the completion counts, and the first round where the lossy and lossless sessions differ (with transcript line numbers), so the orchestrator can read both the numbers and the sessions. No quality verdict is computed.
## 7. How to run and read
```sh
bash scripts/e2e/codex/delta/install.sh # laptop: freeze + check + install on the server (read-only), nothing is hard-deleted
# server: stub ~/work/gpu-runs/holder2/jobs/<name>.sh = `exec bash /data/leleka-e2e/codex-lossy-delta/delta/jobs/<name>.sh`, add <name> to jobs/PRIORITY
python3 -I ~/work/leleka/codex-lossy-delta/delta/index.py ~/work/leleka/runs/codex-lossy-delta # index.csv, rounds.csv, index.md, transcripts
```
Layout: `~/work/leleka/runs/codex-lossy-delta/<V1..V4>/<task>-r<k>/` (matrix cells), `_smoke/V?/...` (smoke), `V?/_stack-<tag>/` (stack logs), `_index/`. Incomplete cells are renamed `*.incomplete-<time>`, never deleted.
## 8. Execution record (2026-10-31)
Measured cell times were far below the pre-pilot estimate (fixbug-ledger 1.5-3 min, crm 5-20 min), so nothing was cut: 6 tasks x 3 repeats x 4 variants = 72 matrix cells, about 5.1 GPU-h for the three matrix jobs plus about 1 GPU-h of pilots (`_pilot0` superseded, `_smoke`, pilot2 = repeats 1-2 of fixbug-ledger).
Changes made after the first pilot, all recorded in git: fixed CODEX_HOME path while Codex runs and a fixed prompt `<current_date>` (the per-cell path made prompts differ, so the first pilot is not comparable), acceptance run from a writable copy of the task files (the read-only install broke refactor-shop and feature-query
verdicts; every stored cell was re-accepted with `delta/reaccept.py`, previous logs kept as `acceptance.log.prev`). Index: `runs/codex-lossy-delta/_index/{index.md,index.csv,rounds.csv}`, transcripts in each cell directory.