Skip to content

feat: AnalysisSetupMixin.adopt_backend; restore the dataset when a default setup is undone - #761

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/likelihood-lifecycle-r6d-prerelease-fixes
Nov 26, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/likelihood-lifecycle-r6d-prerelease-fixes

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Part of PyAutoLabs/PyAutoLens#895 (likelihood-lifecycle R6 pre-release fixes; must merge before the release carrying R6 phase A). Same branch feature/likelihood-lifecycle-r6d-prerelease-fixes in PyAutoFit, PyAutoGalaxy and PyAutoLens. Merge order: Fit → Galaxy → Lens.

  • AnalysisSetupMixin implements the new PyAutoFit hooks: setup_is_default reads setup_defaulted (and stays True after adoption); adopt_backend(use_jax) returns early for explicit setups, otherwise switches the analysis to the no-setup path on the graph's backend (clears setup_input / setup / setup_chosen_by, so no setup.json; _use_jax = use_jax_from(use_jax)) and logs one line saying the graph chose the backend and what setup="auto" had chosen for that factor alone.
  • AnalysisDataset keeps the dataset as given (_dataset_before_setup) and _undo_resolved_setup restores it, undoing any operator the auto setup attached, re-runs check_setup_consistency on the new backend and re-preloads grids (preloading factored into _preload_grids(); modify_before_fit unchanged). The kept reference shares the data arrays (pickle 186013 → 186276 bytes).

API Changes

AnalysisImaging / AnalysisInterferometer (via AnalysisSetupMixin / AnalysisDataset) implement setup_is_default and adopt_backend.
See full details below.

Test Plan

  • Every new test failed in a control run without the source change and passes with it
  • Suites with JAX (serial): PyAutoFit 4399, PyAutoGalaxy 1685, PyAutoLens 1182 passed
  • No-JAX leg reproduced as CI (venv, [optional] extras, jax family uninstalled): PyAutoFit 4072, PyAutoGalaxy 1601, PyAutoLens 1114 passed, 0 failed
  • End-to-end in test mode: autolens_workspace weak/modeling.py on the default (JAX) setup, and multi_dataset/features/imaging_and_interferometer/modeling.py + imaging_and_point_source/modeling.py with every use_jax=True removed — all exit 0
  • Heart dev-ship readiness: GREEN; pyauto-heart smoke --affected-by PyAutoFit against the task worktree: 8/8 workspaces passed
  • New test_analysis_factor_graph_setup.py (6; 3 failed on control): a default imaging (rectangular, numba sparse) + interferometer (MGE, JAX NUFFT) graph adopts one backend, the imaging dataset is restored, the graph likelihood is finite; use_jax=False push-down; following an explicit setup; explicit disagreement raises; agreeing defaults keep the sparse operator
Full API Changes (for automation & release notes)

Added

  • AnalysisSetupMixin.setup_is_default, AnalysisSetupMixin.adopt_backend(use_jax), AnalysisDataset._undo_resolved_setup(), AnalysisDataset._preload_grids().

Generated by the PyAutoLabs agent workflow.

🤖 Generated with Claude Code

…fault setup is undone

Part of PyAutoLabs/PyAutoLens#895.

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 26, 2026
@Jammy2211
Jammy2211 merged commit 5bdbfcb into main Nov 26, 2026
5 checks passed
@Jammy2211
Jammy2211 deleted the feature/likelihood-lifecycle-r6d-prerelease-fixes branch November 26, 2026 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release PR queued for the next release build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant