Speed program: time-weighted hit-rate gap and gap by context from the real Codex sessions (ceiling of the hit-rate levers 1.8-2.6 % of task time)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
cac5802fe6
commit
e7dde84ea9
@@ -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).
|
||||
|
||||
@@ -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<b[1]: a=acc[b];a[0]+=d;a[1]+=o;a[2]+=pf;a[3]+=1
|
||||
res[arm]=acc
|
||||
print(task)
|
||||
TL=sum(a[0]+a[2] for a in res["LEL"].values())
|
||||
for b in B:
|
||||
l=res["LEL"][b];v=res["VANL"][b]
|
||||
if l[3]==0: continue
|
||||
lt=l[1]/l[0]*1e3 if l[0] else 0; vt=v[1]/v[0]*1e3 if v[0] else 0
|
||||
print(" ctx %6d-%-8d LEL n=%3d decode+prefill share %5.1f%% dec tok/s %6.1f | VANL n=%3d tok/s %6.1f gap %+5.1f%% | ms/tok %5.2f vs %5.2f"%(b[0],b[1],l[3],100*(l[0]+l[2])/TL,lt,v[3],vt,100*(lt/vt-1) if vt else 0,1e3/lt if lt else 0,1e3/vt if vt else 0))
|
||||
@@ -0,0 +1,33 @@
|
||||
import re,json,glob,sys
|
||||
root="/data/leleka-e2e/codex-compare/runs/main"
|
||||
def lel(cell):
|
||||
r=[]
|
||||
for l in open(cell+"/engine-slice.log",errors="replace"):
|
||||
if l.startswith("{") and '"ev":"request"' in l and '"comp":"engine"' in l:
|
||||
j=json.loads(l)
|
||||
r.append((j["otok"],j["dec_ms"],j["tier_vram_pct"],j["ptok"]-j["ctok"]))
|
||||
return r
|
||||
def van(cell):
|
||||
hits=[];gen=[]
|
||||
for l in open(cell+"/engine-slice.log",errors="replace"):
|
||||
m=re.search(r"decode expert cache hit rate: [\d.]+% \((\d+) hits / (\d+) lookups\); (\d+) more.*?of all (\d+) routed",l)
|
||||
if m: hits.append(100*int(m.group(1))/int(m.group(4)))
|
||||
m=re.search(r"(\d+) generated in ([\d.]+) ms",l)
|
||||
if m: gen.append((int(m.group(1)),float(m.group(2))))
|
||||
return list(zip(gen,hits))
|
||||
buckets=[(0,600),(600,2000),(2000,10**9)]
|
||||
for task in ("nestng-crm","ttt"):
|
||||
for arm in ("LEL","VANL"):
|
||||
tot=0;acc={b:[0,0,0] for b in buckets} # time, time*hit, count
|
||||
for cell in sorted([c for c in glob.glob(f"{root}/{arm}/{task}-r*") if not c.endswith(".out")]):
|
||||
if arm=="LEL": rows=[(o,d,h) for o,d,h,_ in lel(cell)]
|
||||
else: rows=[(g[0],g[1],h) for g,h in van(cell)]
|
||||
for o,d,h in rows:
|
||||
for b in buckets:
|
||||
if b[0]<=o<b[1]:
|
||||
acc[b][0]+=d;acc[b][1]+=d*h;acc[b][2]+=1
|
||||
T=sum(a[0] for a in acc.values())
|
||||
print(task,arm,"decode time %.0f s"%(T/1e3))
|
||||
for b,a in acc.items():
|
||||
if a[0]: print(" otok %5d-%-9d requests %3d time share %5.1f%% time-weighted vram-hit %.2f"%(b[0],b[1],a[2],100*a[0]/T,a[1]/a[0]))
|
||||
print(" total time-weighted hit %.2f"%(sum(a[1] for a in acc.values())/T))
|
||||
Reference in New Issue
Block a user