Append results to workspace/kb_active/results.json.
(uid, correctness, stability, determinism, perf, vram, meta)
| 698 | |
| 699 | |
| 700 | def _save_results(uid, correctness, stability, determinism, perf, vram, meta): |
| 701 | """Append results to workspace/kb_active/results.json.""" |
| 702 | results_path = KB_ACTIVE_DIR / "results.json" |
| 703 | entry = { |
| 704 | "timestamp": time.strftime("%Y-%m-%d %H:%M:%S"), |
| 705 | "uid": uid, |
| 706 | "correctness": correctness.get("correctness", "FAIL"), |
| 707 | "speedup": perf.get("speedup", 0.0), |
| 708 | "kernel_time_ms": perf.get("kernel_time_ms", 0.0), |
| 709 | "reference_time_ms": perf.get("reference_time_ms", 0.0), |
| 710 | "worst_max_abs_error": correctness.get("worst_max_abs_error", 0.0), |
| 711 | "stability": stability.get("stability", "SKIP"), |
| 712 | "determinism": determinism.get("determinism", "SKIP"), |
| 713 | "peak_vram_mb": vram.get("peak_mb", 0.0), |
| 714 | } |
| 715 | history = [] |
| 716 | if results_path.exists(): |
| 717 | try: |
| 718 | history = json.loads(results_path.read_text(encoding="utf-8")) |
| 719 | except json.JSONDecodeError: |
| 720 | history = [] |
| 721 | history.append(entry) |
| 722 | results_path.write_text(json.dumps(history, indent=2), encoding="utf-8") |
| 723 | |
| 724 | |
| 725 | if __name__ == "__main__": |