benchmark¶
Run a set of provers across a set of named ProofTasks and
tabulate the results. run_benchmark() runs every
(task, prover) pair and lays the artifacts out under output_dir as
output_dir/<task>/<prover>/{wd,logs,results.json}, returning a
BenchmarkResult with a terminal-table view. A prover that
raises is recorded as a failed ProofResult so one bad
run never aborts the sweep.
Runner¶
- open_atp.benchmark.run_benchmark(tasks: Mapping[str, ProofTask], provers: Mapping[str, AutomatedProver], output_dir: Path | str, *, only: Sequence[str] | None = None, max_workers: int | None = None, max_per_prover: int = 5, progress: bool = True) BenchmarkResult[source]¶
Run every prover over every task, writing artifacts under
output_dir.Each
(task, prover)pair runs in its ownoutput_dir/<task>/<prover>/directory, which receives the prover’swd/logsand aresults.jsondump of theProofResult. A prover that raises is recorded as a failed result (itserrorcaptured) and the sweep continues.Pairs run concurrently on a thread pool (
proveis I/O-bound on the sandbox and the prover’s API). Two independent limits bound the concurrency:max_workerscaps the total in-flight pairs, andmax_per_provercaps how many of those may belong to any one prover – so a rate-limited prover (e.g. a hosted model) never has more thanmax_per_provercalls in flight even when other provers fill the pool. The returnedrunskeep task-major, prover-minor order regardless of completion order.- Parameters:
- tasks
Mapping[str,ProofTask] Tasks keyed by name; the name becomes the task’s output subdirectory.
- provers
Mapping[str,AutomatedProver] Provers keyed by name; the name becomes the per-task output subdirectory. A mapping (not a list) so the caller labels each entry – the same prover can appear under several keys (e.g. different models) and stay distinct on disk and in the table.
- output_dir
pathlib.Pathorstr Output root for the sweep, laid out as
output_dir/<task>/<prover>/.- only
Sequence[str], optional Restrict the sweep to these task names (a subset of
tasks), in the given order.None(default) runs every task. An unknown name raisesValueError.- max_workers
int, optional Total
provecalls in flight at once.None(default) lets the thread pool pick a default;1runs the sweep serially.- max_per_prover
int, default 5 Most concurrent
provecalls for any single prover. Bounded to stay under rate limits.- progressbool, default
True Show a
tqdmprogress bar over the(task, prover)pairs. Each completed pair is logged (task, prover, status, duration, cost) on theopen_atplogger regardless.
- tasks
- Returns:
BenchmarkResultEvery
(task, prover)cell (seeto_dict()).
- exception open_atp.benchmark.RunCeilingExceeded[source]¶
The run exceeded the maximum allowed duration and is in an unhealthy state.
Distinct from a prover spending its own generation budget: the ceiling only fires once a run has blown past every timeout meant to bound it, so the run is wedged rather than merely out of time.
Building tasks from a directory¶
tasks_from_dir() builds the tasks mapping from a directory
laid out like the public Lean benchmarks
(PutnamBench,
FATE) — a flat directory of standalone .lean
files, optionally with subdirectories grouping several files into one task.
- open_atp.benchmark.tasks_from_dir(directory: Path | str, *, skeleton: Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/open-atp/envs/latest/lib/python3.12/images/lean')) dict[str, ProofTask][source]¶
Build a benchmark’s
tasksmapping from a directory of Lean files.Mirrors the layout the public Lean benchmarks ship (PutnamBench, FATE):
Each
.leanfile directly underdirectorybecomes one task named by its filename stem, staged intoskeleton(a bare file carries no lake project).Each subdirectory becomes one task named by the subdirectory name. A subdirectory that is already a complete lake project (carries its own
lean-toolchainand lakefile) is used as-is; otherwise its.leanfiles are staged intoskeleton.
In both staged cases
create_project()supplies the skeleton. Subdirectories with no.leanfiles (and entries whose name starts with.) are skipped. The result is ready to hand torun_benchmark().- Parameters:
- directory
pathlib.Pathorstr The benchmark directory:
.leanfiles and/or per-task subdirectories.- skeleton
pathlib.Path, defaultSKELETON_DIR Project skeleton staged around bare files (see
create_project()). The default is the baked image’s pinned Mathlib skeleton, only present in a source checkout. Pass a checkout of a benchmark’s own toolchain to stage against a non-default Lean/Mathlib pin.
- directory
- Returns:
Downloading a dataset¶
download_dataset() fetches one of the public benchmarks (a
DATASET member) straight to a task directory — a sparse
clone of just the dataset’s .lean subdirectory — ready for
tasks_from_dir().
- open_atp.benchmark.download_dataset(dataset: DATASET, dest: Path | str, *, ref: str | None = None) Path[source]¶
Download a benchmark dataset’s task directory to
dest/<dataset>.Sparse-clones only the dataset’s task subdirectory (shallow + blobless), then lifts its
.leanfiles todest/<dataset>– a flat directory ready fortasks_from_dir(), with no surrounding git repo. An already-present download is reused as-is (the clone is skipped), so repeated calls are cheap.DATASET.EXAMPLESinstead copies the package’s bundled example assets intodest/examples(no clone,refignored).- Parameters:
- dataset
DATASET Which benchmark to fetch.
- dest
pathlib.Pathorstr Parent directory; the dataset lands at
dest/<dataset>. Created if missing.- ref
str, optional Branch or tag to check out.
Noneuses the repo’s default branch. Ignored forDATASET.EXAMPLES.
- dataset
- Returns:
pathlib.PathThe dataset’s task directory (
dest/<dataset>).
- class open_atp.benchmark.DATASET(*values)[source]¶
The benchmark datasets accepted by
download_dataset().Each member’s value is the directory name the dataset lands in. The FATE datasets and the bundled examples are on the default
v4.28.0; PutnamBench pins an older Lean (v4.27.0), so stage it with a matchingskeleton(seetasks_from_dir()).EXAMPLESis the package’s bundledEXAMPLEset, copied from the wheel rather than cloned.
Results¶
- class open_atp.benchmark.BenchmarkResult(output_dir: Path, runs: list[BenchmarkRun])[source]¶
The collected cells of a benchmark sweep.
- Parameters:
- output_dir
pathlib.Path The benchmark’s output root, laid out as
output_dir/<task>/<prover>/.- runs
list[BenchmarkRun] One
BenchmarkRunper(task, prover)pair, in run order.
- output_dir
- class open_atp.benchmark.BenchmarkRun(task: str, prover: str, result: ProofResult)[source]¶
One
(task, prover)cell of a benchmark sweep.- Parameters:
- task
str The task’s key in the benchmark’s
tasksmapping.- prover
str The prover’s key in the benchmark’s
proversmapping. Caller-chosen, so it may differ from the prover’s ownprover(e.g. two entries running the same prover under different labels).- result
ProofResult The run’s result. On an exception its
erroris set andverificationisNone.
- task