diff --git a/docs/experiments/codex-compare-speed-gap.md b/docs/experiments/codex-compare-speed-gap.md index cd9af601..7fefe032 100644 --- a/docs/experiments/codex-compare-speed-gap.md +++ b/docs/experiments/codex-compare-speed-gap.md @@ -329,3 +329,11 @@ Per round and per group (48 groups per round), from `runs/main/P/engine.log` (30 * `draft.finish` follows the window width (0.93 ms at T 3.0, 2.5 ms at T 6.2): the chain has more steps in a wider window. It is not a per-round defect; the "+1.3 ms" is the width of the adaptive window, the same cost as the "+3.1 ms for +0.65 tokens" of the window price. * Same speculation, ours against vanilla (B 178.8 against VANL 208.3 tok/s at 2.90 against 2.95 tokens/round): +2.0 ms per round (+14 %). The largest identified part is the miss count: hit rate 90.8 % against 92.8 % (28 % more misses, about +1.4 ms of CPU leg). Per request, vanilla's hit rate is higher in nearly every request, by up to 7 points in short ones (request 12: 93.2 against 86.4 at 276 tokens; request 26: 87.6 against 78.4), i.e. mostly at the start of a request. * The tier policy is the same as the Original's (decay 0.7, margin 1.5, min count 2.0, `adapt_every` 4, 96 swaps, candidates and victims paired per layer; counts survive across requests; the lent slots are refilled with their own previous experts, so the prefill borrow does not lose learned placement). The differences left are +3 % slots (12,575 against 12,192), the window width and whatever the first rounds of a request see. `spd-w1..5` (tier knobs) and `spd-l3e/f` (slots) measure how much each of them moves the hit rate. + +### Real-session weighting of the hit-rate gap and the gap by context (owner rule 2026-11-08: weigh by time in the real session, ignore short-request-only gains) + +Tools: `scripts/e2e/codex/speed/session_hit.py` and `session_ctx_gap.py` (run on the server with `python3 -I`; read the `engine-slice.log` of the `runs/main/{LEL,VANL}` cells, three repetitions each). + +* **VRAM hit share weighted by decode time**: nestng-crm LEL 91.38 % against VANL 92.41 % (-1.03 points), ttt 92.68 % against 93.38 % (-0.70). By output length of the request (share of decode time in brackets), nestng-crm LEL/VANL: < 600 tokens (10 %/12 %) 86.9/89.9, 600-2000 (33 %/34 %) 90.5/91.6, >= 2000 (58 %/54 %) 92.7/93.5 (-0.9). The 3-8 point gaps of the replay are in the short requests, which carry 10 % of the decode time; in the long ones the gap is about 0.9 point. +* **Price of a point**: lever 7 raised the VRAM share by 3.5 points and took 2.0 ms off a round (19.3 -> 17.3) at equal tokens per round, so at most 0.57 ms per round per point (that figure also contains the skipped entries). One point of hit share is therefore at most 0.57 / 3.55 = 0.16 ms per output token: 2.6 % of nestng-crm's 6.14 ms request time per token (1.0 point), 1.8 % of ttt's (0.7 point). That is the ceiling for everything done about the hit rate together (tie order, tier knobs, slots). +* **Gap by context** (decode tok/s LEL against VANL, same cells): nestng-crm 0-30k -18.2 %, 30-60k -16.6 %, 60-100k -18.7 %, 100-160k -24.6 % (3 % of the time); ttt 0-30k -16.8 %, 30-60k -20.0 %. The sessions never pass 160k; the gap is flat in context, so there is no long-context hot spot in these two tasks (a 245k session is not in the cells). diff --git a/scripts/e2e/codex/speed/session_ctx_gap.py b/scripts/e2e/codex/speed/session_ctx_gap.py new file mode 100644 index 00000000..a7d51476 --- /dev/null +++ b/scripts/e2e/codex/speed/session_ctx_gap.py @@ -0,0 +1,28 @@ +import re,json,glob +root="/data/leleka-e2e/codex-compare/runs/main" +B=[(0,30000),(30000,60000),(60000,100000),(100000,160000),(160000,10**9)] +def cells(arm,task): return [c for c in sorted(glob.glob(f"{root}/{arm}/{task}-r*")) if not c.endswith(".out")] +def lel(c): + for l in open(c+"/engine-slice.log",errors="replace"): + if l.startswith("{") and '"ev":"request"' in l and '"comp":"engine"' in l: + j=json.loads(l); yield j["ptok"],j["otok"],j["dec_ms"],j["pf_ms"] +def van(c): + for l in open(c+"/engine-slice.log",errors="replace"): + m=re.search(r"prompt (\d+) tokens = (\d+) reused \+ (\d+) read in ([\d.]+) ms.*?(\d+) generated in ([\d.]+) ms",l) + if m: yield int(m.group(1)),int(m.group(5)),float(m.group(6)),float(m.group(4)) +for task in ("nestng-crm","ttt"): + res={} + for arm,f in (("LEL",lel),("VANL",van)): + acc={b:[0,0,0,0] for b in B} + for c in cells(arm,task): + for p,o,d,pf in f(c): + for b in B: + if b[0]<=p