Files
agentic-kvc/scripts/legacy/final_gpu_comparison.py
Gahow Wang 547611e022 scripts: archive obsolete one-off shell/python scripts to legacy/ (D2, D3)
D2: run_benchmark.sh and run_experiments.sh still pass --time-scale and
--max-inflight-sessions to the replayer, but those flags were removed when
the project moved to trace-driven dispatch. The scripts cannot run as-is.

D3: ~25 ad-hoc analyze_* / compare_* / profile_* / final_* scripts and a
handful of single-experiment run_*.sh point at /home/admin/cpfs paths,
deleted output directories, or a sampled trace file that no longer exists.
Keep them in scripts/legacy/ for historical reference; the scripts that
remain in scripts/ (analyze_trace, analyze_breakdown, analyze_cache_hit,
analyze_eviction, compare_results, compute_roofline, sample_trace,
analyze_agentic_patterns, simulate_cache_policies, plus launch_*.sh,
gpu_monitor.sh, bench.sh) cover the current workflow.

Adds scripts/legacy/README.md to document the archival policy.
2026-05-23 20:57:32 +08:00

43 lines
1.7 KiB
Python

"""Final GPU util + latency comparison across all tested configs."""
import csv, json, statistics, os
def gpu_s(path):
rows = list(csv.DictReader(open(path)))
vals = [float(r["util_pct"]) for r in rows]
s = sorted(vals)
p = lambda q: s[min(int(q*len(s)),len(s)-1)]
nz = sum(1 for v in vals if v > 0)
return {"mean": statistics.fmean(vals), "p50": p(.5), "active": nz*100//len(vals)}
def lat_s(path):
rows = [json.loads(l) for l in open(path)]
ok = [r for r in rows if not r.get("error")]
ttfts = sorted([r["ttft_s"] for r in ok if r.get("ttft_s")])
tpots = sorted([r["tpot_s"] for r in ok if r.get("tpot_s") and r["tpot_s"]>0])
lats = sorted([r["latency_s"] for r in ok])
p = lambda v,q: v[min(int(q*len(v)),len(v)-1)] if v else 0
return {"ok": len(ok), "n": len(rows), "t50": p(ttfts,.5), "t90": p(ttfts,.9),
"p50": p(tpots,.5), "p90": p(tpots,.9), "e50": p(lats,.5)}
print("COMPLETE COMPARISON (200 req, time_scale=20, GPU monitoring)")
print("=" * 75)
fmt = "%-25s %6s %8s %8s %8s %7s %7s"
print(fmt % ("Config", "OK/N", "TTFT50", "TPOT90", "E2E50", "GPU%", "Active"))
print("-" * 75)
for d, label in [
("gpu_ab_combined", "Combined (old cache-aware)"),
("gpu_ab_hybrid", "Combined (hybrid routing)"),
("gpu_ab_pdsep", "PD-Sep 4P+4D"),
("gpu_ab_6p2d", "PD-Sep 6P+2D"),
]:
gp = "outputs/%s/gpu_util.csv" % d
mp = "outputs/%s/metrics.jsonl" % d
if not os.path.exists(gp) or not os.path.exists(mp):
continue
g = gpu_s(gp)
l = lat_s(mp)
print(fmt % (label, "%d/%d" % (l["ok"],l["n"]),
"%.3f" % l["t50"], "%.3f" % l["p90"], "%.3f" % l["e50"],
"%.1f" % g["mean"], "%d%%" % g["active"]))