Skip to content

feat: Phase 3 — mirror Nautilus profiling scripts#8

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/nautilus-mirror
May 16, 2026
Merged

feat: Phase 3 — mirror Nautilus profiling scripts#8
Jammy2211 merged 1 commit into
mainfrom
feature/nautilus-mirror

Conversation

@Jammy2211
Copy link
Copy Markdown
Contributor

Summary

Phase 3 of the autolens_profiling z_feature roadmap — stands up autolens_profiling/searches/ with sampler profiling for the Nautilus sampler only, mirrored from autolens_workspace_developer/searches_minimal/. Other samplers (Dynesty, Emcee, BlackJAX, NumPyro, PocoMC, NSS, LBFGS) are explicitly out of scope; the folder layout is designed so they slot in under their own follow-up prompts.

_developer stays the source of truth — the originals do not move.

Closes #5.

What changed

  • 4 files mirrored from clean origin/main of _developer/searches_minimal/:
    • _setup.py (shared dataset/model/analysis builder) → searches/_setup.py
    • _metrics.py (MLTracker for evals/time to ML) → searches/_metrics.py
    • nautilus_simple.py (NumPy backend) → searches/nautilus/simple.py
    • nautilus_jax.py (JAX-JIT'd likelihood) → searches/nautilus/jax.py
  • Path rewrites in _setup.py:
    • _DATASET_SUBPATH: Path(\"jax_profiling\") / \"dataset\" / \"imaging\" / \"hst\"Path(\"dataset\") / \"imaging\" / \"hst\" (matches Phase 1's top-level layout).
    • Replaced the should_simulate subprocess block (which invoked _developer/jax_profiling/dataset_setup/imaging.py) with a clean FileNotFoundError pointing readers back at _developer for regeneration — same pattern Phase 1 used.
    • Dropped now-unused subprocess + sys imports.
    • Docstring + cross-references updated to the new layout (from searches._setup, likelihood/imaging/mge.py).
  • Import rewrites in nautilus/{simple,jax}.py:
    • from searches_minimal._{metrics,setup}from searches._{metrics,setup}.
    • Added sys.path injection at the top of each script (_REPO_ROOT = Path(__file__).resolve().parents[2]) so they work invariant to invocation style (python searches/nautilus/<name>.py or python -m searches.nautilus.<name>).
  • Output convention upgrade: the originals wrote a freeform <script>_summary.txt to output/. The mirror writes versioned JSON + bar-chart PNG to results/searches/nautilus/<script>_summary_v<al.__version__>.{json,png} matching the Phase 1 convention so Phase 4's dashboard can pick them up.
    • JSON has sections: sampler, backend, instrument, model, sampler_config, results, performance, convergence, version.
    • PNG: horizontal bar chart of headline timings (wall_time, time_per_eval, time_to_ml; plus jit_compile on jax.py).
  • 2 READMEs:
    • searches/README.md (replaces Phase 0 placeholder): section overview, shared helper roles, supported-samplers table (Nautilus ✓, 7 others marked planned), versioned-artifact convention, run instructions.
    • searches/nautilus/README.md: narrative grounded in _developer/searches_minimal/sweep_findings.md — expected converged logZ ≈ -169k for this MGE setup, caveats (upstream JAX-gradient pathology PyAutoLens#514), headline-run-times table placeholder for Phase 4.

F1 lesson applied

Copies came from the worktree's clean origin/main of _developer, NOT the canonical (which is currently dirty with ~36 modified files). This is the same lesson that prompted F1's re-mirror PR #3 for Phase 1.

Test plan

  • py_compile PASSES for all 4 mirrored files (_setup.py, _metrics.py, nautilus/simple.py, nautilus/jax.py).
  • grep -r searches_minimal on the mirrored searches/ returns no residual references — only the section README references the upstream folder by name in context.
  • sys.path injection lets both scripts resolve from searches._{setup,metrics} regardless of cwd / invocation style.
  • .gitignore already covers results/searches/ from Phase 1 — smoke artifacts won't leak.
  • Full runtime smoke skipped: python searches/nautilus/simple.py at default n_live=200 takes 30+ min on CPU. Phase 5 (issue #7) will add the AUTOLENS_PROFILING_SMOKE=1 env-var short-circuit that makes future smokes cheap; until then the static checks above + the matching pattern with Phase 1's already-shipped scripts give sufficient confidence to ship. The Nautilus scripts can be smoked manually after this lands by running them with whatever n_live the user wants.

Refs

🤖 Generated with Claude Code

…ase 3)

Phase 3 of the autolens_profiling z_feature roadmap. Stands up
autolens_profiling/searches/ with profiling for the Nautilus sampler
only, mirrored from autolens_workspace_developer/searches_minimal/.
Designs the folder layout so other samplers (Dynesty, Emcee, BlackJAX,
NumPyro, PocoMC, NSS, LBFGS) can slot in cleanly under their own
follow-up prompts.

Files mirrored (4 copies from clean origin/main of _developer):
  searches_minimal/_setup.py           -> searches/_setup.py
  searches_minimal/_metrics.py         -> searches/_metrics.py
  searches_minimal/nautilus_simple.py  -> searches/nautilus/simple.py
  searches_minimal/nautilus_jax.py     -> searches/nautilus/jax.py

Path rewrites in _setup.py:
- _DATASET_SUBPATH:
    Path("jax_profiling") / "dataset" / "imaging" / "hst"
    -> Path("dataset") / "imaging" / "hst"
- Replaced the if al.util.dataset.should_simulate(...) subprocess block
  (which invoked _developer's dataset_setup/imaging.py) with a clean
  FileNotFoundError pointing back at _developer for regeneration —
  matches the Phase 1 pattern.
- Dropped now-unused subprocess + sys imports.
- Docstring example: `from searches_minimal._setup` -> `from searches._setup`
- Cross-reference: `jax_profiling/imaging/mge.py` -> `likelihood/imaging/mge.py`

Import rewrites in nautilus/simple.py and nautilus/jax.py:
- `from searches_minimal._{metrics,setup}` -> `from searches._{metrics,setup}`
- Added sys.path injection at top so scripts work whether run as
  `python searches/nautilus/<name>.py` or `python -m searches.nautilus.<name>`.

Output convention upgrade (both Nautilus scripts):
- Originals wrote a freeform `<script>_summary.txt` to `output/`.
- New: write versioned JSON + bar-chart PNG to
  `results/searches/nautilus/<script>_summary_v<al.__version__>.{json,png}`
  matching Phase 1's convention. JSON carries sampler config, results,
  performance, and convergence sections plus the al.__version__ tag.
  PNG is a horizontal bar chart of headline timings (wall time, time
  per eval, time to ML; plus JIT compile time on jax.py).

READMEs:
- searches/README.md: replaces Phase 0 placeholder. Section overview,
  why bypass af.NonLinearSearch, shared _setup / _metrics roles,
  supported-samplers table (Nautilus ✓, others "planned"), versioned
  artifact convention, run instructions.
- searches/nautilus/README.md: per-sampler narrative grounded in
  _developer/searches_minimal/sweep_findings.md — expected behaviour
  (converged logZ ≈ -169k for this MGE setup), caveats (upstream JAX-
  gradient pathology #514), headline-run-times table placeholder for
  Phase 4 to auto-populate.

Smoke status: ran py_compile across all 4 files (PASS), verified no
residual `searches_minimal` references in the mirrored scripts. Full
runtime smoke (`python searches/nautilus/simple.py` end-to-end) was
intentionally skipped — n_live=200 takes 30+ min on CPU and Phase 5
will add the AUTOLENS_PROFILING_SMOKE=1 short-circuit that makes this
cheap forever. Static checks + matching the Phase 1/2 pattern give
sufficient confidence to ship.

F1 lesson applied: copies came from the worktree's clean origin/main
of _developer (NOT the canonical, which is dirty with ~36 modified
files).

Closes #5.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Phase 3 — mirror Nautilus profiling scripts

1 participant