Skip to content

feat: runtime estimator: Estimate line, data file, memory cap (5E) #887

Done

Description

@Jammy2211

Overview

Likelihood-lifecycle epic, phase 5E: the runtime estimator. At fit start, a lens fit prints an honest "Estimate:" line under the Parallel: banner, with ms per evaluation, expected evaluations (the Nautilus heuristic), the parallel efficiency and the wall time on this hardware. 5D's memory cap goes live from the same data. This ships as three PRs under this issue: 5E-1 autolens_profiling (exporter v2), 5E-2 PyAutoFit (estimate hook), 5E-3 PyAutoLens (estimator, data file, analyses).

Plan

  • 5E-1, autolens_profiling: the exporter adds per-instrument size fields (n_pixels_masked, n_vis, source pixels) from the simulator summaries, replaces the stale parallel_efficiency block with the measured curve, bumps to schema v2, regenerates catalogue/runtime_estimates.yaml, and adds --copy-to <PyAutoLens>.
  • 5E-2, PyAutoFit: resolve_fit_parallel takes the model and calls a duck-typed analysis.runtime_estimate(search, model, number_of_cores) after the Parallel: line, logging its line and never raising.
  • 5E-3, PyAutoLens:
    • ships autolens/config/runtime_estimates.yaml and a cached, schema-checked loader;
    • adds a RuntimeEstimate dataclass and the ported wall model;
    • adds al.estimate_runtime(...) and exports al.Setup;
    • the lens analyses implement runtime_estimate() and resources_per_eval().

Design calls (human-approved 2026-11-24):

  1. The estimator lives in PyAutoLens; Galaxy is untouched.
  2. Row matching: decision_id + setup_id + the nearest instrument size; otherwise a min–max band, with the largest peak_rss_gb for the memory cap.
  3. Honest labelling: "Nautilus heuristic"; interferometer/weak "uncalibrated (held-out 0.2–0.5×)"; other samplers "no estimate".
  4. al.estimate_runtime(...) rather than al.Setup.estimate.
  • Tier + merge mode: effective level: supervised; merge mode: human /prm (per PR)
Detailed implementation plan

Affected Repositories

  • PyAutoLens (primary, issue home)
  • autolens_profiling (5E-1)
  • PyAutoFit (5E-2)

Branch Survey

Repository Current Branch Dirty?
./autolens_profiling main clean
./PyAutoFit main clean
./PyAutoLens main clean

Suggested branches: feature/likelihood-lifecycle-p5e1-profiling, feature/likelihood-lifecycle-p5e2-fit, feature/likelihood-lifecycle-p5e3-lens, in worktree ~/Code/PyAutoLabs-wt/likelihood-lifecycle-p5e.

Implementation Steps

  1. 5E-1 scripts/misc/tooling/export_runtime_estimates.py:
    • for each row, add n_pixels_masked (imaging-type), n_vis (interferometer) and source_pixels when known, from the profiling simulator summaries / instrument definitions (find the canonical instrument-size source in the repo and cite it in the header);
    • replace the header parallel_efficiency with {curve: {1: 1.0, 2: 0.68, 4: 0.62, 8: 0.55, 16: 0.36, 32: 0.28}, likelihood: imaging/rectangular, setup_id: numba_cpu_sparse_fp64, source: autolens_inference phase 4 (wall/model.py)};
    • version: 2;
    • add --copy-to <path>, which writes the same file to <path>/autolens/config/runtime_estimates.yaml;
    • regenerate; keep the --check drift test and CI lint green.
  2. 5E-2 autofit runtime.py resolve_fit_parallel(search, analysis, model) (update its caller in abstract_search._fit_and_output): after the banner, hook = getattr(analysis, "runtime_estimate", None); if callable, line = hook(search=search, model=model, number_of_cores=resolution.number_of_cores); log it if it is a non-empty string; swallow any exception (debug log). Add runtime_estimate to files/parallel.json (estimate_line). Tests with a dummy analysis.
  3. 5E-3 PyAutoLens:
    • autolens/config/runtime_estimates.yaml (copied from 5E-1).
    • autolens/analysis/runtime_estimate.py (or autolens/setup/):
      • a loader (direct path, cached, schema version check);
      • RuntimeEstimate (ms_per_eval, record_id, instrument, matched_by, expected_evals, evals_model "nautilus-heuristic", parallel_efficiency, number_of_cores, wall_seconds, wall_band, calibrated: bool, note);
      • the ported wall-model constants and functions (cite autolens_inference wall/model.py);
      • estimate_runtime(dataset, model, search, setup, number_of_cores);
      • line() formatting, e.g. Estimate: ~1.9 ms/eval · Nautilus n_live=150 ≈ 2.1e5 evals (heuristic) · η=0.55 on 8 cores · ~7 min on this hardware.
    • Analyses (imaging, interferometer, point, weak, via the Lens setup mixin or analysis base):
      • runtime_estimate(search, model, number_of_cores) → line, or a "no estimate …" line, or None when there is no setup;
      • resources_per_eval() → {cpus_per_eval, peak_rss_gb} from the matched row, using the largest across instruments when unmatched.
    • Export estimate_runtime and Setup from autolens/__init__.py.
    • Tests: loader, schema mismatch, row matching (nearest size / band), labelling (uncalibrated / non-Nautilus), numba η, resources_per_eval feeding a fake ParallelResolution memory cap, the hook end-to-end with a MockSearch.
  4. Each repo's full suite; pyauto-heart smoke --affected-by <repo> for PyAutoFit and PyAutoLens.

Key Files

  • autolens_profiling/scripts/misc/tooling/export_runtime_estimates.py, autolens_profiling/catalogue/runtime_estimates.yaml
  • autofit/non_linear/search/runtime.py, autofit/non_linear/search/abstract_search.py
  • autolens/config/runtime_estimates.yaml (new), autolens/analysis/runtime_estimate.py (new), autolens/analysis/analysis/setup.py, autolens/__init__.py
  • Source: autolens_inference/scripts/misc/wall/model.py

Original Prompt

Click to expand starting prompt

Likelihood lifecycle phase 5E: runtime estimator: profiling exporter v2 with dataset sizes, a PyAutoFit estimate hook, and the PyAutoLens estimator, data file and memory cap

Type: feature
Target: PyAutoLens
Repos:

  • autolens_profiling
  • PyAutoFit
  • PyAutoLens
    Themes:
  • hpc-gpu
  • profiling
    Difficulty: large
    Autonomy: supervised
    Priority: high
    Status: draft
    Consequence: judge
    Witness: autolens_profiling runtime_estimates.yaml v2 carries per-instrument size fields and the measured parallel-efficiency curve, and the exporter can copy it into PyAutoLens (--copy-to). PyAutoFit's resolve_fit_parallel calls a duck-typed analysis.runtime_estimate(search, model, number_of_cores) after the Parallel: line and logs its line without ever raising. PyAutoLens ships autolens/config/runtime_estimates.yaml with a cached, schema-checked loader, a RuntimeEstimate dataclass, the ported autolens_inference wall model, and public al.estimate_runtime(dataset, model, search, setup, number_of_cores) plus al.Setup. The lens analyses implement runtime_estimate() (the "Estimate:" line) and resources_per_eval() (5D's memory cap goes live). Rows are matched by decision_id + setup_id and the nearest instrument size, with a min–max band when unmatched. Lines are labelled "Nautilus heuristic", interferometer/weak are flagged "uncalibrated", and other samplers get "no estimate". Each repo's suite is green, and smoke passes at each ship.
    Review-minutes: 30
    Unattended: no
    Lane: any
    Gate: 5D MERGED (PyAutoFit#1795: resolve_fit_parallel, resources_per_eval() hook). Plan and design calls approved by the human 2026-11-24.
    Epic: likelihood-lifecycle
    Phase: 5
    Parent: draft/research/autolens_profiling/likelihood_lifecycle_epic.md
    Filed: 2026-11-24

Context

  • Report §3.5, Estimator row: a RuntimeEstimate (ms_per_eval, source record id, expected_evals labelled as the Nautilus heuristic until phase 7, parallel efficiency, wall); a data file autolens/config/runtime_estimates.yaml regenerated by an autolens_profiling exporter; the banner's "Estimate:" line.
  • Survey 2026-11-24:
    • lens/autolens_profiling/catalogue/runtime_estimates.yaml (schema v1, tag 2026.10.25.1, 116 rows; fields likelihood, hardware_class, host_class, instrument, setup_id, role, decision_id, ms_per_eval, per_eval_source, cpus_per_eval, devices_per_eval, peak_rss_gb, workers_per_node, bound_by, calls_per_s_per_node, record_id).
    • There are no size fields, and the parallel_efficiency block is stale (1.0, "unmeasured").
    • The exporter is scripts/misc/tooling/export_runtime_estimates.py --pulse ../PyAutoPulse [--check] (stdlib; CI drift check in .github/workflows/lint.yml:127-132). Instrument sizes live in the profiling simulator summaries.
    • The wall model is lens/autolens_inference/scripts/misc/wall/model.py (stdlib): evals = 4.30 · n_live · d^1.637 · EVALS_FACTOR; a 0.014 s floor; 30 s startup; numba η {1:1.0, 2:.68, 4:.62, 8:.55, 16:.36, 32:.28}; per-call/per-eval overrides. It is Nautilus only; in-sample 0.56–1.59×; held-out interferometer 0.19–0.45× and weak 0.50–0.52× (uncalibrated).
    • Insight has no expected-evals table.
    • 5D resolve_fit_parallel (autofit runtime.py) has the search, the setup-resolved analysis and the ParallelResolution; it does not take the model yet.
    • resources_per_eval() expects cpus_per_eval and peak_rss_gb.
    • PyAutoLens ships autolens/config/* (pyproject package-data, MANIFEST.in). Follow PyAutoArray's direct-path loader precedent (RULES_PATH).
  • Design calls (human-approved 2026-11-24):
    1. The estimator lives in PyAutoLens; Galaxy is untouched (no estimate line for Galaxy fits).
    2. Row matching: decision_id + setup_id, nearest instrument by size (masked pixels for imaging, n_vis for interferometer). Otherwise a min–max band, and the memory cap uses the largest peak_rss_gb.
    3. Honest labelling: "Nautilus heuristic"; interferometer/weak "uncalibrated (held-out 0.2–0.5×)"; other samplers "no estimate for ".
    4. The API is al.estimate_runtime(...), not al.Setup.estimate, because Setup lives in PyAutoArray.
  • PRs, in order: 5E-1 autolens_profiling (project repo; ship_workspace; no pending-release) → 5E-2 PyAutoFit (tiny) → 5E-3 PyAutoLens (medium).

Out of scope

  • Phase 7 sampler campaign and expected-evals tables.
  • Workspace prose (5F) and assistant (5G).
  • The default flip (R6).
  • ModelAnalysis forwarding of modify_before_fit (separate follow-up).

Activity

  1. Jammy2211 commented on Nov 24, 2026

    @Jammy2211
    CollaboratorAuthor

    5E-1 shipped as PyAutoLabs/autolens_profiling#535: runtime_estimates.yaml v2 (per-row dataset sizes from the evidence files, the measured parallel-efficiency curve, --copy-to <PyAutoLens>). Gate: 1915 passed, ruff clean, --check current. 5E-2 (PyAutoFit hook) and 5E-3 (PyAutoLens estimator) follow.

  2. Jammy2211 commented on Nov 24, 2026

    @Jammy2211
    CollaboratorAuthor

    5E-2 shipped as PyAutoLabs/PyAutoFit#1796 (pending-release): duck-typed analysis.runtime_estimate(search, model, number_of_cores) hook after the Parallel: banner, logged and recorded as estimate_line in parallel.json; never affects a fit. Gate: 4383 passed, Heart GREEN, smoke 8/8. 5E-3 (PyAutoLens estimator) in progress.

  3. Jammy2211 commented on Nov 24, 2026

    @Jammy2211
    CollaboratorAuthor

    5E-3 shipped as #888 (pending-release): runtime_estimates.yaml v2, ported wall model, al.estimate_runtime / al.RuntimeEstimate / al.Setup, and runtime_estimate() + resources_per_eval() on the lens analyses. Gate: 1154 passed + 1 xfailed, Heart GREEN, smoke 4/4. Merge order: PyAutoFit#1796 first (this PR's CI clones PyAutoFit main), then #888, which closes this issue.

  4. Jammy2211 commented on Nov 24, 2026

    @Jammy2211
    CollaboratorAuthor

    Shipped

    Phase 5E merged in three PRs:

    #1796 and #888 are pending release. #888's first CI run failed only on the end-to-end hook test (resolve_fit_parallel(... model=)) until #1796 merged; the re-run was GREEN. Next in the epic: 5F (workspace prose).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions