|
| 1 | +# Copyright (c) 2022-2026, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md). |
| 2 | +# All rights reserved. |
| 3 | +# |
| 4 | +# SPDX-License-Identifier: BSD-3-Clause |
| 5 | + |
| 6 | +"""Generate compact results, figures, and reports from completed benchmark runs.""" |
| 7 | + |
| 8 | +from __future__ import annotations |
| 9 | + |
| 10 | +import argparse |
| 11 | +import json |
| 12 | +from dataclasses import asdict |
| 13 | +from pathlib import Path |
| 14 | + |
| 15 | +from .analysis import VariantSummary, complete_five_seed_records, load_records, summarize_records |
| 16 | +from .plotting import VARIANT_LABELS, plot_runtime |
| 17 | +from .reporting import write_reports |
| 18 | + |
| 19 | + |
| 20 | +def quality_issues(records, summaries: list[VariantSummary], artifact_root: Path) -> list[str]: |
| 21 | + """Return explicit schema, capacity, failure, and learning-quality warnings.""" |
| 22 | + issues: list[str] = [] |
| 23 | + if any(record.success_schema_mismatch for record in records): |
| 24 | + issues.append( |
| 25 | + "Schema v1.1 success series differs from TensorBoard for at least one run; report uses TensorBoard success." |
| 26 | + ) |
| 27 | + for summary in summaries: |
| 28 | + if summary.num_envs < 4096: |
| 29 | + issues.append(f"{summary.task} used {summary.num_envs} environments after a documented capacity fallback.") |
| 30 | + for manifest_path in sorted(artifact_root.glob("*/manifest.json")): |
| 31 | + manifest = json.loads(manifest_path.read_text(encoding="utf-8")) |
| 32 | + if manifest.get("state") == "failed": |
| 33 | + identity = manifest["identity"] |
| 34 | + issues.append( |
| 35 | + f"Failed {identity['task']} / {identity['variant']} / seed {identity['seed']}: " |
| 36 | + f"{manifest.get('failure_category')}." |
| 37 | + ) |
| 38 | + by_task = {summary.task for summary in summaries} |
| 39 | + for task in sorted(by_task): |
| 40 | + rows = {summary.variant: summary for summary in summaries if summary.task == task} |
| 41 | + baseline = rows.get("kamino_current") |
| 42 | + if baseline is None: |
| 43 | + continue |
| 44 | + baseline_floor = baseline.reward.mean - baseline.reward.half_width |
| 45 | + for variant, row in rows.items(): |
| 46 | + if variant == "kamino_current": |
| 47 | + continue |
| 48 | + if row.reward.mean + row.reward.half_width < baseline_floor: |
| 49 | + issues.append( |
| 50 | + f"{task} {VARIANT_LABELS.get(variant, variant)} has materially lower final-window reward than " |
| 51 | + "current Kamino." |
| 52 | + ) |
| 53 | + return issues |
| 54 | + |
| 55 | + |
| 56 | +def build_parser() -> argparse.ArgumentParser: |
| 57 | + """Build the report generator command-line parser.""" |
| 58 | + parser = argparse.ArgumentParser(description=__doc__) |
| 59 | + parser.add_argument("--artifact-root", type=Path, default=Path("benchmark_artifacts/kamino_dvi/runs")) |
| 60 | + parser.add_argument("--logs-root", type=Path, default=Path("logs")) |
| 61 | + parser.add_argument("--output-dir", type=Path, default=Path("benchmarks/kamino_dvi/results")) |
| 62 | + return parser |
| 63 | + |
| 64 | + |
| 65 | +def main(argv: list[str] | None = None) -> int: |
| 66 | + """Load validated runs and generate all compact report artifacts.""" |
| 67 | + args = build_parser().parse_args(argv) |
| 68 | + records = load_records(args.artifact_root, args.logs_root) |
| 69 | + summaries = summarize_records(complete_five_seed_records(records)) |
| 70 | + if not summaries: |
| 71 | + raise RuntimeError("no complete five-seed task/variant groups are available") |
| 72 | + args.output_dir.mkdir(parents=True, exist_ok=True) |
| 73 | + runtime_figure = args.output_dir / "runtime.png" |
| 74 | + plot_runtime(summaries, runtime_figure) |
| 75 | + issues = quality_issues(records, summaries, args.artifact_root) |
| 76 | + (args.output_dir / "summary.json").write_text( |
| 77 | + json.dumps([asdict(summary) for summary in summaries], indent=2, sort_keys=True) + "\n", |
| 78 | + encoding="utf-8", |
| 79 | + ) |
| 80 | + write_reports( |
| 81 | + summaries, |
| 82 | + issues, |
| 83 | + [runtime_figure], |
| 84 | + args.output_dir / "kamino_dvi_benchmark.md", |
| 85 | + args.output_dir / "kamino_dvi_benchmark.pdf", |
| 86 | + ) |
| 87 | + return 0 |
| 88 | + |
| 89 | + |
| 90 | +if __name__ == "__main__": |
| 91 | + raise SystemExit(main()) |
0 commit comments