diff --git a/docs/experiments/codex-compare-speed-gap.md b/docs/experiments/codex-compare-speed-gap.md index d55479a5..04bd6891 100644 --- a/docs/experiments/codex-compare-speed-gap.md +++ b/docs/experiments/codex-compare-speed-gap.md @@ -1,209 +1,209 @@ -# Codex compare: why Leleka decodes slower than vanilla Strata, and the ranked levers (RTX 5090, 2026-11-07) - -Branch `claude/speed-vs-strata-08143a`. Phase 1 = analysis of existing logs, **no new GPU run, no performance claim**. Phase 2 (measurements) is in section 6 once it has data. -Sources (server `/data/leleka-e2e/`): `codex-compare/runs/main/{LEL,VAN,VANL}/stack-r{1,2,3}/engine.log` (LEL: JSON `request` events of the engine; VAN/VANL: `strata serve: prompt ... generated ... drafts accepted a of b` lines), -`spd-gap/runs/main/{A,B,E,K*,KA*,KS*,P,T*,VANLP,VANL-noprof}` (replay of the recorded VANL `nestng-crm-r2` prompts), `docs/ledger.md`, `docs/roofline.md`, `docs/experiments/codex-compare-5090-results.md` (branch `claude/codex-compare`). -Arms: LEL = release package `leleka-0.1.0-17e372944279`, VANL = vanilla 0.2.6 with route tail skip and CPU prefill share off (reference), VAN = vanilla shipped defaults (both on). -Analysis scripts are not kept in Git (run over ssh from stdin; formulas below). - -## 1. Where the time goes (all requests with prompt > 200 tokens of the 9 `stack` logs per arm, ttt + nestng-crm together) - -Rounds of vanilla are estimated as `generated - drafts accepted` (one bonus token per window); LEL logs `rounds` itself. - -| metric | LEL | VANL (reference) | VAN | LEL vs VANL | -| --- | ---: | ---: | ---: | ---: | -| requests (3 stacks) | 531 | 246 | 271 | | -| decode tok/s (sum output / sum decode ms) | 177.5 | 217 | 238 | **-18 %** | -| tokens per round | 3.22-3.34 | 2.92-3.00 | 2.91-3.02 | **+12 %** (adaptive window) | -| ms per round | 18.1-18.8 | 13.5-13.9 | 12.3-12.5 | **+36 %** | -| prefill tok/s over uncached tokens | 930-1050 | 1460-1560 | 1320-1660 | -35 % | -| prefill share of request time | 9.5 % | 7.1 % | 7.3 % | +2.4 points | -| request time per output token, prefill + decode (ms) | 0.59 + 5.63 = 6.22 | 0.36 + 4.61 = 4.97 | 0.33 + 4.20 = 4.53 | gap 1.25 ms: **decode 82 %, prefill 18 %** | - -Reading: Leleka gets more tokens per round than vanilla (+12 %), but a round costs +5 ms. With vanilla's round time Leleka would be ~10 % *faster* than VANL. The whole gap is the time per round, plus a smaller prefill share. - -Prefill latency by size of the uncached part (median ms): the fixed cost per request is about +200-300 ms, and large reads are 2x slower. - -| uncached tokens | LEL | VANL | VAN | share of LEL requests | -| --- | ---: | ---: | ---: | ---: | -| < 64 | 430 | 268 | 210 | 19 % | -| 64-256 | 530 | 292 | 251 | 31 % | -| 256-1024 | 722 | 435 | 397 | 35 % | -| 1024-4096 | 1002 | 715 | 695 | 11 % | -| >= 4096 | 4405 | 2184 | 2044 | 4 % (19 % of LEL prefill time) | - -## 2. Same prompts replayed (spd-gap; `nestng-crm-r2` of VANL, first 30 requests, requests are identical across variants; dec_tps = output tokens / decode ms) - -| variant | what | dec tok/s | tok/round | ms/round | VRAM / PCIe / CPU % of routed | -| --- | --- | ---: | ---: | ---: | --- | -| VANL (vanilla, lossless) | `--spec 4 --spec-min-p 0.5` | **208.3** (2 runs equal) | 2.95 | 14.2 | hit 92.8 / 2.0 / 5.2 | -| A | ours shipped (adaptive window, floor 0) | 183.8 | 3.55 | 19.3 | 90.2 / 3.0 / 6.7 | -| B | ours with vanilla's window (fixed 4, floor 0.5) | 178.8 | 2.90 | 16.2 | 90.8 / 2.7 / 6.6 | -| E | A + our lossy tail skip | 206.7 | 3.58 | 17.3 | 93.7 / 1.7 / 4.6 | -| T45 | E, repeat | 205.8 | 3.59 | 17.4 | 94.0 / 1.6 / 4.4 | -| KAa | E + sm_120 `ATTN_DAILY` + `GU_SWIGLU` | 209.7 | 3.51 | 16.7 | 93.6 / 1.7 / 4.7 | - -Over requests 4-30 only (whole runs of 27 requests, n = 1-4 per variant, not a paired design): T45 family 207.8 / 210.1 / 213.3 / 209.0 (mean 210.1), K (all three sm_120 sets) 214.0 / 215.8 / 218.3 (216.0), KA 212.0 / 217.6 (214.8), KS (side mixer only) 208.3 / 210.5 (209.4), T30/T35/T40 (PCIe fraction) 204.0 / 206.8 / 207.2. -So: `ATTN_DAILY + GU_SWIGLU` ~ +2.3 %; the side mixer adds nothing; the PCIe fraction 0.45 is not worse than 0.30-0.40. Run-to-run spread inside one variant is +-1.5 %: these are indications, not A/B results. - -Step profile (`P` = ours with `LELEKA_SERVE_PROFILE=1`, vanilla `STRATA_DECODE_TIMING=1`; ms per window, GDN layers + QSA layers, 30 profile lines each): - -| step (ms/window) | ours, miss-heavy (lines 1, 2, 7, 8, 26) | vanilla, miss-heavy (lines 8, 9, 12, 22, 27) | ours, quiet (16, 17) | vanilla, quiet (17, 18) | -| --- | ---: | ---: | ---: | ---: | -| total per window | 21-26 | 16-17 | 12.0 | 10.7 | -| waitB (GDN + QSA) | 4.3-5.9 | 3.9-4.6 | 0.45 | 0.5 | -| **waitCPU (GDN + QSA)** | **3.1-4.0** | **0.4-1.3** | **0.8** | **0.2** | -| **PCIe group** | **0.6-0.9** | **0.3** | **0.4** | **0.1** | -| VRAM hits | 1.7-2.8 | 1.4-1.9 | 1.5 | 1.4 | - -The windows differ by 5-9 ms only in states with misses, and almost all of it is `waitCPU` + `PCIe group` (+2.5 ms of 21 in a miss-heavy window, +0.6 ms in a quiet one) and a hit rate that is lower in ours (90.2 % against 92.8 % of the routed experts). -Cache size: ours 12,192 expert slots (23.24 GiB), vanilla 12,575 (23.87 GiB, +3.1 %), vanilla leaves 389 MiB VRAM free (and warns); vanilla draft head over 106,299 tokens (212.9 MiB), ours the full 248,320-row head (ledger section 5). -Draft + commit outside the window: ours about 2.5 ms/round (`draft.finish` 1.7, `apply_pending` 0.6, commit 0.4), vanilla 1.2 (`draft` 1.17 in its timing line); ledger section 5 measured +1.5 ms/round. -The vanilla server drifts with uptime: 13.5-16 ms/round at 11-13 h, 10.1-11.7 after a fresh boot (`codex-lossy-delta.md`); every A/B must alternate inside one boot. - -## 3. Ranked levers - -Gain = estimated change of end-to-end tok/s on the Codex workload (contexts 30-120k), **E** = estimate from the numbers above, not measured as an A/B. Lossy = changes output; "placement-class" = changes which experts run on the GPU (GPU and CPU round differently), so output differs slightly without being a bug. - -| # | lever | expected gain | risk | class | evidence | -| --- | --- | ---: | --- | --- | --- | -| 1 | sm_120 sets `ATTN_DAILY` + `GU_SWIGLU` default on (the vanilla 0.1.50 defaults) | +2-3 % (E from KA vs T45: 214.8 vs 210.1) | low | non-lossy: byte-identical in the probe and 243-row replay | section 2 | -| 2 | Remove the CPU/PCIe wait of the miss leg (`waitCPU` + `PCIe group`: why is the CPU-expert result late: pool wake/hand-off, per-layer dispatch, split rule with `pcie_frac`, CPU kernel speed per expert) | +4-10 % (E: 1.0-3.1 ms of 19 ms/round; the quiet-state excess is already 0.6 ms) | medium (host threading) | non-lossy if the numerics of each expert stay (same device decides the rounding) | step profile | -| 3 | Fewer misses: slots 12,192 -> 12,575 (headroom policy), adaptive tier timing, draft-head VRAM | +2-6 % (E: miss rate 9.8 % -> 7.2 % removes up to a quarter of the miss leg) | medium: VRAM headroom (vanilla warns at 389 MiB), OOM/paging risk | placement-class (quality gate against control placement) | slots, hit rates | -| 4 | Per-round draft + commit overhead (merge small graphs, fewer launches, cheaper chain step: 0.68 vs 0.42 ms, `mtp_original_finite` guards) | +3-6 % (E: -1.3 ms of 19) | medium | non-lossy, bitwise (same kernels; draft vocabulary subset is a separate sub-lever, ledger: prompt-dependent -4 %..+19 %) | ledger 5, profile | -| 5 | Prefill fixed latency per request (+200-300 ms per small tail; vanilla reads <= 64 tokens through verify windows) and 2x slower large reads | +2-3 % (E: prefill share 9.5 % -> 7.1 %) | medium | tail through windows is a different kernel path: placement-class numerics; faster large chunks are bitwise | section 1 | -| 6 | Adaptive window policy: A vs B is +2.8 % net (+0.65 tokens per round for +3.1 ms); tune floor / ceiling (variants C, D of `spd_replay_job` never ran) | +1-3 % (E) | low | non-lossy (exact speculative decoding) | section 2 | -| 7 | Route tail skip (lossy): E vs A +12.5 % (206.7 vs 183.8), vanilla VAN vs VANL +9.7 % real | +10-12 %, shrinks lever 2 and 3 | quality: rounds growth unknown (codex-compare rounds CV 20-30 %) | **lossy, experimental, stays off** until the owner gate | section 2 | -| 8 | CPU prefill share (vanilla default, KL ~0.004) | ~0 (VAN prefill share 7.3 % vs VANL 7.1 %) | | lossy | section 1 - do not pursue | - -Total of the non-lossy levers 1, 2, 4, 5, 6 if additive: about +12-25 %; the gap to VANL is +22 % (217 / 177.5), to VAN +34 %. Lever 3 and 7 are the way past parity with vanilla's shipped defaults. -The levers interact: tail skip removes most of the miss leg, so lever 2 and 3 are measured with tail skip off (the default). - -## 4. Gates, per lever (AGENTS.md; nothing changes a default before its gate) - -| lever | A/B | quality / identity gate | -| --- | --- | --- | -| 1 | switch on/off, same boot | byte-identical outputs and R hashes on a **full** replay of a Codex session (all 56 requests of `nestng-crm-r2`, plus the earlier 243-row replay); then default on | -| 2 | switch on/off | per-step output identical on a frozen tier (`--adapt-every 0` and a frozen placement, because the adaptive tier is not reproducible run to run); a distribution comparison of the adaptive runs | -| 3 | slots / headroom / profile variants | placement-class gate: deviation against the control placement not worse than between two control placements (>= 1000 rows), zero OOM/paging in the 256k run, VRAM free >= the policy floor | -| 4 | switch on/off | greedy output and tensor identity (the kernels are the same); chain graph timing in the model-free probe first | -| 5 | switch on/off, tails of 1-64 / 64-256 tokens | R hash identity for the unchanged path; the window-tail path under the placement-class gate | -| 6 | variants of floor/ceiling on the same replay | identical greedy output (speculation is exact); tokens/round and ms/round reported | -| 7 | E against A on the replay + real Codex sessions | the **owner criterion**: rounds growth <= speed gain in %, game playable, CRM 56/56; stays experimental until it passes | - -## 5. Measurement protocol for phase 2 - -* Workload: the recorded VANL `nestng-crm-r2` requests (`proxy/rounds/NNNN.fwd.json.gz`) through `scripts/e2e/codex/compare/spd_replay_job.sh` (server copy `spd-gap/tools/spd_replay_job7.sh`), whole cell (56 requests); requests 1-3 are warm-up and dropped. -* Design: blocks of `leleka up` per variant, order A B B A A B ..., **n >= 10 blocks per variant** in one boot (uptime drift above), GPU lock and holder queue as for all jobs; the metric per block: dec tok/s, tok/round, ms/round, end-to-end tok/s (`otok / (pf + dec)`), tier %; paired difference per adjacent block pair with a 95 % CI. -* Record per run: GPU, driver, CUDA, host, model digest (`8f59b4aa...` profile, model files), binary sha256 and commit, the switches, cache state (prefix cache and expert tier start state: engine restarted per block, prefix cache empty at start), token counts and the distributions (per-request dec tok/s). -* Binary: lever 1 is a pure switch (`LELEKA_SM120_ATTN_DAILY`, `LELEKA_SM120_GU_SWIGLU`), so its paired A/B runs the same codex-compare release package on and off (sha256 in the job log); the default flip itself is a commit on the hexagonal head `e4993d151` and needs one confirmation block pair on that head. Levers that change code (2, 4, 5) are measured as head build against head build with the same switch off. -* Tools (this branch, `scripts/e2e/codex/speed/`): `spd_ab_job.sh` (holder job; variant names `NAME.BLOCK`, new variant `L`), `replay_hash.py` (adds `out_sha` per request), `ab_report.py RUN_DIR BASE VAR` (paired differences with 95 % t intervals and the identity count). Copies live in `/data/leleka-e2e/spd-gap/tools/`. - -## 6. Phase 2 results - -Not run yet: the GPU queue holds the hexagonal identity/A-B jobs (`hx-abg1` running, `hx-abc3..5`, `hx-id6`, `hx-abd1..5` behind it, ~30 min each) ahead of this program. -Queued at the end of `PRIORITY` (2026-11-07 18:30 UTC): `spd-l1a` (blocks 1-5) and `spd-l1b` (blocks 6-10) = lever 1, A (shipped lossless) against L (A + `ATTN_DAILY` + `GU_SWIGLU`), 10 blocks per arm, 30 requests of the recorded cell per block, ~12 min per block. -Read the result with `python3 -I - RUN_DIR A L < scripts/e2e/codex/speed/ab_report.py` on `/data/leleka-e2e/spd-gap/runs/ab-l1`. Smoke test of the report on three old block pairs (tail skip on, no hashes): L +1.9 % decode tok/s, CI -2.1..+6.0 % (n = 3, which is why n >= 10). -Entries are added below, one per lever, as each paired A/B finishes. - -### Lever 1, interim (blocks 1-5 of 10, `spd-l1a`; `spd-l1b` was running, so no final numbers yet) - -| metric | A | L | L - A (95 % CI) | -| --- | ---: | ---: | --- | -| decode tok/s | 187.10 | 190.05 | +1.6 % (-0.3..+3.4 %) | -| end-to-end tok/s | 170.18 | 169.67 | -0.3 % (-3.2..+2.6 %) | -| ms/round | 19.60 | 19.21 | -2.0 % (-6.6..+2.6 %) | - -n = 5 pairs: not significant, gain below the +2-3 % of the estimate. **Identity gate cannot use two boots**: `out_sha` is equal for only 2 of 30 requests even between two runs of the *same* arm (A.1 vs A.2, A.2 vs A.3; L.1 vs L.2: 3 of 30), because the adaptive tier / placement is not reproducible run to run (as `codex-lossy-delta.md` noted). So the byte-identity of lever 1 must be shown on a frozen placement (`--adapt-every 0`, static tier, one boot, switch toggled per request or two boots with the same frozen tier), not by this A/B; the A/B above is the speed record only. -Queue order (orchestrator request 2026-11-07): `hx-abg2..5` (cumulative refactor A/B) are on top of `PRIORITY`; the running `spd-l1b` was left to finish. - - -### Lever 1, final speed result (10 pairs, `spd-l1a` + `spd-l1b`, 2026-11-08) - -Release package `leleka-0.1.0-17e372944279-5090`, RTX 5090, VANL `nestng-crm-r2`, 30 requests per block (27 after the 3-request warm-up skip), engine restarted per block, order alternated, only the switch differs. - -| metric | A (shipped lossless) | L (+ ATTN_DAILY + GU_SWIGLU) | L - A (95 % CI) | -| --- | ---: | ---: | --- | -| decode tok/s | 186.58 | 190.03 | **+1.85 % (+0.97..+2.73 %)** | -| end-to-end tok/s | 168.87 | 170.07 | +0.71 % (-1.01..+2.44 %) | -| tokens/round | 3.66 | 3.63 | -0.66 % (-3.13..+1.82 %) | -| ms/round | 19.61 | 19.13 | -2.46 % (-4.47..-0.46 %) | -| VRAM % of routed | 90.37 | 90.34 | -0.03 % (-0.27..+0.21 %) | - -Decode gain is real and small (+1.85 %, CI excludes zero), inside the +2-3 % estimate's lower end; it does not reach the end-to-end number (prefill is untouched; CI crosses zero). The cross-boot `out_sha` identity is 22 of 300 and is **not** the gate (A against A is as low, adaptive tier and window). Default stays off until the frozen-placement gate passes: `spd-l1id` (variants `FA`/`FL` = tier swaps off + fixed window 4, with and without the two sets; `FA.1` vs `FA.2` is the A/A floor, then `FA.n` vs `FL.n` must be byte-identical), output `/data/leleka-e2e/spd-gap/runs/id-l1`, queued on top of `PRIORITY`. - -### Lever 1, identity gate: HTTP replay cannot decide, teacher-forced harness used (2026-11-08) - -`spd-l1id` (release package, `leleka up`, tier swaps off, fixed window 4, 30 requests, 4 boots FA.1 FL.1 FA.2 FL.2): `out_sha` equal for 10/30 (FA.1 vs FA.2), 10/30 (FL.1 vs FL.2), 11/30 (FA.1 vs FL.1), 9/30 (FA.2 vs FL.2). The A/A floor is as low as the A-vs-L pairs, so the live HTTP replay is not a deterministic probe even on a frozen tier and window (the remaining sources are not isolated: host-thread timing of the CPU/PCIe split, the persisted prefix-cache state between boots; the frozen tier also runs at 63 % VRAM hits, ~104 tok/s, so these four boots say nothing about speed). The gate is therefore the repository's teacher-forced harness (`scripts/e2e/decode/draftround-id.sh`, the 256k-class capture `night5-long-256k`, top-16 logprob rows, A/A floor inside each process): `spd-l1id2`, P1 = release kernels, P2 = P1 + `ATTN_DAILY` + `GU_SWIGLU`, test binary `rt-dr2`, output `/data/leleka-e2e/spd-gap/runs/id-l1-tf`. - -### Lever 1, verdict: default ON for the 5090 profiles (2026-11-08) - -`spd-l1id2` (teacher-forced, `rt-dr2`, five requests of `night5-long-256k` up to 243k prompt, 240 forced tokens each, `ADAPT=4`): reference process A/A floor 2057 of 2057 top-16 rows identical; P2 (`ATTN_DAILY` + `GU_SWIGLU`) against the reference, both arms: 2057 of 2057 identical, 0 argmax flips; draft trace 1036 of 1036 lines identical (**IDENTICAL**); `q_tail_gate` PASS in both processes. So the two sets are bitwise identical to the shipped kernels on this gate and the paired decode gain is +1.85 % (CI +0.97..+2.73 %), end-to-end +0.71 % (not significant). Caveats: the gate binary `rt-dr2` (draft-round `28d74a2ef`) is older than the release package `17e372944279`, and the live HTTP replay cannot serve as an identity probe (floor 10/30). The three 5090 profiles (`rtx5090-32g`, `-file`, `-gguf-ple`) now set `LELEKA_SM120_ATTN_DAILY=1` and `LELEKA_SM120_GU_SWIGLU=1`; the laptop profile (sm_86) does not; an operator's `engine_env` still wins. Rollback: set both to `0` in `engine_env`. - -Confirmation on the product tree (2026-11-08, jobs `spd-l1id4-c9`, `spd-l1id4-main`): the same teacher-forced gate on the hexagonal test binaries `rt-c9` (refactored product tree) and `rt-main` (its base). Both: A/A floor 2057 of 2057 top-16 rows identical, P2 (`ATTN_DAILY` + `GU_SWIGLU`) against the reference 2057 of 2057 in both arms, 0 argmax flips, draft trace 1036 of 1036 identical, `q_tail_gate` PASS. The release package itself cannot run the replay smoke (it is a lib test), and a test binary of exactly `17e372944279` does not exist on the server (not built: 41 GiB free on `/data`); the kernels are the same PTX. The server copy of `draftround-id.sh` hardcodes the binary directory, so these two jobs use the repository version (`D` override) installed as `spd-gap/tools/draftround-id.sh`. The decision to keep the sets on stands; the paired A/B of the release package (10 pairs above) is the switch these profiles now set, so no further A/B was run. - -### Levers 2 and 4: what the existing evidence says before any code (2026-11-08, no GPU run) - -* Vanilla and ours run the same CPU leg shape: 15 workers on logical processors 1-15, host on 0 (vanilla engine.log, ours `cpu_workers=15`), `LELEKA_POOL_TASKS_PER_THREAD` 2/4/6 within +-2 us per expert (`docs/experiments/cpu-service2-5090.md`), PCIe fraction 0.30-0.40 not better than 0.45 (section 2 above). -* The step-profile columns are not comparable one to one: vanilla books the CPU wait inside `waitB` (GDN layers waitB 4.87, waitCPU 0.22, PCIe group 0.36 = 5.45 ms/window) where ours splits it (waitB 3.74, waitCPU 2.36, PCIe group 0.57 = 6.67 ms/window). The wait group of the GDN layers is ~1.2 ms/window longer in ours, the QSA layers ~0.2 ms/window shorter in ours: a net ~1.0 ms of ~19 ms/window (~5 %), and it moves with the miss count (hit rate 90.2 % against 92.8 %, 12,192 against 12,575 slots), so lever 2 and lever 3 are one effect until a per-miss cost is measured. -* The fused verifier commit graph (`LELEKA_DRAFT_FUSED_COMMIT=on`, bitwise, `docs/experiments/draft-round-5090.md`) measured -0.024 +- 0.046 ms per round: neutral, not worth an A/B here. -* Consequence: a code change for lever 2 needs a per-miss timing (CPU compute against late start) from an instrumented build before it is worth an A/B; the cheap config knobs are already flat. Not started; the next measured lever is 7 (tail skip, experimental, lossy): `spd-l7a`/`spd-l7b` queued, 10 paired blocks A against E, speed and rounds growth only (the owner gate also needs real Codex sessions and CRM 56/56), output `/data/leleka-e2e/spd-gap/runs/ab-l7`. - -### Lever 7 (route tail skip, EXPERIMENTAL, lossy), interim: blocks 1-5 of 10 (`spd-l7a`; `spd-l7b` running), 2026-11-08 - -Release package `17e372944279`, same replay as lever 1, A (shipped) against E (`LELEKA_ROUTE_TAIL_SKIP=7`, `..._MAX_CACHED=100`), 27 requests per block after warm-up, order alternated. - -| metric | A | E | E - A (95 % CI) | -| --- | ---: | ---: | --- | -| decode tok/s | 185.84 | 210.30 | **+13.16 % (+11.80..+14.53 %)** | -| end-to-end tok/s | 168.49 | 186.95 | +10.95 % (+8.47..+13.44 %) | -| tokens/round | 3.59 | 3.79 | +5.45 % (+0.07..+10.83 %) | -| ms/round | 19.31 | 18.00 | -6.81 % (-10.67..-2.96 %) | -| VRAM % of routed | 90.42 | 93.89 | +3.48 % (+3.09..+4.59 %) | - -The gain is large and the CI is far from zero; rounds per token did not grow in this replay (tokens/round +5.5 %), but the replay sends recorded prompts, so the replies differ from E's own (the task trajectory is not followed) and this says nothing about the owner criterion on real sessions. The output is not identical (lossy by definition). **Stays off by default.** The owner gate (rounds growth <= speed gain in %, game playable, CRM 56/56) runs on real Codex sessions: `spd-g1..3` (the codex-compare ours arm with the two tail-skip variables exported, tasks `ttt` + `nestng-crm`, repetitions 1-3, output `/data/leleka-e2e/spd-gap/runs/codex-tail`), queued behind `spd-l7b`; compare with the shipped `LEL` and `VANL` runs of `codex-compare/runs/main`. - -### Lever 7, final speed result (10 pairs, `spd-l7a` + `spd-l7b`, 2026-11-08) - -Same replay and arms as the interim table (27 requests per block after warm-up, 10 block pairs, order alternated): decode tok/s A 186.40, E 209.81, **+12.56 % (95 % CI +11.50..+13.62 %)**; end-to-end +11.00 % (+9.75..+12.25 %); tokens/round 3.65 against 3.77 (+3.30 %, CI -0.21..+6.80 %, includes zero); ms/round 19.57 against 17.96 (-8.24 %, -10.71..-5.77 %); VRAM share of routed 90.32 -> 93.76 %. `out_sha` identical in 4 of 300 requests: it is a lossy mode, and the HTTP replay floor is about 10 of 30 anyway, so this number decides nothing. - -### Lever 7, owner gate on real Codex sessions (jobs `spd-g1..3`, 2026-11-08) - the table below used the OLD accept.py, see the correction after it - -Release package `17e372944279`, `LELEKA_ROUTE_TAIL_SKIP=7`, `LELEKA_ROUTE_TAIL_SKIP_MAX_CACHED=100`, real Codex CLI 0.163.0, temperature 0, three repetitions of `ttt` and `nestng-crm`, run by `cmp_codex_job.sh` on the 5090 (`/data/leleka-e2e/spd-gap/runs/codex-tail`, report `_compare/compare.md`). Baseline is the shipped LEL of `codex-compare/runs/main` (same tools, same Codex, same tasks). - -| task | arm | accepted | rounds (mean +- sd) | wall s | decode tok/s | -| --- | --- | --- | --- | ---: | ---: | -| nestng-crm | LEL shipped | 3/3 (56/56 each) | 54.0 +- 7.5 | 488.4 | 163.1 | -| nestng-crm | LEL + tail skip | **0/3 (55/56, 55/56, 54/56)** | 55.0 +- 17.4 | 468.3 | 183.2 | -| ttt | LEL shipped | 3/3 (14/14) | 17.7 (15, 22, 16) | 177.9 | 164.3 | -| ttt | LEL + tail skip | 3/3 (14/14) | 18.0 +- 7.0 | 155.5 | 184.6 | - -* Speed: decode tok/s +12.3 % (crm) and +12.4 % (ttt); the engine's own per-round view over the CRM requests is 17.4 ms/round against 19.4 (-10 %) at an equal 3.47 tokens/round. -* Rounds: CRM +1.9 % and ttt +1.7 % (both far inside the sd): the growth of rounds is below the speed gain (+12 %) in both tasks (greedy sessions are not reproducible run to run, n = 3). -* Game: `ttt` accepted 3/3. -* **CRM 56/56 is not met in any of the three runs.** The failing check is `frontend src: a board with one column per stage (all five stages and a loop)` in r1, r2 and r3 (`no file with all five stages and a loop`), plus one backend e2e test in r3 (`deals.e2e-spec.ts`, passed=41 failed=1). All nine baseline sessions (LEL, VAN, VANL, three each) passed 56/56. Three of three against zero of nine is not noise at this size; the lossy skip changes what the model writes on this task, and the gate in AGENTS.md ("do not enable lossy optimizations by default until their separate quality gate passes") is not passed. - -Verdict: the route tail skip stays **experimental and off by default**; no default or profile was changed for it. The logit gate (`q_tail_gate`, teacher-forced `night5-long-256k`, `rt-c10`) is queued as `spd-l7id` for the record; it cannot overturn the CRM failure above. - -### Lever 2 (waitCPU / PCIe), decision after re-reading `cpu-service2-5090.md` (2026-11-08, no new GPU run) - -The CPU leg already costs what vanilla's costs per expert: the server bench of the dispatch gives 41-51 us per CPU expert (15 workers, 54-57 GB/s of expert bytes, near this host's DRAM bandwidth) and vanilla's PcieAuto line reports 44 us; the host-callback stages are 0.06-1.08 ms/round each and already trimmed (eager admission +4.24 %, AVX2 `q8_k`); pool tasks per thread, PCIe share 0.45-0.65 and the fused commit graph are flat or neutral. What remains of the `waitCPU` + `PCIe group` excess (about 1 ms of ~19 ms per window) scales with the number of misses per window, i.e. it is lever 3 (hit rate 90.2 % against 92.8 %), not a separate host-side defect. A per-miss instrumented build would only re-split a quantity that the miss count already explains, so none is built. Lever 2 is closed with **no change**; the remaining miss-leg work moves to lever 3 (placement-class gate) and, lossy, lever 7. - -Queued next: lever 6 (`spd-l6a`, `spd-l6b`: D = adaptive window at floor 0.5 against shipped A, 10 block pairs, exact speculative decoding) and the lever 7 logit gate `spd-l7id`. - -#### Correction: the `spd-g1..3` cells were accepted by the pre-fix `accept.py` (2026-11-08) - -`cmp_codex_job.sh` ran the frozen `codex-compare/tasks/nestng-crm/accept.py` (sha256 `db1b7095...`), whose check "a board with one column per stage" needs the five stages and the loop in ONE file and failed in all nine baseline cells too (`codex-compare-5090-results.md`, Deviations 4); the baseline 56/56 come from the fixed `reaccept-1/tasks/nestng-crm/accept.py` (sha256 `b2e6c690...`). The 0/3 above therefore compared unlike checkers. Re-accepted offline with the fixed script (copy at `/data/leleka-e2e/spd-gap/runs/codex-tail-reaccept/accept-task`, logs `r1.log r2.log r3.log`, original cell logs untouched): - -| cell | fixed accept.py | detail | -| --- | --- | --- | -| nestng-crm r1 | **56/56** | board: `@for (stage of stages ...)` in `deals.component.html` | -| nestng-crm r2 | **56/56** | board: `@for (stage of stages ...)` in `deals-page.html` | -| nestng-crm r3 | 55/56 (reproduced 3 of 3 runs) | `backend tests: npm run test:e2e passes`: 41 of 42 pass | - -* The board is present in all three (a column per stage over the five stages, read in the sources), so the static failure was the checker artifact, not a model defect. -* r3: the failing test is the agent's OWN `deals.e2e-spec.ts:176` ("searches deals by title ... combines with stage"): it expects one deal for `?stage=won&q=software`, but its own fixture creates two won deals with "software" in the title ("Alpha software" and "Beta software"), so the API correctly returns two. Deterministic (3 of 3 reruns), a wrong assertion written by the model, not environment noise, and not a defect of the service. It still fails the acceptance rule "the agent's tests pass". The baselines have 0 such cases in 9 sessions; 1 in 3 with tail skip is a small-n signal, not proof (an own-test slip of this kind can occur without tail skip, and greedy sessions are not reproducible). -* Gate re-assessed: rounds growth below the speed gain (yes, +1.9 % / +1.7 % against +12 %); game playable (ttt 3/3, 14/14); CRM 56/56: **2 of 3** (r3 55/56 through its own wrong test). Not passed in full; with n = 3 per arm I do not call it a quality regression either. Tail skip stays experimental and off. To settle it, run 3 more repetitions of `nestng-crm` with the fixed `accept.py` (and the first three re-run under it); needs the owner's go on the cost (about 8 GPU-min each). +# Codex compare: why Leleka decodes slower than vanilla Strata, and the ranked levers (RTX 5090, 2026-11-07) + +Branch `claude/speed-vs-strata-08143a`. Phase 1 = analysis of existing logs, **no new GPU run, no performance claim**. Phase 2 (measurements) is in section 6 once it has data. +Sources (server `/data/leleka-e2e/`): `codex-compare/runs/main/{LEL,VAN,VANL}/stack-r{1,2,3}/engine.log` (LEL: JSON `request` events of the engine; VAN/VANL: `strata serve: prompt ... generated ... drafts accepted a of b` lines), +`spd-gap/runs/main/{A,B,E,K*,KA*,KS*,P,T*,VANLP,VANL-noprof}` (replay of the recorded VANL `nestng-crm-r2` prompts), `docs/ledger.md`, `docs/roofline.md`, `docs/experiments/codex-compare-5090-results.md` (branch `claude/codex-compare`). +Arms: LEL = release package `leleka-0.1.0-17e372944279`, VANL = vanilla 0.2.6 with route tail skip and CPU prefill share off (reference), VAN = vanilla shipped defaults (both on). +Analysis scripts are not kept in Git (run over ssh from stdin; formulas below). + +## 1. Where the time goes (all requests with prompt > 200 tokens of the 9 `stack` logs per arm, ttt + nestng-crm together) + +Rounds of vanilla are estimated as `generated - drafts accepted` (one bonus token per window); LEL logs `rounds` itself. + +| metric | LEL | VANL (reference) | VAN | LEL vs VANL | +| --- | ---: | ---: | ---: | ---: | +| requests (3 stacks) | 531 | 246 | 271 | | +| decode tok/s (sum output / sum decode ms) | 177.5 | 217 | 238 | **-18 %** | +| tokens per round | 3.22-3.34 | 2.92-3.00 | 2.91-3.02 | **+12 %** (adaptive window) | +| ms per round | 18.1-18.8 | 13.5-13.9 | 12.3-12.5 | **+36 %** | +| prefill tok/s over uncached tokens | 930-1050 | 1460-1560 | 1320-1660 | -35 % | +| prefill share of request time | 9.5 % | 7.1 % | 7.3 % | +2.4 points | +| request time per output token, prefill + decode (ms) | 0.59 + 5.63 = 6.22 | 0.36 + 4.61 = 4.97 | 0.33 + 4.20 = 4.53 | gap 1.25 ms: **decode 82 %, prefill 18 %** | + +Reading: Leleka gets more tokens per round than vanilla (+12 %), but a round costs +5 ms. With vanilla's round time Leleka would be ~10 % *faster* than VANL. The whole gap is the time per round, plus a smaller prefill share. + +Prefill latency by size of the uncached part (median ms): the fixed cost per request is about +200-300 ms, and large reads are 2x slower. + +| uncached tokens | LEL | VANL | VAN | share of LEL requests | +| --- | ---: | ---: | ---: | ---: | +| < 64 | 430 | 268 | 210 | 19 % | +| 64-256 | 530 | 292 | 251 | 31 % | +| 256-1024 | 722 | 435 | 397 | 35 % | +| 1024-4096 | 1002 | 715 | 695 | 11 % | +| >= 4096 | 4405 | 2184 | 2044 | 4 % (19 % of LEL prefill time) | + +## 2. Same prompts replayed (spd-gap; `nestng-crm-r2` of VANL, first 30 requests, requests are identical across variants; dec_tps = output tokens / decode ms) + +| variant | what | dec tok/s | tok/round | ms/round | VRAM / PCIe / CPU % of routed | +| --- | --- | ---: | ---: | ---: | --- | +| VANL (vanilla, lossless) | `--spec 4 --spec-min-p 0.5` | **208.3** (2 runs equal) | 2.95 | 14.2 | hit 92.8 / 2.0 / 5.2 | +| A | ours shipped (adaptive window, floor 0) | 183.8 | 3.55 | 19.3 | 90.2 / 3.0 / 6.7 | +| B | ours with vanilla's window (fixed 4, floor 0.5) | 178.8 | 2.90 | 16.2 | 90.8 / 2.7 / 6.6 | +| E | A + our lossy tail skip | 206.7 | 3.58 | 17.3 | 93.7 / 1.7 / 4.6 | +| T45 | E, repeat | 205.8 | 3.59 | 17.4 | 94.0 / 1.6 / 4.4 | +| KAa | E + sm_120 `ATTN_DAILY` + `GU_SWIGLU` | 209.7 | 3.51 | 16.7 | 93.6 / 1.7 / 4.7 | + +Over requests 4-30 only (whole runs of 27 requests, n = 1-4 per variant, not a paired design): T45 family 207.8 / 210.1 / 213.3 / 209.0 (mean 210.1), K (all three sm_120 sets) 214.0 / 215.8 / 218.3 (216.0), KA 212.0 / 217.6 (214.8), KS (side mixer only) 208.3 / 210.5 (209.4), T30/T35/T40 (PCIe fraction) 204.0 / 206.8 / 207.2. +So: `ATTN_DAILY + GU_SWIGLU` ~ +2.3 %; the side mixer adds nothing; the PCIe fraction 0.45 is not worse than 0.30-0.40. Run-to-run spread inside one variant is +-1.5 %: these are indications, not A/B results. + +Step profile (`P` = ours with `LELEKA_SERVE_PROFILE=1`, vanilla `STRATA_DECODE_TIMING=1`; ms per window, GDN layers + QSA layers, 30 profile lines each): + +| step (ms/window) | ours, miss-heavy (lines 1, 2, 7, 8, 26) | vanilla, miss-heavy (lines 8, 9, 12, 22, 27) | ours, quiet (16, 17) | vanilla, quiet (17, 18) | +| --- | ---: | ---: | ---: | ---: | +| total per window | 21-26 | 16-17 | 12.0 | 10.7 | +| waitB (GDN + QSA) | 4.3-5.9 | 3.9-4.6 | 0.45 | 0.5 | +| **waitCPU (GDN + QSA)** | **3.1-4.0** | **0.4-1.3** | **0.8** | **0.2** | +| **PCIe group** | **0.6-0.9** | **0.3** | **0.4** | **0.1** | +| VRAM hits | 1.7-2.8 | 1.4-1.9 | 1.5 | 1.4 | + +The windows differ by 5-9 ms only in states with misses, and almost all of it is `waitCPU` + `PCIe group` (+2.5 ms of 21 in a miss-heavy window, +0.6 ms in a quiet one) and a hit rate that is lower in ours (90.2 % against 92.8 % of the routed experts). +Cache size: ours 12,192 expert slots (23.24 GiB), vanilla 12,575 (23.87 GiB, +3.1 %), vanilla leaves 389 MiB VRAM free (and warns); vanilla draft head over 106,299 tokens (212.9 MiB), ours the full 248,320-row head (ledger section 5). +Draft + commit outside the window: ours about 2.5 ms/round (`draft.finish` 1.7, `apply_pending` 0.6, commit 0.4), vanilla 1.2 (`draft` 1.17 in its timing line); ledger section 5 measured +1.5 ms/round. +The vanilla server drifts with uptime: 13.5-16 ms/round at 11-13 h, 10.1-11.7 after a fresh boot (`codex-lossy-delta.md`); every A/B must alternate inside one boot. + +## 3. Ranked levers + +Gain = estimated change of end-to-end tok/s on the Codex workload (contexts 30-120k), **E** = estimate from the numbers above, not measured as an A/B. Lossy = changes output; "placement-class" = changes which experts run on the GPU (GPU and CPU round differently), so output differs slightly without being a bug. + +| # | lever | expected gain | risk | class | evidence | +| --- | --- | ---: | --- | --- | --- | +| 1 | sm_120 sets `ATTN_DAILY` + `GU_SWIGLU` default on (the vanilla 0.1.50 defaults) | +2-3 % (E from KA vs T45: 214.8 vs 210.1) | low | non-lossy: byte-identical in the probe and 243-row replay | section 2 | +| 2 | Remove the CPU/PCIe wait of the miss leg (`waitCPU` + `PCIe group`: why is the CPU-expert result late: pool wake/hand-off, per-layer dispatch, split rule with `pcie_frac`, CPU kernel speed per expert) | +4-10 % (E: 1.0-3.1 ms of 19 ms/round; the quiet-state excess is already 0.6 ms) | medium (host threading) | non-lossy if the numerics of each expert stay (same device decides the rounding) | step profile | +| 3 | Fewer misses: slots 12,192 -> 12,575 (headroom policy), adaptive tier timing, draft-head VRAM | +2-6 % (E: miss rate 9.8 % -> 7.2 % removes up to a quarter of the miss leg) | medium: VRAM headroom (vanilla warns at 389 MiB), OOM/paging risk | placement-class (quality gate against control placement) | slots, hit rates | +| 4 | Per-round draft + commit overhead (merge small graphs, fewer launches, cheaper chain step: 0.68 vs 0.42 ms, `mtp_original_finite` guards) | +3-6 % (E: -1.3 ms of 19) | medium | non-lossy, bitwise (same kernels; draft vocabulary subset is a separate sub-lever, ledger: prompt-dependent -4 %..+19 %) | ledger 5, profile | +| 5 | Prefill fixed latency per request (+200-300 ms per small tail; vanilla reads <= 64 tokens through verify windows) and 2x slower large reads | +2-3 % (E: prefill share 9.5 % -> 7.1 %) | medium | tail through windows is a different kernel path: placement-class numerics; faster large chunks are bitwise | section 1 | +| 6 | Adaptive window policy: A vs B is +2.8 % net (+0.65 tokens per round for +3.1 ms); tune floor / ceiling (variants C, D of `spd_replay_job` never ran) | +1-3 % (E) | low | non-lossy (exact speculative decoding) | section 2 | +| 7 | Route tail skip (lossy): E vs A +12.5 % (206.7 vs 183.8), vanilla VAN vs VANL +9.7 % real | +10-12 %, shrinks lever 2 and 3 | quality: rounds growth unknown (codex-compare rounds CV 20-30 %) | **lossy, experimental, stays off** until the owner gate | section 2 | +| 8 | CPU prefill share (vanilla default, KL ~0.004) | ~0 (VAN prefill share 7.3 % vs VANL 7.1 %) | | lossy | section 1 - do not pursue | + +Total of the non-lossy levers 1, 2, 4, 5, 6 if additive: about +12-25 %; the gap to VANL is +22 % (217 / 177.5), to VAN +34 %. Lever 3 and 7 are the way past parity with vanilla's shipped defaults. +The levers interact: tail skip removes most of the miss leg, so lever 2 and 3 are measured with tail skip off (the default). + +## 4. Gates, per lever (AGENTS.md; nothing changes a default before its gate) + +| lever | A/B | quality / identity gate | +| --- | --- | --- | +| 1 | switch on/off, same boot | byte-identical outputs and R hashes on a **full** replay of a Codex session (all 56 requests of `nestng-crm-r2`, plus the earlier 243-row replay); then default on | +| 2 | switch on/off | per-step output identical on a frozen tier (`--adapt-every 0` and a frozen placement, because the adaptive tier is not reproducible run to run); a distribution comparison of the adaptive runs | +| 3 | slots / headroom / profile variants | placement-class gate: deviation against the control placement not worse than between two control placements (>= 1000 rows), zero OOM/paging in the 256k run, VRAM free >= the policy floor | +| 4 | switch on/off | greedy output and tensor identity (the kernels are the same); chain graph timing in the model-free probe first | +| 5 | switch on/off, tails of 1-64 / 64-256 tokens | R hash identity for the unchanged path; the window-tail path under the placement-class gate | +| 6 | variants of floor/ceiling on the same replay | identical greedy output (speculation is exact); tokens/round and ms/round reported | +| 7 | E against A on the replay + real Codex sessions | the **owner criterion**: rounds growth <= speed gain in %, game playable, CRM 56/56; stays experimental until it passes | + +## 5. Measurement protocol for phase 2 + +* Workload: the recorded VANL `nestng-crm-r2` requests (`proxy/rounds/NNNN.fwd.json.gz`) through `scripts/e2e/codex/compare/spd_replay_job.sh` (server copy `spd-gap/tools/spd_replay_job7.sh`), whole cell (56 requests); requests 1-3 are warm-up and dropped. +* Design: blocks of `leleka up` per variant, order A B B A A B ..., **n >= 10 blocks per variant** in one boot (uptime drift above), GPU lock and holder queue as for all jobs; the metric per block: dec tok/s, tok/round, ms/round, end-to-end tok/s (`otok / (pf + dec)`), tier %; paired difference per adjacent block pair with a 95 % CI. +* Record per run: GPU, driver, CUDA, host, model digest (`8f59b4aa...` profile, model files), binary sha256 and commit, the switches, cache state (prefix cache and expert tier start state: engine restarted per block, prefix cache empty at start), token counts and the distributions (per-request dec tok/s). +* Binary: lever 1 is a pure switch (`LELEKA_SM120_ATTN_DAILY`, `LELEKA_SM120_GU_SWIGLU`), so its paired A/B runs the same codex-compare release package on and off (sha256 in the job log); the default flip itself is a commit on the hexagonal head `e4993d151` and needs one confirmation block pair on that head. Levers that change code (2, 4, 5) are measured as head build against head build with the same switch off. +* Tools (this branch, `scripts/e2e/codex/speed/`): `spd_ab_job.sh` (holder job; variant names `NAME.BLOCK`, new variant `L`), `replay_hash.py` (adds `out_sha` per request), `ab_report.py RUN_DIR BASE VAR` (paired differences with 95 % t intervals and the identity count). Copies live in `/data/leleka-e2e/spd-gap/tools/`. + +## 6. Phase 2 results + +Not run yet: the GPU queue holds the hexagonal identity/A-B jobs (`hx-abg1` running, `hx-abc3..5`, `hx-id6`, `hx-abd1..5` behind it, ~30 min each) ahead of this program. +Queued at the end of `PRIORITY` (2026-11-07 18:30 UTC): `spd-l1a` (blocks 1-5) and `spd-l1b` (blocks 6-10) = lever 1, A (shipped lossless) against L (A + `ATTN_DAILY` + `GU_SWIGLU`), 10 blocks per arm, 30 requests of the recorded cell per block, ~12 min per block. +Read the result with `python3 -I - RUN_DIR A L < scripts/e2e/codex/speed/ab_report.py` on `/data/leleka-e2e/spd-gap/runs/ab-l1`. Smoke test of the report on three old block pairs (tail skip on, no hashes): L +1.9 % decode tok/s, CI -2.1..+6.0 % (n = 3, which is why n >= 10). +Entries are added below, one per lever, as each paired A/B finishes. + +### Lever 1, interim (blocks 1-5 of 10, `spd-l1a`; `spd-l1b` was running, so no final numbers yet) + +| metric | A | L | L - A (95 % CI) | +| --- | ---: | ---: | --- | +| decode tok/s | 187.10 | 190.05 | +1.6 % (-0.3..+3.4 %) | +| end-to-end tok/s | 170.18 | 169.67 | -0.3 % (-3.2..+2.6 %) | +| ms/round | 19.60 | 19.21 | -2.0 % (-6.6..+2.6 %) | + +n = 5 pairs: not significant, gain below the +2-3 % of the estimate. **Identity gate cannot use two boots**: `out_sha` is equal for only 2 of 30 requests even between two runs of the *same* arm (A.1 vs A.2, A.2 vs A.3; L.1 vs L.2: 3 of 30), because the adaptive tier / placement is not reproducible run to run (as `codex-lossy-delta.md` noted). So the byte-identity of lever 1 must be shown on a frozen placement (`--adapt-every 0`, static tier, one boot, switch toggled per request or two boots with the same frozen tier), not by this A/B; the A/B above is the speed record only. +Queue order (orchestrator request 2026-11-07): `hx-abg2..5` (cumulative refactor A/B) are on top of `PRIORITY`; the running `spd-l1b` was left to finish. + + +### Lever 1, final speed result (10 pairs, `spd-l1a` + `spd-l1b`, 2026-11-08) + +Release package `leleka-0.1.0-17e372944279-5090`, RTX 5090, VANL `nestng-crm-r2`, 30 requests per block (27 after the 3-request warm-up skip), engine restarted per block, order alternated, only the switch differs. + +| metric | A (shipped lossless) | L (+ ATTN_DAILY + GU_SWIGLU) | L - A (95 % CI) | +| --- | ---: | ---: | --- | +| decode tok/s | 186.58 | 190.03 | **+1.85 % (+0.97..+2.73 %)** | +| end-to-end tok/s | 168.87 | 170.07 | +0.71 % (-1.01..+2.44 %) | +| tokens/round | 3.66 | 3.63 | -0.66 % (-3.13..+1.82 %) | +| ms/round | 19.61 | 19.13 | -2.46 % (-4.47..-0.46 %) | +| VRAM % of routed | 90.37 | 90.34 | -0.03 % (-0.27..+0.21 %) | + +Decode gain is real and small (+1.85 %, CI excludes zero), inside the +2-3 % estimate's lower end; it does not reach the end-to-end number (prefill is untouched; CI crosses zero). The cross-boot `out_sha` identity is 22 of 300 and is **not** the gate (A against A is as low, adaptive tier and window). Default stays off until the frozen-placement gate passes: `spd-l1id` (variants `FA`/`FL` = tier swaps off + fixed window 4, with and without the two sets; `FA.1` vs `FA.2` is the A/A floor, then `FA.n` vs `FL.n` must be byte-identical), output `/data/leleka-e2e/spd-gap/runs/id-l1`, queued on top of `PRIORITY`. + +### Lever 1, identity gate: HTTP replay cannot decide, teacher-forced harness used (2026-11-08) + +`spd-l1id` (release package, `leleka up`, tier swaps off, fixed window 4, 30 requests, 4 boots FA.1 FL.1 FA.2 FL.2): `out_sha` equal for 10/30 (FA.1 vs FA.2), 10/30 (FL.1 vs FL.2), 11/30 (FA.1 vs FL.1), 9/30 (FA.2 vs FL.2). The A/A floor is as low as the A-vs-L pairs, so the live HTTP replay is not a deterministic probe even on a frozen tier and window (the remaining sources are not isolated: host-thread timing of the CPU/PCIe split, the persisted prefix-cache state between boots; the frozen tier also runs at 63 % VRAM hits, ~104 tok/s, so these four boots say nothing about speed). The gate is therefore the repository's teacher-forced harness (`scripts/e2e/decode/draftround-id.sh`, the 256k-class capture `night5-long-256k`, top-16 logprob rows, A/A floor inside each process): `spd-l1id2`, P1 = release kernels, P2 = P1 + `ATTN_DAILY` + `GU_SWIGLU`, test binary `rt-dr2`, output `/data/leleka-e2e/spd-gap/runs/id-l1-tf`. + +### Lever 1, verdict: default ON for the 5090 profiles (2026-11-08) + +`spd-l1id2` (teacher-forced, `rt-dr2`, five requests of `night5-long-256k` up to 243k prompt, 240 forced tokens each, `ADAPT=4`): reference process A/A floor 2057 of 2057 top-16 rows identical; P2 (`ATTN_DAILY` + `GU_SWIGLU`) against the reference, both arms: 2057 of 2057 identical, 0 argmax flips; draft trace 1036 of 1036 lines identical (**IDENTICAL**); `q_tail_gate` PASS in both processes. So the two sets are bitwise identical to the shipped kernels on this gate and the paired decode gain is +1.85 % (CI +0.97..+2.73 %), end-to-end +0.71 % (not significant). Caveats: the gate binary `rt-dr2` (draft-round `28d74a2ef`) is older than the release package `17e372944279`, and the live HTTP replay cannot serve as an identity probe (floor 10/30). The three 5090 profiles (`rtx5090-32g`, `-file`, `-gguf-ple`) now set `LELEKA_SM120_ATTN_DAILY=1` and `LELEKA_SM120_GU_SWIGLU=1`; the laptop profile (sm_86) does not; an operator's `engine_env` still wins. Rollback: set both to `0` in `engine_env`. + +Confirmation on the product tree (2026-11-08, jobs `spd-l1id4-c9`, `spd-l1id4-main`): the same teacher-forced gate on the hexagonal test binaries `rt-c9` (refactored product tree) and `rt-main` (its base). Both: A/A floor 2057 of 2057 top-16 rows identical, P2 (`ATTN_DAILY` + `GU_SWIGLU`) against the reference 2057 of 2057 in both arms, 0 argmax flips, draft trace 1036 of 1036 identical, `q_tail_gate` PASS. The release package itself cannot run the replay smoke (it is a lib test), and a test binary of exactly `17e372944279` does not exist on the server (not built: 41 GiB free on `/data`); the kernels are the same PTX. The server copy of `draftround-id.sh` hardcodes the binary directory, so these two jobs use the repository version (`D` override) installed as `spd-gap/tools/draftround-id.sh`. The decision to keep the sets on stands; the paired A/B of the release package (10 pairs above) is the switch these profiles now set, so no further A/B was run. + +### Levers 2 and 4: what the existing evidence says before any code (2026-11-08, no GPU run) + +* Vanilla and ours run the same CPU leg shape: 15 workers on logical processors 1-15, host on 0 (vanilla engine.log, ours `cpu_workers=15`), `LELEKA_POOL_TASKS_PER_THREAD` 2/4/6 within +-2 us per expert (`docs/experiments/cpu-service2-5090.md`), PCIe fraction 0.30-0.40 not better than 0.45 (section 2 above). +* The step-profile columns are not comparable one to one: vanilla books the CPU wait inside `waitB` (GDN layers waitB 4.87, waitCPU 0.22, PCIe group 0.36 = 5.45 ms/window) where ours splits it (waitB 3.74, waitCPU 2.36, PCIe group 0.57 = 6.67 ms/window). The wait group of the GDN layers is ~1.2 ms/window longer in ours, the QSA layers ~0.2 ms/window shorter in ours: a net ~1.0 ms of ~19 ms/window (~5 %), and it moves with the miss count (hit rate 90.2 % against 92.8 %, 12,192 against 12,575 slots), so lever 2 and lever 3 are one effect until a per-miss cost is measured. +* The fused verifier commit graph (`LELEKA_DRAFT_FUSED_COMMIT=on`, bitwise, `docs/experiments/draft-round-5090.md`) measured -0.024 +- 0.046 ms per round: neutral, not worth an A/B here. +* Consequence: a code change for lever 2 needs a per-miss timing (CPU compute against late start) from an instrumented build before it is worth an A/B; the cheap config knobs are already flat. Not started; the next measured lever is 7 (tail skip, experimental, lossy): `spd-l7a`/`spd-l7b` queued, 10 paired blocks A against E, speed and rounds growth only (the owner gate also needs real Codex sessions and CRM 56/56), output `/data/leleka-e2e/spd-gap/runs/ab-l7`. + +### Lever 7 (route tail skip, EXPERIMENTAL, lossy), interim: blocks 1-5 of 10 (`spd-l7a`; `spd-l7b` running), 2026-11-08 + +Release package `17e372944279`, same replay as lever 1, A (shipped) against E (`LELEKA_ROUTE_TAIL_SKIP=7`, `..._MAX_CACHED=100`), 27 requests per block after warm-up, order alternated. + +| metric | A | E | E - A (95 % CI) | +| --- | ---: | ---: | --- | +| decode tok/s | 185.84 | 210.30 | **+13.16 % (+11.80..+14.53 %)** | +| end-to-end tok/s | 168.49 | 186.95 | +10.95 % (+8.47..+13.44 %) | +| tokens/round | 3.59 | 3.79 | +5.45 % (+0.07..+10.83 %) | +| ms/round | 19.31 | 18.00 | -6.81 % (-10.67..-2.96 %) | +| VRAM % of routed | 90.42 | 93.89 | +3.48 % (+3.09..+4.59 %) | + +The gain is large and the CI is far from zero; rounds per token did not grow in this replay (tokens/round +5.5 %), but the replay sends recorded prompts, so the replies differ from E's own (the task trajectory is not followed) and this says nothing about the owner criterion on real sessions. The output is not identical (lossy by definition). **Stays off by default.** The owner gate (rounds growth <= speed gain in %, game playable, CRM 56/56) runs on real Codex sessions: `spd-g1..3` (the codex-compare ours arm with the two tail-skip variables exported, tasks `ttt` + `nestng-crm`, repetitions 1-3, output `/data/leleka-e2e/spd-gap/runs/codex-tail`), queued behind `spd-l7b`; compare with the shipped `LEL` and `VANL` runs of `codex-compare/runs/main`. + +### Lever 7, final speed result (10 pairs, `spd-l7a` + `spd-l7b`, 2026-11-08) + +Same replay and arms as the interim table (27 requests per block after warm-up, 10 block pairs, order alternated): decode tok/s A 186.40, E 209.81, **+12.56 % (95 % CI +11.50..+13.62 %)**; end-to-end +11.00 % (+9.75..+12.25 %); tokens/round 3.65 against 3.77 (+3.30 %, CI -0.21..+6.80 %, includes zero); ms/round 19.57 against 17.96 (-8.24 %, -10.71..-5.77 %); VRAM share of routed 90.32 -> 93.76 %. `out_sha` identical in 4 of 300 requests: it is a lossy mode, and the HTTP replay floor is about 10 of 30 anyway, so this number decides nothing. + +### Lever 7, owner gate on real Codex sessions (jobs `spd-g1..3`, 2026-11-08) - the table below used the OLD accept.py, see the correction after it + +Release package `17e372944279`, `LELEKA_ROUTE_TAIL_SKIP=7`, `LELEKA_ROUTE_TAIL_SKIP_MAX_CACHED=100`, real Codex CLI 0.163.0, temperature 0, three repetitions of `ttt` and `nestng-crm`, run by `cmp_codex_job.sh` on the 5090 (`/data/leleka-e2e/spd-gap/runs/codex-tail`, report `_compare/compare.md`). Baseline is the shipped LEL of `codex-compare/runs/main` (same tools, same Codex, same tasks). + +| task | arm | accepted | rounds (mean +- sd) | wall s | decode tok/s | +| --- | --- | --- | --- | ---: | ---: | +| nestng-crm | LEL shipped | 3/3 (56/56 each) | 54.0 +- 7.5 | 488.4 | 163.1 | +| nestng-crm | LEL + tail skip | **0/3 (55/56, 55/56, 54/56)** | 55.0 +- 17.4 | 468.3 | 183.2 | +| ttt | LEL shipped | 3/3 (14/14) | 17.7 (15, 22, 16) | 177.9 | 164.3 | +| ttt | LEL + tail skip | 3/3 (14/14) | 18.0 +- 7.0 | 155.5 | 184.6 | + +* Speed: decode tok/s +12.3 % (crm) and +12.4 % (ttt); the engine's own per-round view over the CRM requests is 17.4 ms/round against 19.4 (-10 %) at an equal 3.47 tokens/round. +* Rounds: CRM +1.9 % and ttt +1.7 % (both far inside the sd): the growth of rounds is below the speed gain (+12 %) in both tasks (greedy sessions are not reproducible run to run, n = 3). +* Game: `ttt` accepted 3/3. +* **CRM 56/56 is not met in any of the three runs.** The failing check is `frontend src: a board with one column per stage (all five stages and a loop)` in r1, r2 and r3 (`no file with all five stages and a loop`), plus one backend e2e test in r3 (`deals.e2e-spec.ts`, passed=41 failed=1). All nine baseline sessions (LEL, VAN, VANL, three each) passed 56/56. Three of three against zero of nine is not noise at this size; the lossy skip changes what the model writes on this task, and the gate in AGENTS.md ("do not enable lossy optimizations by default until their separate quality gate passes") is not passed. + +Verdict: the route tail skip stays **experimental and off by default**; no default or profile was changed for it. The logit gate (`q_tail_gate`, teacher-forced `night5-long-256k`, `rt-c10`) is queued as `spd-l7id` for the record; it cannot overturn the CRM failure above. + +### Lever 2 (waitCPU / PCIe), decision after re-reading `cpu-service2-5090.md` (2026-11-08, no new GPU run) + +The CPU leg already costs what vanilla's costs per expert: the server bench of the dispatch gives 41-51 us per CPU expert (15 workers, 54-57 GB/s of expert bytes, near this host's DRAM bandwidth) and vanilla's PcieAuto line reports 44 us; the host-callback stages are 0.06-1.08 ms/round each and already trimmed (eager admission +4.24 %, AVX2 `q8_k`); pool tasks per thread, PCIe share 0.45-0.65 and the fused commit graph are flat or neutral. What remains of the `waitCPU` + `PCIe group` excess (about 1 ms of ~19 ms per window) scales with the number of misses per window, i.e. it is lever 3 (hit rate 90.2 % against 92.8 %), not a separate host-side defect. A per-miss instrumented build would only re-split a quantity that the miss count already explains, so none is built. Lever 2 is closed with **no change**; the remaining miss-leg work moves to lever 3 (placement-class gate) and, lossy, lever 7. + +Queued next: lever 6 (`spd-l6a`, `spd-l6b`: D = adaptive window at floor 0.5 against shipped A, 10 block pairs, exact speculative decoding) and the lever 7 logit gate `spd-l7id`. + +#### Correction: the `spd-g1..3` cells were accepted by the pre-fix `accept.py` (2026-11-08) + +`cmp_codex_job.sh` ran the frozen `codex-compare/tasks/nestng-crm/accept.py` (sha256 `db1b7095...`), whose check "a board with one column per stage" needs the five stages and the loop in ONE file and failed in all nine baseline cells too (`codex-compare-5090-results.md`, Deviations 4); the baseline 56/56 come from the fixed `reaccept-1/tasks/nestng-crm/accept.py` (sha256 `b2e6c690...`). The 0/3 above therefore compared unlike checkers. Re-accepted offline with the fixed script (copy at `/data/leleka-e2e/spd-gap/runs/codex-tail-reaccept/accept-task`, logs `r1.log r2.log r3.log`, original cell logs untouched): + +| cell | fixed accept.py | detail | +| --- | --- | --- | +| nestng-crm r1 | **56/56** | board: `@for (stage of stages ...)` in `deals.component.html` | +| nestng-crm r2 | **56/56** | board: `@for (stage of stages ...)` in `deals-page.html` | +| nestng-crm r3 | 55/56 (reproduced 3 of 3 runs) | `backend tests: npm run test:e2e passes`: 41 of 42 pass | + +* The board is present in all three (a column per stage over the five stages, read in the sources), so the static failure was the checker artifact, not a model defect. +* r3: the failing test is the agent's OWN `deals.e2e-spec.ts:176` ("searches deals by title ... combines with stage"): it expects one deal for `?stage=won&q=software`, but its own fixture creates two won deals with "software" in the title ("Alpha software" and "Beta software"), so the API correctly returns two. Deterministic (3 of 3 reruns), a wrong assertion written by the model, not environment noise, and not a defect of the service. It still fails the acceptance rule "the agent's tests pass". The baselines have 0 such cases in 9 sessions; 1 in 3 with tail skip is a small-n signal, not proof (an own-test slip of this kind can occur without tail skip, and greedy sessions are not reproducible). +* Gate re-assessed: rounds growth below the speed gain (yes, +1.9 % / +1.7 % against +12 %); game playable (ttt 3/3, 14/14); CRM 56/56: **2 of 3** (r3 55/56 through its own wrong test). Not passed in full; with n = 3 per arm I do not call it a quality regression either. Tail skip stays experimental and off. To settle it, run 3 more repetitions of `nestng-crm` with the fixed `accept.py` (and the first three re-run under it); needs the owner's go on the cost (about 8 GPU-min each). ### Lever 7, owner gate on n = 7 CRM and 5 ttt (`spd-g1..3` re-accepted + `spd-g4..g9`, fixed `accept.py` b2e6c690, 2026-11-08): NOT passed on rounds @@ -235,7 +235,7 @@ D (adaptive window with `spec_min_p` floor 0.5, `leleka reconfigure`) against sh ### Where the real-session gap goes, per request (existing cells only, no new run; `scripts/e2e/codex/speed/session_split.py`, 2026-11-08) -Source: `codex-compare/runs/main/{LEL,VANL,VAN}/{nestng-crm,ttt}-r1..3`. Proxy time per request (`proxy/rounds.jsonl`, `t_end - t_start`) joined by order with the engine's own prefill and decode milliseconds (the cell's `engine_log_start_offset` slice of the stack `engine.log`; join checked: request counts equal in all 18 cells per arm). Proxy "tok/s" = output tokens / proxy time = the `decode tok/s` of `compare.md`. +Source: `codex-compare/runs/main/{LEL,VANL,VAN}/{nestng-crm,ttt}-r1..3`. Proxy time per request (`proxy/rounds.jsonl`, `t_end - t_start`) joined by order with the engine's own prefill and decode milliseconds (the cell's `engine_log_start_offset` slice of the stack `engine.log`; join checked: request counts equal in all 6 cells per arm, 3 per task). Proxy "tok/s" = output tokens / proxy time = the `decode tok/s` of `compare.md`. | nestng-crm (3 cells per arm) | LEL | VANL | VAN | LEL - VANL | | --- | ---: | ---: | ---: | ---: |