Skip to content

feat: factors left on the default setup adopt one shared backend in a FactorGraphModel - #1801

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.

Under the R6 default setup="auto", a FactorGraphModel mixing dataset types (imaging + interferometer, imaging + point) failed check_setup_agreement: each default-constructed factor resolved its own setup. Human ruling: factors left on the default setup adopt one shared backend.

  • New generic hooks on af.Analysis: setup_is_default (property, False) and adopt_backend(use_jax) (no-op), forwarded by AnalysisFactor and ModelAnalysis (which also refreshes _use_jax).
  • FactorGraphModel.adopt_shared_backend(), called in modify_before_fit between forwarding and check_setup_agreement. Factors the user configured (setup= or use_jax=) are never changed; if they disagree it still raises. Otherwise the backend is the graph's use_jax, else the configured factors' common backend, else JAX when available. Defaulted factors adopt it when setups disagree or when they differ from a set backend. Nested graphs implement the hooks too; expectation propagation never calls this path.
  • check_setup_agreement's message explains the default vs explicit distinction.

API Changes

Added af.Analysis.setup_is_default, af.Analysis.adopt_backend(use_jax), FactorGraphModel.adopt_shared_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
  • test_factor_graph_setup.py (+8, mock analyses; 7 failed on control)
Full API Changes (for automation & release notes)

Added

  • af.Analysis.setup_is_default → bool (default False); af.Analysis.adopt_backend(use_jax: bool) (no-op default); both forwarded by AnalysisFactor, ModelAnalysis, nested FactorGraphModel.
  • af.FactorGraphModel.adopt_shared_backend().

Changed

  • FactorGraphModel.modify_before_fit aligns factors left on the default setup before check_setup_agreement.

Generated by the PyAutoLabs agent workflow.

🤖 Generated with Claude Code

… FactorGraphModel

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 68075ce into main Nov 26, 2026
9 of 10 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