50 lines
2.2 KiB
Python
50 lines
2.2 KiB
Python
"""每个已结束 job 的四道门一行摘要(看 FAIL 到底败在哪一门、差多少)。
|
|
|
|
python3 scripts/gate_summary.py [--run r…] [--state FAIL]
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
import sqlite3
|
|
import sys
|
|
from collections import Counter
|
|
from pathlib import Path
|
|
|
|
BENCH = Path(__file__).resolve().parent.parent
|
|
sys.path.insert(0, str(BENCH))
|
|
from harness import paths # noqa: E402
|
|
|
|
|
|
def main() -> int:
|
|
ap = argparse.ArgumentParser()
|
|
ap.add_argument("--run", action="append")
|
|
ap.add_argument("--state", default=None)
|
|
a = ap.parse_args()
|
|
con = sqlite3.connect(paths.DB_PATH)
|
|
runs = a.run or [con.execute("select run_id from runs order by created_at desc limit 1").fetchone()[0]]
|
|
q = "select run_id, job_id, state, error_class, stage_failed, result from jobs where mode='oracle' and run_id in (%s)" % ",".join("?" * len(runs))
|
|
args = list(runs)
|
|
if a.state:
|
|
q += " and state=?"; args.append(a.state)
|
|
q += " and state in ('PASS','FAIL','UNVERIFIED') order by run_id, job_id"
|
|
fg = Counter()
|
|
for rid, jid, st, ec, sf, res in con.execute(q, args):
|
|
r = json.loads(res) if res else {}
|
|
g = r.get("gates", {})
|
|
g1, g2, g3, g4 = (g.get(k, {}) for k in ("G1", "G2", "G3", "G4"))
|
|
fg[(st, r.get("failed_gate") or (sf and f"stage:{sf}") or "-")] += 1
|
|
f1 = f"/{','.join(g1.get('failed', []))}" if g1.get("failed") else (f"/miss:{','.join(g1.get('missing', []))}" if g1.get("missing") else "")
|
|
cos = g2.get("cos_min")
|
|
print(f"{rid} {jid:<46} {st:<10} fg={r.get('failed_gate') or '-':<3} ec={ec or '-':<14} "
|
|
f"G1={g1.get('verdict', '-')}{f1} G2={g2.get('verdict', '-')}{'' if cos is None else f'({cos:.4f})'} "
|
|
f"G3={g3.get('verdict', '-')}"
|
|
+ ("" if g3.get("fp32") is None else f"(fp32={g3['fp32']:.2f} q={g3['quant']:.2f} d={g3['delta']:+.2f} tol={g3.get('effective_tolerance', 0):.2f})")
|
|
+ (f" lat_est={g1.get('static_perf', {}).get('latency_ms_est')}ms" if g1.get("static_perf", {}).get("latency_ms_est") else ""))
|
|
print("\nsummary:", dict(fg))
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|