Skip to content

feat: setup="auto" (opt-in), setup.json and setup banner in the analyses (5C-1) - #752

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/likelihood-lifecycle-p5c1-galaxy
Nov 24, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/likelihood-lifecycle-p5c1-galaxy

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Likelihood-lifecycle phase 5C-1, the first of two PRs under PyAutoLabs/PyAutoLens#881. The PyAutoGalaxy dataset analyses accept setup=None | "auto" | aa.Setup | "<setup_id>". At fit start (modify_before_fit) the setup is resolved from the dataset and model, which sets the analysis backend. It is then applied to the dataset (apply_setup), checked for an operator/backend mismatch outside the likelihood, pins the thread pools, is logged as a banner line and is written to files/setup.json. Following ruling R6 it is opt-in: without setup=, nothing changes except one "auto would choose …" log line.

API Changes

  • ag.AnalysisImaging(..., setup=None) / ag.AnalysisInterferometer(..., setup=None) and AnalysisDataset(..., setup=None): "auto" picks the Pulse-designated setup via aa.Setup.auto (PYAUTO_SETUP=<setup_id> overrides it). An aa.Setup or setup_id string is used as given. use_jax= is honoured as before when setup is None.
  • AnalysisDataset.resolve_setup(model), called first in modify_before_fit. With a setup, _use_jax follows the setup's backend, falling back to numpy when JAX is disabled or missing.
  • New files/setup.json (setup fields plus chosen_by: auto / explicit / PYAUTO_SETUP).
  • New module autogalaxy.analysis.setup_util (rule-key mapping, banner, setup.json dict, consistency check).
    See full details below.

Test Plan

  • pytest test_autogalaxy: 1641 passed
  • Heart dev gate (pyauto-heart readiness --dev --repos PyAutoGalaxy): GREEN. Non-blocking shown reasons: manifest drift (1 workspace checkout mismatch vs repos.yaml); release validation has no rehearsal for current source.
  • pyauto-heart smoke --affected-by PyAutoGalaxy --jobs 3: 5/5 workspaces PASS (autogalaxy, autolens, autolens_test, euclid, howtolens), run against this branch via PYAUTO_ROOT
Full API Changes (for automation & release notes)

Added

  • setup keyword on AnalysisDataset, AnalysisImaging and AnalysisInterferometer.
  • AnalysisDataset.resolve_setup(model), plus the attributes setup_input, setup (the resolved aa.Setup or None) and setup_chosen_by.
  • autogalaxy.analysis.setup_util: setup_input_from, dataset_type_from, mesh_variant_from, mesh_classes_from, setup_key_from / setup_key_and_note_from, use_jax_from, check_setup_consistency, chosen_by_from, setup_banner_from, setup_dict_from.
  • files/setup.json is written by save_attributes when a setup was resolved.

Changed

  • AnalysisDataset.modify_before_fit resolves the setup before preloading grids, so the grids belong to the dataset the likelihood uses. Without a setup it only logs the "auto would choose …" line, and also runs hardware detection (Environment.detect(), about 1.4 s on the first call in a process when nvidia-smi is present).

Migration

  • None. The new behaviour is opt-in.

Notes:

  • Rule key: the dataset type plus the model's mesh: DelaunayNN → delaunay_nn; Delaunay and its subclasses → delaunay; rectangular meshes → rectangular; no mesh → mge. With several meshes the most expensive wins. A missing row (e.g. interferometer/delaunay_nn) falls back to the nearest variant, and the banner says so.
  • The JAX line from log_fit_start can be stale when a setup flips the backend. The banner is the authoritative report (approved design call 1).
  • Private helpers: check_setup_consistency calls PyAutoArray's private factory._check_imaging_setup_consistency / _check_interferometer_setup_consistency. A rename there would break it.
  • Factor graphs: FactorGraphModel does not forward modify_before_fit, so setup="auto" inside an AnalysisFactor is not applied yet. The guard that raises lands in 5C-2, and setup agreement in 5D.
  • Next: 5C-2 (PyAutoLens: lens analyses, point, weak, factor-graph guard).

Generated by the PyAutoLabs agent workflow.

🤖 Generated with Claude Code

…et analyses (5C-1)

AnalysisImaging / AnalysisInterferometer accept setup=None|"auto"|aa.Setup|
"<setup_id>". modify_before_fit resolves it from the dataset and model
(pixelization mesh or MGE), sets the backend, applies it to the dataset,
runs the operator/backend consistency check outside the likelihood, pins
threads, logs a banner and writes files/setup.json. Without setup= nothing
changes beyond one "auto would choose" log line (ruling R6).

Part of PyAutoLabs/PyAutoLens#881 (likelihood-lifecycle phase 5C-1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Nov 24, 2026
@Jammy2211
Jammy2211 merged commit 5bcb54a into main Nov 24, 2026
5 checks passed
@Jammy2211
Jammy2211 deleted the feature/likelihood-lifecycle-p5c1-galaxy branch November 24, 2026 11:48
@pyautolabs-bot pyautolabs-bot Bot removed the pending-release PR queued for the next release build label Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant