add paper artifact
Validate Operations / validate-operations (push) Has been cancelled

This commit is contained in:
Niccolò Nicolosi
2026-11-03 14:37:25 +01:00
parent aff9482db1
commit 66db4b66da
21 changed files with 1161 additions and 311 deletions
+40 -21
View File
@@ -524,23 +524,32 @@ def test_suite_reruns_anchor_and_shares_only_new_reports(tmp_path, monkeypatch,
report.parent.mkdir(parents=True)
report.write_text("{}")
os.utime(report, ns=(1, 1))
batches = []
commands = []
errors = []
def run_jobs(jobs, max_workers, log_dir, offset):
assert max_workers == 1
batches.append([command for _, command, _ in jobs])
for _, command, _ in jobs:
output = Path(command[command.index("--out-dir") + 1]) / "pimcomp/comparison_report.json"
if fresh or len(batches) > 1:
output.parent.mkdir(parents=True, exist_ok=True)
output.write_text('{"new": true}')
return [], offset + len(jobs)
def run_jobs(tasks, jobs, threads, cwd):
assert jobs == 1
results = {}
for task in tasks:
try:
command = task.command()
except ValueError as exc:
errors.append(str(exc))
results[task.key] = suite.TaskResult(1, str(exc))
continue
if "--prepare-common" not in command:
commands.append(command)
output = Path(command[command.index("--out-dir") + 1]) / "pimcomp/comparison_report.json"
if fresh or only == "raptor":
output.parent.mkdir(parents=True, exist_ok=True)
output.write_text('{"new": true}')
results[task.key] = suite.TaskResult(0)
return results
summary = tmp_path / "results.csv"
summary.write_text("summary\n")
monkeypatch.setattr(suite, "validate_pimcomp_source", lambda: None)
monkeypatch.setattr(suite, "run", lambda *a, **k: 0)
monkeypatch.setattr(suite, "run_comparison_jobs", run_jobs)
monkeypatch.setattr(suite, "run_tasks", run_jobs)
monkeypatch.setattr(suite, "write_results_csv", lambda *a: summary)
monkeypatch.setattr(suite, "comparison_passed", lambda report: True)
monkeypatch.setattr(sys, "argv", [
@@ -548,15 +557,19 @@ def test_suite_reruns_anchor_and_shares_only_new_reports(tmp_path, monkeypatch,
"--archs", "arch-a", "--mode", "throughput", "--jobs", "1",
*(["--only", only] if only else []),
])
assert suite.main() == 0
assert suite.main() == (1 if only != "raptor" and not fresh else 0)
if only == "raptor":
assert len(batches[0]) == 3
assert all("--reuse-pimcomp-report" in command for command in batches[0])
assert len(commands) == 3
assert all("--reuse-pimcomp-report" in command for command in commands)
else:
assert len(batches[0]) == 1
assert "--reuse-pimcomp-report" not in batches[0][0]
assert all(("--reuse-pimcomp-report" in command) == fresh for command in batches[1])
assert ("--reuse-raptor-report" in batches[0][0]) == (only == "pimcomp")
assert "--reuse-pimcomp-report" not in commands[0]
assert ("--reuse-raptor-report" in commands[0]) == (only == "pimcomp")
if fresh:
assert len(commands) == 3
assert all("--reuse-pimcomp-report" in command for command in commands[1:])
else:
assert len(commands) == 1 # Missing reports must not cause duplicate Pimcomp work.
assert len(errors) == 2
def test_missing_pimcomp_report_is_not_reused(tmp_path):
@@ -658,7 +671,7 @@ def test_ablation_cli_selects_canonical_or_custom_output(tmp_path, monkeypatch,
canonical = tmp_path / "scripts/results_ablation.csv"
monkeypatch.setattr(ablation, "DEFAULT_OUT_DIR", artifact_root)
monkeypatch.setattr(ablation, "DEFAULT_RESULTS_PATH", canonical)
monkeypatch.setattr(ablation.subprocess, "Popen", lambda *a, **k: argparse.Namespace(wait=lambda: 0))
monkeypatch.setattr(suite, "run_plans", lambda plans: 0)
calls = []
monkeypatch.setattr(ablation, "aggregate_results", lambda root, *a, **k: (calls.append((root, k["output"])) or None, []))
command = ["--variant", "baseline", "--jobs", "1"]
@@ -863,7 +876,13 @@ def test_ablation_runner_distinguishes_invalid_outputs_from_failed_execution(tmp
csv = tmp_path / "results.csv"
csv.write_text("summary\n")
monkeypatch.setattr(suite, "run", lambda *a, **k: 0)
monkeypatch.setattr(suite, "run_comparison_jobs", lambda *a: (["arch-a/vgg8/throughput/pipeline4"] if process_failed else [], 1))
def complete_tasks(tasks, *args):
previous = output.stat().st_mtime_ns
output.write_text(json.dumps(report))
os.utime(output, ns=(previous + 1000000, previous + 1000000))
return {task.key: suite.TaskResult(int(process_failed)) for task in tasks}
monkeypatch.setattr(suite, "run_tasks", complete_tasks)
monkeypatch.setattr(suite, "write_results_csv", lambda *a: csv)
monkeypatch.setattr(sys, "argv", ["run_pimcomp_models.py", "--out-dir", str(tmp_path),
"--models", "vgg8", "--archs", "arch-a", "--mode", "throughput", "--pipeline", "4",