Repository navigation
Description
Overview
Likelihood-lifecycle epic, phase 5B (PyAutoArray only). This adds aa.Setup and aa.Setup.auto, which pick the Pulse-designated optimal compute setup (backend, device, operator, precision, transformer) for a likelihood on the current hardware. It also adds dataset.apply_setup, which attaches the matching operator or transformer, and an inversion-factory check that refuses an operator/backend mismatch. It builds on 5A (PyAutoNerves#223: autonerves.environment). It ships as two PRs under this issue.
Plan
5B-1: choosing a setup. No dataset behaviour changes.
aa.Setup: the setup tuple plus its provenance (rule, regime, hardware class, Pulse decision id, extrapolated).autoarray/config/setup_rules.yaml, generated from the 39 Pulse designations with a provenance header.aa.Setup.auto(dataset_type, variant)reads the hardware viaEnvironment.detect().PYAUTO_SETUP=<setup_id>or an explicitaa.Setup(...)always wins.
5B-2: applying a setup.
Imaging.apply_setup/Interferometer.apply_setup: idempotent, and carried throughapply_mask/apply_over_sampling/apply_noise_scaling.- The inversion factory raises on an operator/backend mismatch.
- Run-time thread helper.
Design calls (human-approved 2026-11-23):
- Hardware with no designation (a laptop, a non-A100 GPU) uses the nearest class, with
extrapolated=True. - The parity test regenerates the table from a local Pulse checkout, and is skipped without one.
- Lens-scale keys (group, multi_galaxy, cluster, point source) are resolved by the caller in 5C.
- The mismatch check raises rather than warns; a smoke hit stops and is reported.
- Tier + merge mode: effective level: supervised; merge mode: human /prm (per PR)
Detailed implementation plan
Affected Repositories
- PyAutoArray (primary)
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| ./PyAutoArray | main | clean |
Suggested branch: feature/likelihood-lifecycle-p5b-array (5B-1). 5B-2 goes on a follow-up branch after 5B-1 merges.
Implementation Steps
autoarray/setup/setup.py:- A frozen
Setupdataclass (backend,device,operator,precision,transformer,rule_id,regime,hardware_class,decision_id,extrapolated), withfrom_setup_id()and.setup_id, usingautonerves.environment.parse_setup_intent's grammar. Setup.auto(dataset_type, variant, regime="standard", environment=None): an explicitPYAUTO_SETUPsetup_id wins; otherwise the hardware class comes fromEnvironment.detect()(gpu → gpu_a100, else cpu_many_core, withextrapolated=Trueunless the GPU name contains A100 or the CPU is many-core) and the rule table is looked up. An unknown key raises an error listing the known keys.
- A frozen
- Rule table:
autoarray/setup/generate_rules.py --pulse <path>reads PyAutoPulsedecisions.yaml(kind: designation) and writesautoarray/config/setup_rules.yaml, with a header holding the Pulse commit and date, and rows of likelihood, regime, hardware_class, optimal, secondary, decision_id and rule.- Tests: the schema; every setup_id round-trips;
Setup.autofor every row with a faked Environment; the override precedence; the parity regeneration whenPYAUTO_PULSE, or a sibling Pulse checkout, exists, skipped otherwise.
- (5B-2)
apply_setup:- Imaging: a sparse setup uses
apply_sparse_operator(jax) orapply_sparse_operator_cpu(numba); a dense setup attaches nothing. - Interferometer: a
_nufftsetup uses the NUFFT transformer (under auto this replaces the >10,000-visibility DFT guard); a_wtildesetup usesapply_sparse_operator. - The dataset stores
.setup, and theapply_*methods carry it.
- Imaging: a sparse setup uses
- (5B-2) Inversion factory consistency check for imaging and interferometer, with a test per mismatch.
- (5B-2)
Setup.apply_threads():numba.set_num_threads, plus threadpoolctl when installed. It is safe inside multiprocessing workers (no prange in workers; it pins and never raises). - Full test suite, plus
pyauto-heart smoke --affected-by PyAutoArrayat each ship.
Key Files
autoarray/setup/(new),autoarray/config/setup_rules.yaml(new)autoarray/dataset/imaging/dataset.py,autoarray/dataset/interferometer/dataset.pyautoarray/inversion/inversion/factory.pyautoarray/__init__.py(exportSetup)- Rule source: PyAutoPulse
decisions.yaml
Original Prompt
Click to expand starting prompt
Likelihood lifecycle phase 5B: PyAutoArray aa.Setup, Setup.auto, rule table from the Pulse designations, dataset.apply_setup, operator/backend consistency check
Type: feature
Target: PyAutoArray
Repos:
- PyAutoArray
Themes: - hpc-gpu
- profiling
Difficulty: large
Autonomy: supervised
Priority: high
Status: draft
Consequence: judge
Witness: PyAutoArray main carriesaa.Setup(the report §3.1 setup tuple plusrule_id,regime,hardware_class,decision_id,extrapolated) withSetup.from_setup_id()round-tripping every setup_id in the rule table;autoarray/config/setup_rules.yamlgenerated from PyAutoPulsedecisions.yaml(39 designations) with a provenance header, and a parity test that regenerates it from a Pulse checkout when one is available (skipped otherwise);aa.Setup.auto(dataset_type, variant, environment=None)returns the designated optimal setup for every (likelihood, hardware class) row, unit-tested with a monkeypatchedEnvironment;PYAUTO_SETUP=<setup_id>and an explicitaa.Setup(...)always win;Imaging.apply_setup/Interferometer.apply_setupattach the matching operator/transformer, are idempotent and surviveapply_mask/apply_over_sampling/apply_noise_scaling; the inversion factory raises a clear error on an operator/backend mismatch instead of silently taking another path; full test suite green
Review-minutes: 30
Unattended: no
Lane: any
Gate: 5A MERGED 2026-11-23 (PyAutoNerves#223;autonerves.environment.Environment.detect()andparse_setup_intent()on Nerves main; Heart lib-tests install Nerves from source main, so no release is needed for Array CI). Boundary table (report §3.4) and R6 = opt-in first approved 2026-11-16.
Epic: likelihood-lifecycle
Phase: 5
Parent: draft/research/autolens_profiling/likelihood_lifecycle_epic.md
Filed: 2026-11-23
Context
- Phase 5 order: 5A Nerves (done) → 5B Array (this prompt) → 5C Galaxy+Lens (
setup="auto"on analyses,setup.json, banner, SLaM threading) → 5D Fit (number_of_cores="auto") → 5E estimator → 5F–5H workspace/assistant/science. One issue in PyAutoArray. - Design: report §3.5, PyAutoArray row (
draft/research/autolens_profiling/likelihood_lifecycle_epic_report.md):aa.Setupdataclass;Setup.auto(...)with rule tableconfig/setup_rules.yamlgenerated from the Pulse designation decisions; regimes computed from the dataset;dataset.apply_setup(setup)idempotent and carried byapply_over_sampling/apply_mask/apply_noise_scaling; inversion factory raises when operator and backend disagree; threads at runtime vianumba.set_num_threads(+ threadpoolctl if available). - Boundary (report §3.4): auto decides backend, device, operator, precision, transformer/route, threads; never the model (mesh, over-sampling, regularisation), the sampler or the HPC request; an explicit override always wins.
- Rule source:
@PyAutoPulse/decisions.yaml, 39kind: designationrows, keyed (likelihood =<dataset_type>/<variant>, regime =standard, hardware_class ∈ {cpu_many_core, gpu_a100}) →optimal: <setup_id>,secondary: [...],rule(one sentence in dataset terms). Examples: imaging/{rectangular,delaunay,delaunay_nn} cpu →numba_cpu_sparse_fp64, gpu →jax_gpu_dense_fp64; imaging/mge cpu →jax_cpu_dense_fp64; interferometer pixelized cpu →numba_cpu_sparse_fp64_wtilde, gpu →jax_gpu_sparse_fp64_wtilde; interferometer/mge →jax_{cpu,gpu}_dense_fp64_nufft; point-source/cluster →jax_{cpu,gpu}_na_fp64. - Array knows dataset classes, not lens-scale concepts: group / multi_galaxy / cluster / point-source likelihood keys are resolved by the caller (5C passes
dataset_type/variant); 5B ships the full table and the lookup, and the Array-level helpers for imaging and interferometer. - Existing code:
@PyAutoArray/autoarray/dataset/imaging/dataset.py(apply_sparse_operator,apply_sparse_operator_cpu,apply_mask,apply_over_sampling,apply_noise_scaling),@PyAutoArray/autoarray/dataset/interferometer/dataset.py(the >10,000-visibility DFT guard,apply_sparse_operator),@PyAutoArray/autoarray/inversion/inversion/factory.py(operator dispatch),@PyAutoArray/autoarray/settings.py(interferometer_route).
Out of scope
setup="auto" on analyses, setup.json, banner, SLaM threading (5C); number_of_cores="auto" (5D); the estimator (5E); workspace prose (5F). Mixed precision is never chosen by auto (R4). No compute.
Activity
Jammy2211 commentedon Nov 23, 2026
5B-1 PR created — awaiting human /prm
PR: #709 (pending-release), commit 4d54c54.
test_autoarray/setup85 passed. That includes the parity regeneration against a local Pulse checkout at 94a101f4, which ran rather than being skipped. Full suite: 2562 passed.pyauto-heart smoke --affected-by PyAutoArray, run against the task worktree: 7/7 PASS. autolens and autolens_test failed on the first parallel run because two environments were building wheels from the same library source trees at once. Rerun one at a time, both PASS.datacube/delaunayhas only a CPU designation, so on a GPU nodeautoreturns that CPU setup withextrapolated=True.Next: 5B-2 (
apply_setup, the inversion-factory mismatch check, run-time threads) on a follow-up branch once #709 merges.Jammy2211 commentedon Nov 24, 2026
5B-2 shipped as #710 (pending-release):
Imaging/Interferometer.apply_setup, inversion-factory operator/backend mismatch check (raises),Setup.apply_threads(). Gate: 2594 tests pass, Heart dev GREEN, smoke 7/7 against the branch. This issue stays open until #710 merges; the close-out carries pending-release lines for #709 and #710.Jammy2211 commentedon Nov 24, 2026
Shipped
Phase 5B is merged in two PRs:
aa.Setup,Setup.auto, andsetup_rules.yamlgenerated from the 39 Pulse designations.Imaging/Interferometer.apply_setup, the inversion-factory operator/backend mismatch check (it raises), andSetup.apply_threads().Both are pending release. Next: phase 5C (PyAutoGalaxy + PyAutoLens:
setup="auto"opt-in,setup.json, banner, multi-dataset and SLaM setup threading, lens-scale keys).