Files

29 lines
1.5 KiB
Python

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))