Overview
Resuming a partially-complete SLaM pipeline can take significant wall time even though every completed stage skips its search: inter-stage work (result loading, max-likelihood fit recomputation, adapt-image construction, visualization re-output, JAX JIT compile) runs again on every resume, slowing the science loop. This task adds a pipeline_resume/ profiling tier to autolens_profiling that measures where resume time goes across a full 5-stage SLaM pipeline, then delivers a judgment: targeted speed-ups vs a checkpoint system (weighing the adapt-image data-flow complexity a checkpoint design would need to handle).
Plan
- Add a new
pipeline_resume/ tier to autolens_profiling that runs a full 5-stage SLaM pipeline to completion, then re-runs it to profile the resume path.
- Instrument both runs with per-stage and inter-stage timers: samples load, result rebuild, max-likelihood fit recompute, adapt-image construction, visualization/output, JIT compile.
- Write versioned JSON + PNG results under
results/ per repo convention, and register the tier in the README dashboard.
- Run cold + resume on CPU (optionally laptop GPU) and capture the breakdown.
- Deliver the judgment on this issue: whether resume is slow, where the time goes, and whether the fix is targeted speed-ups (e.g. persist adapt images to
files/ at stage completion and load on resume) or a full checkpoint system.
- Any resulting library change (PyAutoFit/PyAutoLens caching or checkpointing) is filed as a follow-up prompt, not implemented here.
Detailed implementation plan
Work Classification
Workspace
Worktree root
~/Code/PyAutoLabs-wt/slam-resume-profiling/ (created by /start_workspace)
Affected Repositories
- autolens_profiling (primary)
Branch Survey
| Repository |
Current Branch |
Dirty? |
| ./autolens_profiling |
main |
clean |
Note: stale unregistered branch feature/jax-optimizer-tuning exists from the merged optimizer-benchmark work — warning only, no worktree claim conflicts.
Suggested branch: feature/slam-resume-profiling
Implementation Steps
pipeline_resume/slam_resume.py — a full 5-stage SLaM chain mirroring autolens_workspace/scripts/guides/modeling/slam_start_here.py (SOURCE LP → SOURCE PIX (adaptive pixelization via al.AdaptImages from the prior result) → LIGHT LP → MASS TOTAL → SUBHALO), so a bottleneck in any real stage boundary is captured rather than trimmed away. Small auto-simulated dataset, fast search settings so the cold run completes in reasonable time. Reuses _profile_cli.py conventions (device-info capture, output-path resolver, auto-simulate hook) without forcing the script into the JIT-sweep mold.
- Instrumentation — wall-clock timers around each
search.fit() and each inter-stage block (result → galaxy_name_image_dict → AdaptImages, model composition). On the resume run, decompose inside the completed-fit path (PyAutoFit/autofit/non_linear/search/abstract_search.py → paths.is_complete → result_via_completed_fit): samples CSV load, result rebuild, max-LH fit recompute, visualization re-output — via targeted timer wrappers in the script (no library edits).
- Output — versioned
summary JSON + stacked-bar PNG (stage × component, cold vs resume) under results/, shapes per results/README.md; add the tier to scripts/build_readme.py and the README dashboard.
- Measurement — run cold + resume on CPU (optionally laptop GPU; cap JAX GPU prealloc). Hypotheses to test: per-stage JAX JIT recompile and adapt-image fit recomputation dominate resume; samples parsing and visualization are secondary. Adjacent to the filed
jax_compile_time_profiling intake — this task quantifies compile's share of resume specifically.
- Judgment (deliverable) — written assessment on this issue: is resume overhead material; component breakdown; recommendation of targeted speed-ups (e.g. persist adapt images /
galaxy_name_image_dict into files/ at stage completion, load on resume; skip visualization re-output on completed fits; lazy samples load) vs a full checkpoint system — explicitly weighing the adapt-image pass-through problem: checkpointed resume must load adapt images from the right stage's output, which may make a general checkpoint system unnecessarily complex.
- Follow-up seam — any library change lands as a new PyAutoMind prompt via intake; out of scope here.
Key Files
autolens_profiling/pipeline_resume/slam_resume.py — new profiling script (this task's main artifact)
autolens_profiling/_profile_cli.py — shared helper conventions to reuse
autolens_profiling/results/README.md — result JSON/PNG shape conventions
autolens_profiling/scripts/build_readme.py — README dashboard generator to extend
autolens_workspace/scripts/guides/modeling/slam_start_here.py — canonical 5-stage SLaM chain to mirror (read-only reference)
PyAutoFit/autofit/non_linear/search/abstract_search.py — resume path (is_complete → result_via_completed_fit) being profiled (read-only reference)
Testing
- Run the script twice (cold, then resume) and verify the JSON schema, presence and sanity of per-stage/per-component timings.
ruff check . — the repo's PR lint gate (lint.yml, Python 3.12).
Original Prompt
Click to expand starting prompt
It is common for a user to set off a lens model, get so far, and then resume that model. For SLaM pipelines,
this can take time if it has to do tasks between each stage, which makes doing the science slower.
First, can you extend autolens_profiling to have some testing and profiling code for this, its part of the
core run time and thus falls under profiling rather than hygeine (e.g. in the context of agent work).
Then, can you assess if it is slow, whether the best way forward is to try and speed it up or if it would
be feasily to build a checkpoing system, where resuming goes straight to the latest result to
resume? Normally this would be fine, the issue is that stuff like adapt images, which get passed through
the pipeline, would need to be carefully thought about so the resume has their data loaded from the right place.
This may make a full chckpointing system unnecessary complex. You judge.
Overview
Resuming a partially-complete SLaM pipeline can take significant wall time even though every completed stage skips its search: inter-stage work (result loading, max-likelihood fit recomputation, adapt-image construction, visualization re-output, JAX JIT compile) runs again on every resume, slowing the science loop. This task adds a
pipeline_resume/profiling tier toautolens_profilingthat measures where resume time goes across a full 5-stage SLaM pipeline, then delivers a judgment: targeted speed-ups vs a checkpoint system (weighing the adapt-image data-flow complexity a checkpoint design would need to handle).Plan
pipeline_resume/tier toautolens_profilingthat runs a full 5-stage SLaM pipeline to completion, then re-runs it to profile the resume path.results/per repo convention, and register the tier in the README dashboard.files/at stage completion and load on resume) or a full checkpoint system.Detailed implementation plan
Work Classification
Workspace
Worktree root
~/Code/PyAutoLabs-wt/slam-resume-profiling/(created by/start_workspace)Affected Repositories
Branch Survey
Note: stale unregistered branch
feature/jax-optimizer-tuningexists from the merged optimizer-benchmark work — warning only, no worktree claim conflicts.Suggested branch:
feature/slam-resume-profilingImplementation Steps
pipeline_resume/slam_resume.py— a full 5-stage SLaM chain mirroringautolens_workspace/scripts/guides/modeling/slam_start_here.py(SOURCE LP → SOURCE PIX (adaptive pixelization viaal.AdaptImagesfrom the prior result) → LIGHT LP → MASS TOTAL → SUBHALO), so a bottleneck in any real stage boundary is captured rather than trimmed away. Small auto-simulated dataset, fast search settings so the cold run completes in reasonable time. Reuses_profile_cli.pyconventions (device-info capture, output-path resolver, auto-simulate hook) without forcing the script into the JIT-sweep mold.search.fit()and each inter-stage block (result →galaxy_name_image_dict→AdaptImages, model composition). On the resume run, decompose inside the completed-fit path (PyAutoFit/autofit/non_linear/search/abstract_search.py→paths.is_complete→result_via_completed_fit): samples CSV load, result rebuild, max-LH fit recompute, visualization re-output — via targeted timer wrappers in the script (no library edits).summaryJSON + stacked-bar PNG (stage × component, cold vs resume) underresults/, shapes perresults/README.md; add the tier toscripts/build_readme.pyand the README dashboard.jax_compile_time_profilingintake — this task quantifies compile's share of resume specifically.galaxy_name_image_dictintofiles/at stage completion, load on resume; skip visualization re-output on completed fits; lazy samples load) vs a full checkpoint system — explicitly weighing the adapt-image pass-through problem: checkpointed resume must load adapt images from the right stage's output, which may make a general checkpoint system unnecessarily complex.Key Files
autolens_profiling/pipeline_resume/slam_resume.py— new profiling script (this task's main artifact)autolens_profiling/_profile_cli.py— shared helper conventions to reuseautolens_profiling/results/README.md— result JSON/PNG shape conventionsautolens_profiling/scripts/build_readme.py— README dashboard generator to extendautolens_workspace/scripts/guides/modeling/slam_start_here.py— canonical 5-stage SLaM chain to mirror (read-only reference)PyAutoFit/autofit/non_linear/search/abstract_search.py— resume path (is_complete→result_via_completed_fit) being profiled (read-only reference)Testing
ruff check .— the repo's PR lint gate (lint.yml, Python 3.12).Original Prompt
Click to expand starting prompt
It is common for a user to set off a lens model, get so far, and then resume that model. For SLaM pipelines,
this can take time if it has to do tasks between each stage, which makes doing the science slower.
First, can you extend autolens_profiling to have some testing and profiling code for this, its part of the
core run time and thus falls under profiling rather than hygeine (e.g. in the context of agent work).
Then, can you assess if it is slow, whether the best way forward is to try and speed it up or if it would
be feasily to build a checkpoing system, where resuming goes straight to the latest result to
resume? Normally this would be fine, the issue is that stuff like adapt images, which get passed through
the pipeline, would need to be carefully thought about so the resume has their data loaded from the right place.
This may make a full chckpointing system unnecessary complex. You judge.