From 22d9689e73cdb3318cf82e19a8d3561d06579891 Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Fri, 13 Nov 2026 00:24:53 +0100 Subject: [PATCH] Host-round span report; identity stub with the sparse-extent guard and the input manifest check Co-Authored-By: Claude Sonnet 5.5 --- ...ed-draftround-reference-vs-on-vs-verify.sh | 10 +- scripts/e2e/codex/speed/host_round_spans.py | 92 +++++++++++++++++++ 2 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 scripts/e2e/codex/speed/host_round_spans.py diff --git a/scripts/e2e/codex/speed/decode-ple-rows-on-chain-identity-teacher-forced-draftround-reference-vs-on-vs-verify.sh b/scripts/e2e/codex/speed/decode-ple-rows-on-chain-identity-teacher-forced-draftround-reference-vs-on-vs-verify.sh index ecd588ce..7e8b4986 100644 --- a/scripts/e2e/codex/speed/decode-ple-rows-on-chain-identity-teacher-forced-draftround-reference-vs-on-vs-verify.sh +++ b/scripts/e2e/codex/speed/decode-ple-rows-on-chain-identity-teacher-forced-draftround-reference-vs-on-vs-verify.sh @@ -2,12 +2,18 @@ # HOLDER JOB. Plan 6c identity gate of LELEKA_PLE_ON_CHAIN (bitwise): draftround-id.sh, teacher-forced night5-long-256k (5 requests, 240 forced tokens each), top-16 logprob rows # and the draft trace of every window, two arms per process (the A/A floor), ONE test binary for all three processes: # idP1 reference (switch unset) idP2 LELEKA_PLE_ON_CHAIN=on idP3 LELEKA_PLE_ON_CHAIN=verify (every row taken from the cache is also gathered directly and compared bit for bit) -# Test binary: release lib tests of leleka-engine-qwen35-cuda built from the branch commit (sha256 recorded by the gate in $ID_OUT/rt.sha256). +# Test binary: release lib tests of leleka-engine-qwen35-cuda built from the branch commit (host-round/MANIFEST.sha256 holds its digest; the gate also records it in $ID_OUT/rt.sha256). # Proof that the path ran: the `DBG profile` lines of the processes carry `ple.ahead` and `ple.ahead_hit` (the gate exports LELEKA_SERVE_PROFILE=1); the verify process prints # `leleka-ple-on-chain: verified N window rows equal to a direct gather` and never `MISMATCH`. +( cd /data/leleka-e2e/prefill-latency/host-round && sha256sum --quiet -c MANIFEST.sha256 ) || { echo "host-round inputs do not match MANIFEST.sha256" >&2; exit 3; } unset ID_BIN P1_ENV P2_ENV P3_ENV P4_ENV ID_OUT MAX_NEW ADAPT SKIP_P1 D DR export D=/data/leleka-e2e/prefill-latency/host-round/dt DR=/data/leleka-e2e/draft-round -export ID_BIN=rt-host-round-ple-on-chain +export ID_BIN=rt-host-round-ple-on-chain MAX_NEW=240 ADAPT=4 export P2_ENV="LELEKA_PLE_ON_CHAIN=on" P3_ENV="LELEKA_PLE_ON_CHAIN=verify" export ID_OUT=/data/leleka-e2e/prefill-latency/runs/decode-ple-rows-on-chain-identity-teacher-forced-draftround-reference-vs-on-vs-verify +unset LELEKA_KAR_SPARSE_EXTENTS_SHA256 +if [ -n "${LELEKA_STRA169_KAR_FD:-}" ] && [ -e "/proc/self/fd/$LELEKA_STRA169_KAR_FD" ]; then + read -r kar_size kar_blocks < <(stat -L -c "%s %b" "/proc/self/fd/$LELEKA_STRA169_KAR_FD") + if [ $(( kar_blocks * 512 * 2 )) -lt "$kar_size" ]; then export LELEKA_KAR_SPARSE_EXTENTS_SHA256=7568b1211419a7c10a9b39a86230f75b7fa9c02839e36c9b5f2494ec7af72143; fi +fi exec bash /data/leleka-e2e/spd-gap/tools/draftround-id.sh diff --git a/scripts/e2e/codex/speed/host_round_spans.py b/scripts/e2e/codex/speed/host_round_spans.py new file mode 100644 index 00000000..3e278f81 --- /dev/null +++ b/scripts/e2e/codex/speed/host_round_spans.py @@ -0,0 +1,92 @@ +#!/usr/bin/env python3 +"""Host spans of the decode round per arm (offline analysis, stdlib only; never part of serving). + + host_round_spans.py RUN_DIR BASE VAR [--skip 3] [--spans a,b,c] + +RUN_DIR holds one directory per block named NAME.BLOCK (written by host_round_ab_job.sh, profile on: engine.log has one +`DBG profile request: name=total_ms/count ...` line per request). For every block the spans are summed over the requests after +the first --skip (warm-up) and divided by the block's rounds (the count of `round.verify_commit`): ms per round. The report gives, per span, +the mean of BASE blocks, the mean of VAR blocks, the paired difference VAR - BASE (blocks paired by number) with a two-sided 95 % t interval, +and the spread between the BASE blocks themselves (the noise the difference has to be read against). +""" +import math +import os +import re +import sys + +T975 = {1: 12.706, 2: 4.303, 3: 3.182, 4: 2.776, 5: 2.571, 6: 2.447, 7: 2.365, 8: 2.306, 9: 2.262} +DEFAULT = ("round.apply_pending", "window.ple", "ple.ahead", "ple.ahead_hit", "round.plan", "round.checkpoints", "window.verifier", + "round.run_window", "round.verify_commit", "round.emit", "draft.launch", "draft.finish", "round.draft_committed", + "commit.wait", "commit.publish", "round.adapt_deferred", "round.adopt", "round.finish", "round.T", "round.acc") +TOKEN = re.compile(r"([A-Za-z0-9_.]+)=(-?[0-9.]+)/(\d+)") + + +def block_sums(path, skip): + """Total ms and count of every span over the requests after `skip`.""" + sums, counts, seen = {}, {}, 0 + for line in open(path, errors="replace"): + if "DBG profile request:" not in line: + continue + seen += 1 + if seen <= skip: + continue + for name, total, count in TOKEN.findall(line.split("DBG profile request:", 1)[1]): + sums[name] = sums.get(name, 0.0) + float(total) + counts[name] = counts.get(name, 0) + int(count) + return sums, counts + + +def per_round(directory, skip): + sums, counts = block_sums(os.path.join(directory, "engine.log"), skip) + rounds = counts.get("round.verify_commit", 0) + if rounds == 0: + return None + out = {name: total / rounds for name, total in sums.items()} + out["rounds"] = rounds + out["tokens_per_round"] = (sums.get("round.acc", 0.0) + rounds) / rounds if "round.acc" in sums else float("nan") + return out + + +def interval(xs): + n = len(xs) + mean = sum(xs) / n + if n < 2: + return mean, float("nan") + sd = math.sqrt(sum((x - mean) ** 2 for x in xs) / (n - 1)) + return mean, T975.get(n - 1, 1.96) * sd / math.sqrt(n) + + +def blocks(run_dir, name): + return {d.split(".", 1)[1]: os.path.join(run_dir, d) for d in sorted(os.listdir(run_dir)) + if d.startswith(name + ".") and not os.path.exists(os.path.join(run_dir, d, "INVALID"))} + + +def main(argv): + skip, spans = 3, DEFAULT + args = [a for a in argv[1:] if not a.startswith("--")] + if "--skip" in argv: + skip = int(argv[argv.index("--skip") + 1]) + args = [a for a in args if a != str(skip)] + if "--spans" in argv: + spans = tuple(argv[argv.index("--spans") + 1].split(",")) + args = [a for a in args if a != argv[argv.index("--spans") + 1]] + run_dir, base_name, var_name = args[:3] + base, var = blocks(run_dir, base_name), blocks(run_dir, var_name) + paired = sorted(set(base) & set(var)) + print(f"{run_dir}: {base_name} blocks {sorted(base)}, {var_name} blocks {sorted(var)}, paired {paired}; first {skip} requests dropped") + base_rows = {k: per_round(v, skip) for k, v in base.items()} + var_rows = {k: per_round(v, skip) for k, v in var.items()} + print(f"{'span (ms per round)':<26}{base_name:>10}{var_name:>10}{'diff':>10}{'+-95%':>9}{'base spread':>13}") + for name in spans + ("tokens_per_round", "rounds"): + b = [r[name] for r in base_rows.values() if r and name in r] + v = [r[name] for r in var_rows.values() if r and name in r] + if not b or not v: + continue + diffs = [var_rows[k][name] - base_rows[k][name] for k in paired if base_rows[k] and var_rows[k] and name in base_rows[k] and name in var_rows[k]] + mean, half = interval(diffs) if diffs else (float("nan"), float("nan")) + spread = (max(b) - min(b)) if len(b) > 1 else float("nan") + print(f"{name:<26}{sum(b) / len(b):>10.3f}{sum(v) / len(v):>10.3f}{mean:>10.3f}{half:>9.3f}{spread:>13.3f}") + + +if __name__ == "__main__": + main(sys.argv)