draft-round: timeline and window-width analyzers, SPEC_MIN_P in the A/B harness, fused-commit class in the kernel tables

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Pavlo Ratushnyi
2026-11-02 16:51:13 +01:00
co-authored by Claude Sonnet 5.5
parent 28d74a2efd
commit 8f4b351363
5 changed files with 104 additions and 3 deletions
+2 -1
View File
@@ -18,6 +18,7 @@ UP=/data/leleka-e2e/decode/assets/expert-profile-upstream.bin
BLOCKS=${BLOCKS:-"1 2 3 4 5"}
RUN_TAG=${RUN_TAG:-}
PCIE_FRAC=${PCIE_FRAC:-0.45}
SPEC_MIN_P=${SPEC_MIN_P:-0} # the request's draft confidence floor (the product profile: 0 with the adaptive window)
A_BIN=${A_BIN:?A_BIN}; B_BIN=${B_BIN:-$A_BIN}; A_ENV=${A_ENV:-}; B_ENV=${B_ENV:-}
SESSION_ARGS="--turns 5 --target-tokens 245000 --max-output 300 --min-final-tokens 200000"
WIN_S=${WIN_S:-20}
@@ -62,7 +63,7 @@ ours() { # $1 tag, $2 run dir, $3 bin dir, $4 extra env words
( export E2E_BIN=$D/$bin E2E_OUT=$R
export LELEKA_BRINGUP_TRACE=1 LELEKA_PREFIX_TRACE=1
export LELEKA_ORIGINAL_SERVE_EXPERT_SLOTS=auto E2E_GPU_BUDGET=${GPU_BUDGET:-32819404800}
export E2E_ENGINE_ARGS="--prefix-cache-mib auto --prefix-cache-tail reply --original-prefill-capacity 8192 --prefix-cache-block 8192 --spec-min-p 0"
export E2E_ENGINE_ARGS="--prefix-cache-mib auto --prefix-cache-tail reply --original-prefill-capacity 8192 --prefix-cache-block 8192 --spec-min-p ${SPEC_MIN_P:-0}"
export E2E_SAMPLE_S=10 LELEKA_CHAIN=all
export LELEKA_ORIGINAL_SERVE_EXPERT_PROFILE=$UP
unset LELEKA_FOOTPRINT_LEGACY LELEKA_ORIGINAL_SERVE_SEED_MAX_ROWS LELEKA_SM120_ATTN_DAILY LELEKA_SM120_GU_SWIGLU LELEKA_SM120_SIDE_MIXER LELEKA_SM120_PERF LELEKA_SERVE_DRAFT_AFTER_COMMIT LELEKA_PROMPT_EMBED_ALIAS LELEKA_VRAM_LEDGER LELEKA_DENSE_SLAB LELEKA_ORIGINAL_SERVE_DECODE_RESERVE_MIB LELEKA_ROUTE_TAIL_SKIP
+1 -1
View File
@@ -9,7 +9,7 @@ D=/data/leleka-e2e/decode/dt
SRC=$(cd "$(dirname "$0")" && pwd)
mkdir -p "$DR/tools"
chmod -R u+w "$DR/tools" 2>/dev/null || true
for f in draftround-ab.sh draftround-id.sh draftround-idcmp.py draftround-kernels.py draftround-install.sh ts-wrap.sh draftround-analyze.py; do [ -e "$SRC/$f" ] && install -m 0444 "$SRC/$f" "$DR/tools/$f"; done
for f in draftround-ab.sh draftround-id.sh draftround-idcmp.py draftround-kernels.py draftround-timeline.py draftround-width.py draftround-install.sh ts-wrap.sh draftround-analyze.py; do [ -e "$SRC/$f" ] && install -m 0444 "$SRC/$f" "$DR/tools/$f"; done
[ -e "$DR/tools/libleleka_cupti_trace.so" ] || install -m 0444 "$HOME/work/cupti-trace/libleleka_cupti_trace.so" "$DR/tools/libleleka_cupti_trace.so"
chmod a-w "$DR/tools"
BINS="bin-main-ffd9322 $*"
+1 -1
View File
@@ -34,7 +34,7 @@ def main():
if not ks or len(ks) >= 1000:
continue
names = [t.names.get(k.name, "?") for k in ks]
if any("conv_commit" in n for n in names):
if any("conv_commit" in n or "draft_commit" in n for n in names):
cl = "commit"
elif len(ks) == 113:
cl = "step"
+61
View File
@@ -0,0 +1,61 @@
#!/usr/bin/env python3
"""Timeline of a decode round from a CUPTI window: for each verify window graph followed by one commit graph, one MTP round graph and 0..n step graphs, the mean gaps
(verify end -> commit launch call / first kernel, -> round graph first kernel, launch call lengths, step gaps, draft end vs commit end, last draft kernel -> next verify).
python3 -I draftround-timeline.py <win.lct>
Classes by kernel count and names: V >= 1000 kernels (verify window), C has verify_gdn_conv_commit_kernel or draft_commit_* (the fused commit graph), S exactly 113 kernels (MTP step), R 140-200 kernels (MTP round graph).
"""
import sys, collections, statistics
sys.path.insert(0,"/data/leleka-e2e/decode/tools")
import lct as L
t = L.Trace(sys.argv[1])
gl = {x.corr: x for x in t.apis if "GraphLaunch" in t.names.get(x.name, "")}
byc = collections.defaultdict(list)
for k in t.kernels: byc[k.corr].append(k)
G=[]
for corr,x in gl.items():
ks=sorted(byc.get(corr,[]),key=lambda k:k.start)
if not ks: continue
names=[t.names.get(k.name,"?") for k in ks]
if len(ks)>=1000: cl="V"
elif any("conv_commit" in n or "draft_commit" in n for n in names): cl="C"
elif len(ks)==113: cl="S"
elif 140<=len(ks)<=200: cl="R"
else: cl="?"
G.append((ks[0].start, ks[-1].end, cl, x.start, x.end))
G.sort()
# rounds: V then C, R, S*
rows=[]
i=0
while i < len(G):
if G[i][2]=="V":
j=i+1; seq=[]
while j<len(G) and G[j][2]!="V": seq.append(G[j]); j+=1
if j<len(G) and seq:
rows.append((G[i],seq,G[j]))
i=j
else: i+=1
f=lambda a:statistics.mean(a)/1e3
acc=collections.defaultdict(list)
for v,seq,nv in rows:
C=[g for g in seq if g[2]=="C"]; R=[g for g in seq if g[2]=="R"]; S=[g for g in seq if g[2]=="S"]
if len(C)!=1 or len(R)!=1: continue
c=C[0]; r=R[0]
acc["V end -> C launch call start"].append(c[3]-v[1])
acc["V end -> C first kernel"].append(c[0]-v[1])
acc["C gpu span"].append(c[1]-c[0])
acc["V end -> R first kernel"].append(r[0]-v[1])
acc["R launch call (start->end)"].append(r[4]-r[3])
acc["R gpu span"].append(r[1]-r[0])
last=r
for k,s in enumerate(S):
acc["gap before step (prev end -> launch call start)"].append(s[3]-last[1])
acc["gap before step (prev end -> first kernel)"].append(s[0]-last[1])
acc["step gpu span"].append(s[1]-s[0])
last=s
acc["last draft kernel end -> next V first kernel"].append(nv[0]-last[1])
acc["C end vs draft end (draft end - C end)"].append(last[1]-c[1])
acc["V end -> next V start (round)"].append(nv[0]-v[1])
acc["nsteps"].append(len(S)*1e3)
for k,v in acc.items(): print("%-55s n=%4d mean %8.1f us p10 %8.1f p90 %8.1f"%(k,len(v),f(v),sorted(v)[len(v)//10]/1e3,sorted(v)[len(v)*9//10]/1e3))
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env python3
"""Window width and acceptance per arm of a draftround-ab.sh series: mean verified rows per round (round.T), mean accepted drafts per round (round.acc), drafts per
round (mtp.chain_step calls + 1 round graph = steps) from the 'DBG profile request:' lines; block-paired b - a.
python3 -I draftround-width.py <outroot>
"""
import glob, os, re, statistics, sys
def stats(d):
rounds = T = acc = steps = 0
cur = None
for ln in open(os.path.join(d, "inference.log"), errors="replace"):
if ln.startswith("DBG profile request:"):
cur = {m[0]: (float(m[1]), int(m[2])) for m in re.findall(r"(\S+?)=([\d.]+)/(\d+)", ln)}
elif "leleka-serve request outcome" in ln and cur:
r = int(re.search(r"rounds=(\d+)", ln).group(1))
rounds += r
T += cur.get("round.T", (0, 0))[0]
acc += cur.get("round.acc", (0, 0))[0]
steps += cur.get("mtp.chain_step", (0, 0))[1]
cur = None
return rounds, T / rounds, acc / rounds, steps / rounds
root = sys.argv[1]
by = {}
for d in sorted(glob.glob(os.path.join(root, "b*p*-*"))):
m = re.match(r"b(\d+)p(\d+)-([ab])", os.path.basename(d))
if not m or not os.path.exists(os.path.join(d, "VALIDITY.txt")) or not open(os.path.join(d, "VALIDITY.txt")).read().startswith("VALID"):
continue
by.setdefault(int(m.group(1)), {})[m.group(3)] = stats(d)
print("block arm rounds rows/round accepted/round chain steps/round")
for b, v in sorted(by.items()):
for arm in "ab":
if arm in v:
print("%5d %s %6d %10.3f %14.3f %17.3f" % (b, arm, *v[arm]))
pairs = [(v["a"], v["b"]) for v in by.values() if "a" in v and "b" in v]
for i, name in ((1, "rows/round"), (2, "accepted/round"), (3, "chain steps/round")):
d = [pb[i] - pa[i] for pa, pb in pairs]
print("b - a %-18s per block %s mean %+.3f (se %.3f)" % (name, " ".join("%+.3f" % x for x in d), statistics.mean(d), statistics.stdev(d) / len(d) ** 0.5))