Files
agentic-kvc/scripts/legacy/final_all_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

48 lines
1.9 KiB
Python

"""Final comparison across ALL tested configurations."""
import json, csv, statistics, os
def lat(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 len(ok), len(rows), p(ttfts,.5), p(ttfts,.9), p(tpots,.5), p(tpots,.9), p(lats,.5)
def gpu(path):
rows = list(csv.DictReader(open(path)))
vals = [float(r["util_pct"]) for r in rows]
return statistics.fmean(vals) if vals else 0
print("COMPLETE CONFIGURATION COMPARISON")
print("All use same 1000-req trace (200 req for GPU tests), 8xH20")
print("=" * 85)
fmt = "%-35s %6s %8s %8s %8s %8s %8s"
print(fmt % ("Config", "OK/N", "TTFT50", "TTFT90", "TPOT50", "TPOT90", "E2E50"))
print("-" * 85)
configs = [
("gpu_ab_combined", "TP=1 DP=8 old cache-aware"),
("gpu_ab_hybrid", "TP=1 DP=8 hybrid routing"),
("tp2dp4_hybrid", "TP=2 DP=4 hybrid routing *** NEW"),
("gpu_ab_pdsep", "TP=1 PD-Sep 4P+4D"),
("gpu_ab_6p2d", "TP=1 PD-Sep 6P+2D"),
("adaptive_v2_baseline", "TP=1 kv_both baseline"),
("adaptive_v2_offload", "TP=1 adaptive offload"),
]
for d, label in configs:
mp = "outputs/%s/metrics.jsonl" % d
if not os.path.exists(mp):
continue
ok, n, t50, t90, p50, p90, e50 = lat(mp)
print(fmt % (label, "%d/%d" % (ok, n),
"%.3f" % t50, "%.3f" % t90, "%.3f" % p50, "%.3f" % p90, "%.3f" % e50))
print()
print("KEY TRADEOFF: TP=1 vs TP=2")
print(" TP=1 DP=8: Better TPOT (0.072), more instances for routing diversity")
print(" TP=2 DP=4: Better TTFT (0.565), faster prefill, larger KV cache per inst")
print(" Which is better depends on SLO: TTFT-sensitive -> TP=2, TPOT-sensitive -> TP=1")