Skip to content

research: 4-lens + 4-source MGE search benchmark (JAX gradient optimizers vs Nautilus) #82

Description

@Jammy2211

Overview

searches/ currently runs a JAX gradient MAP optimizer (af.MultiStartAdam) only on the single-lens/single-MGE-source cell. This task extends that proven MGE cell to a 4-deflector + 4-source group-scale model (~50–55 non-linear params) to answer: do the JAX gradient max-likelihood optimizers scale to a higher-dimensional, harder lens model? We benchmark the MultiStart gradient family (fixed-step and auto-convergence) against Nautilus and check truth recovery. If cold-start optimizers fail, a careful-initialization arm follows.

Plan

  • Write simulators/group4_mge.py — simulate a 4-lens + 4-source MGE imaging dataset with known truth (truth.json).
  • Add a group/mge cell to the searches/ harness (_setup.py dataset+model builders, AnalysisImaging).
  • Add searches/_recovery.py — compare max_log_likelihood_instance to truth; emit a per-galaxy recovery block into the summary JSON.
  • Register the MultiStart gradient family in two modes — fixed-step (convergence=None) and automatic-convergence (af.MultiStartGradientConvergence), including a first-class multi_start_prodigy_autoconv cell — plus Nautilus as the reference.
  • Run the benchmark, aggregate a recovery + wall-time comparison.
  • Contingency: if cold-start fails recovery, add narrow-prior / warm-start initialization and re-benchmark.
Detailed implementation plan

Affected Repositories

  • autolens_profiling (primary) — workspace/research only, no library source changes

Branch Survey

Repository Current Branch Dirty?
./autolens_profiling research/multiband-compile-ab dirty (untracked dataset/imaging/jwst_lw/)

Suggested branch: feature/group4-mge-search-benchmark (fresh worktree off main via /start_workspace)

Model (settled)

  • 4 lenses: al.mp.Isothermal mass + MGE light (al.model_util.mge_model_from), ExternalShear on lens_0; per-galaxy centre prior seeded near truth.
  • 4 sources: per-galaxy MGE light at distinct source-plane positions. Amplitudes stay linear (inversion); non-linear count ~50–55.

Samplers

  • nautilus (reference), and MultiStart JAX family run fixed-step (n_steps=300) and auto-convergence (MultiStartGradientConvergence(check_for_convergence=True, window=50, rtol=1e-4, atol=1e-3, min_steps=100)). First-class multi_start_prodigy_autoconv cell; summary surfaces actual steps-taken for the early-stop-vs-fixed-300 comparison.

Implementation Steps

  1. simulators/group4_mge.py (mirror simulators/imaging.py CLI + simulators/group.py geometry) -> dataset + truth.json under dataset/imaging/group4_mge/<instrument>/.
  2. searches/_setup.py: dataset_class="group" -> _build_group_imaging (auto-simulate via dataset_type="group4_mge"), _group_mge_model(), AnalysisImaging branch, _mask_radius_for + format_best_fit updates.
  3. searches/_recovery.py + _runner._build_summary "recovery" block loading truth.json.
  4. searches/_samplers.py: ("group","mge"): 200 n_live; fixed + autoconv builders; register in SAMPLER_BUILDERS.
  5. Leaf scripts searches/<sampler>/group/mge.py; add cell to searches/sweep.py.
  6. Run cells (CPU JAX first); searches/aggregate.py; record findings.
  7. Contingency (Phase 4): narrow-prior / warm-start init arm if cold-start fails.

Key Files

  • New: simulators/group4_mge.py, searches/_recovery.py, searches/{nautilus,multi_start_adam,multi_start_prodigy,multi_start_prodigy_autoconv,multi_start_lion,multi_start_adabelief}/group/mge.py
  • Edit: searches/{_setup,_samplers,_runner,sweep}.py, searches/README.md

Verification

ruff check . && ruff format --check .; AUTOLENS_PROFILING_SMOKE=1 import-smoke; simulate -> 4 lensed sources; Nautilus recovery anchor; then gradient sweep + aggregate.

Original Prompt

Click to expand starting prompt

Research profiling experiment in the autolens_profiling repo. We currently have autolens_profiling examples that run JAX gradient max-likelihood optimizers on a single lens galaxy with a single MGE source. Extend this to a much higher-dimensional, harder model: 4 lens galaxies + 4 source galaxies. Write a simulator.py that generates the dataset from known input truth, then run the existing JAX gradient optimizers (max-likelihood samplers) alongside Nautilus and record whether any of them scale to this dimensionality and recover the input truth. If none of the optimizers succeed, investigate more careful initialization strategies. This is an exploratory benchmark, not a library change.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions