Overview
Add a searches_minimal/ folder to autolens_workspace_developer that mirrors the equivalent folder in autofit_workspace_developer, but runs each sampler against the real MGE imaging likelihood (HST dataset) instead of the 1D Gaussian toy model. These scripts drive Nautilus, Dynesty, Emcee, scipy.L-BFGS-B, and NSS directly against PyAutoFit's Model / Analysis objects, bypassing the NonLinearSearch wrapper — useful for quickly smoke-testing a search against a realistic likelihood.
Plan
- Create
searches_minimal/ with one script per sampler (nautilus, dynesty, emcee, lbfgs, nss_simple, nss_jit, nss_grad).
- Share the HST dataset + MGE model +
AnalysisImaging setup via a small _setup.py helper.
- NumPy-path samplers use the standard
AnalysisImaging and model.instance_from_vector.
nss_simple.py wraps the NumPy analysis in jax.pure_callback.
nss_jit.py / nss_grad.py use AnalysisImaging(use_jax=True) + autofit.jax.register_model for the pure-JAX path — exercising the MGE gradient support.
- Keep run times short (small
n_live, short chains) — these are smoke tests, not converged runs.
Detailed implementation plan
Affected Repositories
- autolens_workspace_developer (primary)
Work Classification
Workspace
Branch Survey
| Repository |
Current Branch |
Dirty? |
| ./autolens_workspace_developer |
main |
clean |
Suggested branch: feature/searches-minimal
Worktree root: ~/Code/PyAutoLabs-wt/searches-minimal/ (created later by /start_workspace)
Implementation Steps
- Create
searches_minimal/_setup.py with build_dataset(instrument=\"hst\"), build_model(mask_radius=3.5), build_analysis(dataset, use_jax=False) helpers. Mirrors the setup block in jax_profiling/imaging/mge.py (mask radius 3.5, radial-bin over-sampling, 20-gaussian MGE bulges for lens + source, Isothermal mass + ExternalShear).
- Create
searches_minimal/nautilus_simple.py — load setup, run nautilus.Sampler with n_live=50, print best-fit lens / source parameters + log evidence + wall time / likelihood-call count.
- Create
searches_minimal/dynesty_simple.py — dynesty.NestedSampler with small nlive.
- Create
searches_minimal/emcee_simple.py — emcee.EnsembleSampler, walkers initialised near prior medians with small scatter, short chain (few hundred steps).
- Create
searches_minimal/lbfgs_simple.py — scipy.optimize.minimize(method=\"L-BFGS-B\") with bounds derived from the model's priors via model.physical_upper_limits_for_parameters / physical_lower_limits_for_parameters, started at model.physical_values_from_prior_medians.
- Create
searches_minimal/nss_simple.py — run_nested_sampling using NumPy analysis wrapped in jax.pure_callback (same pattern as autofit reference).
- Create
searches_minimal/nss_jit.py — AnalysisImaging(use_jax=True) + autofit.jax.register_model(model) + params_tree = jax.tree_util.tree_map(jnp.asarray, instance), then run_nested_sampling with the pure-JAX likelihood.
- Create
searches_minimal/nss_grad.py — same pure-JAX setup, then run_hmc_sequential_mc to exercise jax.grad through MGE.
- Smoke-test each script:
NUMBA_CACHE_DIR=/tmp/numba_cache MPLCONFIGDIR=/tmp/matplotlib python searches_minimal/<name>.py, verify a best-fit instance + finite log evidence are printed.
Key Files
searches_minimal/_setup.py — shared HST dataset + MGE model + analysis setup.
searches_minimal/nautilus_simple.py — direct Nautilus example.
searches_minimal/dynesty_simple.py — direct Dynesty example.
searches_minimal/emcee_simple.py — direct Emcee example.
searches_minimal/lbfgs_simple.py — direct scipy L-BFGS-B example.
searches_minimal/nss_simple.py — NSS with NumPy likelihood via jax.pure_callback.
searches_minimal/nss_jit.py — NSS with pure-JAX MGE likelihood.
searches_minimal/nss_grad.py — NSS HMC-SMC with gradient-accelerated MGE.
Original Prompt
Click to expand starting prompt
The folder autofit_workspace_developer/searches_minimal has examples of how to set up an likelihood function and
have it so a search runs with a minimal interface, for quick testing of lieklihood functions.
Can you set up all of these on autolens_workspacde_developer, using the same hst data used in jax_profiling/imaging
and using the mge model which now supports gradients.
Overview
Add a
searches_minimal/folder toautolens_workspace_developerthat mirrors the equivalent folder inautofit_workspace_developer, but runs each sampler against the real MGE imaging likelihood (HST dataset) instead of the 1D Gaussian toy model. These scripts driveNautilus,Dynesty,Emcee,scipy.L-BFGS-B, andNSSdirectly against PyAutoFit'sModel/Analysisobjects, bypassing theNonLinearSearchwrapper — useful for quickly smoke-testing a search against a realistic likelihood.Plan
searches_minimal/with one script per sampler (nautilus, dynesty, emcee, lbfgs, nss_simple, nss_jit, nss_grad).AnalysisImagingsetup via a small_setup.pyhelper.AnalysisImagingandmodel.instance_from_vector.nss_simple.pywraps the NumPy analysis injax.pure_callback.nss_jit.py/nss_grad.pyuseAnalysisImaging(use_jax=True)+autofit.jax.register_modelfor the pure-JAX path — exercising the MGE gradient support.n_live, short chains) — these are smoke tests, not converged runs.Detailed implementation plan
Affected Repositories
Work Classification
Workspace
Branch Survey
Suggested branch:
feature/searches-minimalWorktree root:
~/Code/PyAutoLabs-wt/searches-minimal/(created later by/start_workspace)Implementation Steps
searches_minimal/_setup.pywithbuild_dataset(instrument=\"hst\"),build_model(mask_radius=3.5),build_analysis(dataset, use_jax=False)helpers. Mirrors the setup block injax_profiling/imaging/mge.py(mask radius 3.5, radial-bin over-sampling, 20-gaussian MGE bulges for lens + source, Isothermal mass + ExternalShear).searches_minimal/nautilus_simple.py— load setup, runnautilus.Samplerwithn_live=50, print best-fit lens / source parameters + log evidence + wall time / likelihood-call count.searches_minimal/dynesty_simple.py—dynesty.NestedSamplerwith smallnlive.searches_minimal/emcee_simple.py—emcee.EnsembleSampler, walkers initialised near prior medians with small scatter, short chain (few hundred steps).searches_minimal/lbfgs_simple.py—scipy.optimize.minimize(method=\"L-BFGS-B\")with bounds derived from the model's priors viamodel.physical_upper_limits_for_parameters/physical_lower_limits_for_parameters, started atmodel.physical_values_from_prior_medians.searches_minimal/nss_simple.py—run_nested_samplingusing NumPy analysis wrapped injax.pure_callback(same pattern as autofit reference).searches_minimal/nss_jit.py—AnalysisImaging(use_jax=True)+autofit.jax.register_model(model)+params_tree = jax.tree_util.tree_map(jnp.asarray, instance), thenrun_nested_samplingwith the pure-JAX likelihood.searches_minimal/nss_grad.py— same pure-JAX setup, thenrun_hmc_sequential_mcto exercisejax.gradthrough MGE.NUMBA_CACHE_DIR=/tmp/numba_cache MPLCONFIGDIR=/tmp/matplotlib python searches_minimal/<name>.py, verify a best-fit instance + finite log evidence are printed.Key Files
searches_minimal/_setup.py— shared HST dataset + MGE model + analysis setup.searches_minimal/nautilus_simple.py— direct Nautilus example.searches_minimal/dynesty_simple.py— direct Dynesty example.searches_minimal/emcee_simple.py— direct Emcee example.searches_minimal/lbfgs_simple.py— direct scipy L-BFGS-B example.searches_minimal/nss_simple.py— NSS with NumPy likelihood viajax.pure_callback.searches_minimal/nss_jit.py— NSS with pure-JAX MGE likelihood.searches_minimal/nss_grad.py— NSS HMC-SMC with gradient-accelerated MGE.Original Prompt
Click to expand starting prompt
The folder autofit_workspace_developer/searches_minimal has examples of how to set up an likelihood function and
have it so a search runs with a minimal interface, for quick testing of lieklihood functions.
Can you set up all of these on autolens_workspacde_developer, using the same hst data used in jax_profiling/imaging
and using the mge model which now supports gradients.