Repository navigation
feat: apply_setup, operator/backend mismatch check and Setup.apply_threads (5B-2) - #710
Merged
Merged
Conversation
…hreads (5B-2) Imaging.apply_setup / Interferometer.apply_setup attach the operator or transformer an aa.Setup names; datasets store .setup and carry it through apply_mask / apply_noise_scaling / apply_over_sampling. The inversion factory raises InversionException on an operator/backend mismatch. Setup.apply_threads pins numba and threadpoolctl thread pools, safely inside multiprocessing workers. Part of #708 (likelihood-lifecycle phase 5B-2). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The unittest-nojax leg failed on five new tests that build the JAX ImagingSparseOperator. Guard their JAX parts with pytest.importorskip, as other test modules do; the numba halves still run without jax. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Likelihood-lifecycle phase 5B-2 (second PR under #708; 5B-1 was #709). This applies a compute setup to a dataset.
Imaging.apply_setup/Interferometer.apply_setupattach the operator or transformer anaa.Setupnames. The inversion factory raises on an operator/backend mismatch instead of silently taking another path.Setup.apply_threads()pins the run-time thread pools.Part of #708 (stays open until this merges).
API Changes
Imaging.apply_setup(setup): a sparse setup attachesapply_sparse_operator(jax) orapply_sparse_operator_cpu(numba); a dense setup attaches none. It is idempotent.Interferometer.apply_setup(setup):_nufftusesTransformerNUFFT, and_wtilde(sparse) attachesapply_sparse_operator. A dataset constructed with asetupskips the >10,000-visibility DFT check, because the setup decides the transformer.setup=and store.setup. Imaging carries it throughapply_mask/apply_noise_scaling(the operator is rebuilt for the new mask or noise-map) andapply_over_sampling. Interferometer carries it throughapply_sparse_operator*andfrom_fits.InversionExceptionon an operator/backend mismatch.Setup.apply_threads(n=None)callsnumba.set_num_threads, plusthreadpoolctlif it is installed. It never raises, and inside multiprocessing workers it leaves numba alone.See full details below.
Test Plan
pytest test_autoarray: 2594 passedpyauto-heart readiness --dev --repos PyAutoArray): 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 PyAutoArray --jobs 3: 7/7 workspaces PASS (autogalaxy, autolens, autolens_test, euclid, howtolens, autocti, autocti_test), run against this branch via PYAUTO_ROOTFull API Changes (for automation & release notes)
Added
Imaging.apply_setup(setup: Setup | str, batch_size=128) -> Imaging: attaches the operator the setup names. It is idempotent (returnsselfwhen the operator already matches).Interferometer.apply_setup(setup: Setup | str, **sparse_operator_kwargs) -> Interferometer: attaches the NUFFT transformer and/or the sparse operator the setup names. It is idempotent.Imaging(..., setup=None),Interferometer(..., setup=None),Interferometer.from_fits(..., setup=None): the dataset stores the setup as.setup. Passing it here only records it.Setup.apply_threads(n=None) -> int | None: pins numba and BLAS/OpenMP threads and returns the count applied.autoarray.setup.setup.setup_from(setup): converts aSetup, a setup_id string orNoneto aSetup(orNone).Changed
Imaging.apply_mask/apply_noise_scaling: with a.setup, the result has the setup re-applied, and the "sparse operator discarded" warning is not emitted. Without a setup, behaviour is unchanged.Interferometer.__init__: asetupdisables the >10,000-visibility DFT check. A_nufftsetup replaces a non-NUFFTtransformer_classwithTransformerNUFFT.inversion_imaging_from/inversion_interferometer_fromraiseInversionExceptionwhen:xp; a numba setup carries the JAX operator, or a jax setup the numba operator; a sparse setup has no operator; a dense/na setup has an operator;xp; a sparse setup has no operator; a dense/na setup has an operator.Still allowed: a JAX operator under numpy (visualization), and func-list-only imaging inversions, which stay on the mapping formalism.
Migration
apply_sparse_operator()(orapply_setup("jax_...")) for JAX fits.Notes:
xppicks the route.apply_setup, once when the analysis is constructed.Generated by the PyAutoLabs agent workflow.
🤖 Generated with Claude Code