Repository navigation
Description
Overview
Phase 2 (of 4) of the multi-dataset shared-state epic (#599 = phase 1 design, decisions D1–D6 + the H-removal amendment). Implements the imaging shared-state consumer: the shared object is the source-plane mesh geometry only (traced mesh centres) — per-exposure PSFs and pixel offsets make the mapper, mapping matrix, curvature matrix, and regularization matrix (user amendment: adaptive regularization is data-dependent) per-dataset.
Running under --auto (Autonomy: safe, feature/medium — mirrors the shipped PyAutoArray#344 / PyAutoLens#566 pattern): plan recorded here, run proceeds through the four-leg autonomous ship gate and ends at PR-open; merge stays human.
Plan
- PyAutoArray:
AbstractPreloadsgainssource_plane_mesh_grid; newPreloadsImagingsibling with the invariance-contract docstring (mesh geometry shareable across exposures under one lens model; mapper /F/ blurredL/Hare NOT — unlike the datacube whose channels share one grid, whose whole-mapper +Fpreload is untouched). JAX pytree registration mirroringPreloadsInterferometer. - PyAutoLens:
AnalysisImaging(shared_preloads=False)opt-in +shared_state_from(apply the lead factor'saa.DatasetModeloffset → trace the lead image-mesh once →PreloadsImaging(source_plane_mesh_grid=...));shared=threaded throughlog_likelihood_function→fit_from→FitImaging→TracerToInversion, mirroring PR#566. New reuse path inTracerToInversion: whenpreloads.source_plane_mesh_gridis set, skipimage_plane_mesh_grid_pg_list+ mesh tracing and build this dataset's mapper (its own offset grid) onto the preloaded mesh. - Unit tests (numpy-only): preloads container tests in
test_autoarray; intest_autolens, shared-vs-unsharedfigure_of_meritparity on offset datasets, opt-in default-off, single-dataset path byte-for-byte unchanged. - Out of scope: same-λ joint stacked inversion (D2 follow-up prompt
multi_joint_stack_inversion); workspace/workspace_test/profiling examples (phase 3 — includes the shared-vs-unshared assertion + runtime scripts mirroring the datacube pattern); docs (phase 4).
Detailed implementation plan
Affected Repositories
- PyAutoArray (primary — new preloads surface)
- PyAutoLens (consumer)
- Downstream test surface at gate time: PyAutoGalaxy + PyAutoLens suites (public API touched)
Branch Survey (2026-07-10)
| Repository | Current Branch | Dirty? | Note |
|---|---|---|---|
| ./PyAutoArray | main | clean | claims kernel-forward-chunking, rect-adapt exist but touch only inversion/mesh/ kernel-CDF files — zero overlap with preloads/; override recorded in active.md |
| ./PyAutoLens | main | clean |
Branch: feature/multi-shared-state-core-api in worktree ~/Code/PyAutoLabs-wt/multi-shared-state-core-api/
Implementation Steps
PyAutoArray/autoarray/preloads/abstract.py— addsource_plane_mesh_grid=NonetoAbstractPreloads.__init__+ docstring; keep pytree registration consistent.PyAutoArray/autoarray/preloads/imaging.py(new) —PreloadsImaging(AbstractPreloads)with the invariance-contract docstring; export asaa.PreloadsImaging.PyAutoLens/autolens/lens/to_inversion.py— in the mapper-construction flow, whenself._preloads.source_plane_mesh_gridis set (and no whole-mapper preload), bypassimage_plane_mesh_grid_pg_list+traced_mesh_grid_pg_listand build the mapper from this dataset's traced data grid onto the preloaded source-plane mesh.PyAutoLens/autolens/imaging/model/analysis.py—shared_preloadsflag,shared_state_from(instance)(leadDatasetModeloffset honored),log_likelihood_function(..., shared=None),fit_from(..., preloads=shared)threading; JAX pytree registration forPreloadsImaging.- Tests as above; full suites + downstream at the gate.
Key Files
autoarray/preloads/{abstract,interferometer}.py,autolens/interferometer/model/analysis.py— the shipped pattern to mirrorautolens/lens/to_inversion.py:379-460—mapper_galaxy_dictconstruction + existing preload short-circuit (NOT valid cross-dataset; the new path is mesh-level)autoarray/dataset/dataset_model.py— offset surface (no changes expected)
Original Prompt
Click to expand starting prompt
See PyAutoMind/issued/multi_shared_state_examples_phase_2_core_api.md (locked by #599 D1–D6 + amendment). Parent epic: issued/multi_shared_state_examples.md.
Activity
Jammy2211 commentedon Jul 10, 2026
Shipped to PR-open — 2026-07-10 (
--autosafe, four-leg gate)PRs (pending-release; PyAutoArray must merge first)
Gate record
test_autoarray896 passed; downstreamtest_autogalaxy962 passed (canonical checkout against branch PyAutoArray);test_autolens378 passed; 10 new/updated analysis tests.shared_preloads.pyJIT script).FactorGraphModelend-to-end: shared-vs-unshared log-likelihood bit-identical (−58.673099306030444),shared_state_fromcomputed once (lead only). Two CRLF-normalization diff inflations caught via the review surface and repaired byte-exactly.active.mdheart-ack:; binds to this launch only).What shipped
Design #599 D1–D6 + regularization amendment:
aa.PreloadsImaging+ mesh-geometry fields onAbstractPreloads(dataset-type-agnostic for the imaging+interferometer case);AnalysisImaging(shared_preloads=True)+shared_state_from+shared=/preloads=threading;TracerToInversionmesh-preload reuse path. Opt-in default-off; single-dataset path byte-for-byte unchanged.Next
Merge is human (PyAutoArray #380 first). Phase 3 (workspace example sections in
multi/features/{same_wavelength,wavelength_dependence,imaging_and_interferometer},workspace_testshared-vs-unshared assertion script +autolens_profilingmeasurement mirroring the datacube pattern, simulator shifts default 0) is prompted and issues after this merges.Jammy2211 commentedon Jul 10, 2026
Merged — 2026-07-10
f8a32d43b1513236daPhase 2 complete (both
pending-releasefor the next nightly). Phase 3 (workspace examples + workspace_test parity + profiling measurement) proceeds now under--auto. Closing.