Repository navigation
Description
Overview
After the latent refactor series shipped (z_features/complete/latent_refactor.md), the autolens SLaM smoke test times out at the 5-minute mark inside the first SLaM stage's post-fit latent processing. Root cause: PyAutoFit:autofit/non_linear/search/updater.py:226 (_compute_latent_samples) ignores PYAUTO_TEST_MODE. It always draws output.latent_draw_via_pdf_size samples (default 100) and runs analysis.compute_latent_samples(...) on each — and PyAutoGalaxy's AnalysisDataset.LATENT_BATCH_MODE = "jit" override means that's a Python loop of per-sample JIT dispatches because the einstein-radius latent's ZeroSolver isn't vmap-compatible.
Test mode by definition mocks the fit, so the latent values are never asserted on — short-circuiting _compute_latent_samples in test mode unblocks smoke testing immediately with no behavioural change to real runs.
Plan
- Add a
skip_latents()helper inPyAutoConf:autoconf/test_mode.py(alongside existingskip_visualization(),skip_checks()etc) that composesis_test_mode()ORPYAUTO_SKIP_LATENTS=1. - In
PyAutoFit:autofit/non_linear/search/updater.py, short-circuit_compute_latent_samplesto returnNonewhenskip_latents()is true. - Add unit test covering both the test-mode trigger and the explicit
PYAUTO_SKIP_LATENTS=1trigger. - Validate against the previously-timing-out SLaM smoke command.
Detailed implementation plan
Affected Repositories
- rhayes777/PyAutoFit (primary —
updater.pyshort-circuit) - rhayes777/PyAutoConf (
test_mode.pyaddsskip_latents()helper)
Work Classification
Library.
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| ./PyAutoFit | main | clean |
| ./PyAutoConf | main | clean |
Suggested branch: feature/test-mode-skip-latents
Worktree root: ~/Code/PyAutoLabs-wt/test-mode-skip-latents/ (created later by /start_library)
Implementation Steps
-
PyAutoConf — add
skip_latents()toautoconf/test_mode.py:def skip_latents(): """Return True if latent variable computation should be skipped.""" return is_test_mode() or os.environ.get("PYAUTO_SKIP_LATENTS", "0") == "1"
Place after
skip_checks()to match the file's existing layout. -
PyAutoFit — short-circuit
_compute_latent_samplesinautofit/non_linear/search/updater.py:226:def _compute_latent_samples(self, ...): """Compute and persist latent variable samples if configured.""" from autoconf.test_mode import skip_latents if skip_latents(): return None if not ((during_analysis and conf.instance["output"]["latent_during_fit"]) or (not during_analysis and conf.instance["output"]["latent_after_fit"])): return ...
_profile_and_summarize(line 117 callsite) already acceptslatent_samples=None, so no downstream changes. -
PyAutoFit unit test in
test_autofit/non_linear/search/(confirm test layout first; if no test_updater.py exists, add one or use the appropriate adjacent file). Three cases:- With
PYAUTO_TEST_MODE=1set →_compute_latent_samplesreturnsNonewithout invokinganalysis.compute_latent_samples. - With
PYAUTO_SKIP_LATENTS=1set (test mode off) → same behaviour. - Default (both unset) → existing path still runs (mock
analysis.compute_latent_samplesto return a sentinel; assert it's called).
No JAX in the unit test.
- With
-
Validate with the SLaM smoke command that previously timed out:
PYAUTO_TEST_MODE=2 PYAUTO_SKIP_FIT_OUTPUT=1 PYAUTO_SKIP_VISUALIZATION=1 \ PYAUTO_SKIP_CHECKS=1 PYAUTO_SMALL_DATASETS=1 PYAUTO_FAST_PLOTS=1 \ python scripts/imaging/features/advanced/slam/start_here.py
Should complete in seconds. Then a no-
PYAUTO_TEST_MODEreal-mode fit to confirmlatent.csvstill produced as before.
Key Files
PyAutoConf/autoconf/test_mode.py— addskip_latents()helperPyAutoFit/autofit/non_linear/search/updater.py:226(_compute_latent_samples) — short-circuitPyAutoFit/test_autofit/non_linear/search/(test layout TBD) — unit test
Out of Scope
- Per-latent
LATENT_BATCH_MODE(so fast latents vmap while einstein-radius stays jit-per-sample). That's the real-mode SLaM perf fix and lives in a separate follow-up atPyAutoPrompt/autogalaxy/latent_batch_mode_per_latent.md(TBA). This issue only unblocks smoke testing. - No new workspace CLAUDE.md documentation: the existing fast-smoke env set covers test mode;
PYAUTO_SKIP_LATENTS=1is for power users and is discoverable viaautoconf/test_mode.py.
Original Prompt
Click to expand starting prompt
Located at PyAutoPrompt/issued/test_mode_skip_latents.md after routing.
Activity
Jammy2211 commentedon May 24, 2026
Smoke Test Results — 2026-05-24
Worktree:
feature/test-mode-skip-latents— validatesSearchUpdater._compute_latent_samplesshort-circuit in test mode.All 44 smoke tests passed across 6 workspaces (2 pre-existing skips:
searches/mcmcin autofit anddatabase/scrape/generalin autolens_workspace_test — both already inno_run.yaml).Notable:
cookbooks/latent_variables.py(autofit_workspace) andlatent/latent_variables_smoke.py(autolens_workspace_test) both PASS, confirming the latent-variable short-circuit does not break downstream scripts.Merge pull request #1295 from PyAutoLabs/feature/test-mode-skip-latents
Jammy2211 commentedon May 24, 2026
Shipped — 2026-05-24
PRs
Summary
Added
autoconf.test_mode.skip_latents()helper composingis_test_mode()ORPYAUTO_SKIP_LATENTS=1, and short-circuitedSearchUpdater._compute_latent_samplesto returnNonewhen it fires. Eliminates the 100-sample post-fit latent dispatch loop in test-mode runs, which under PyAutoGalaxy'sAnalysisDataset.LATENT_BATCH_MODE = "jit"override was ~750s per SLaM fit on CPU. End-to-end SLaMslam_start_here.pysmoke went from > 5-min timeout to 29.6s.Session Notes
LATENT_BATCH_MODEper-latent so fast latentsvmapwhile onlyeinstein_radiusstays jit-per-sample. That's the real-mode SLaM perf fix; this PR only unblocked smoke testing. Spans PyAutoFit dispatcher (_compute_latent_samples) + PyAutoGalaxy registry (LATENT_FUNCTIONSneeds to carry a per-entry mode tag) + tests. Filed as a TBA prompt forPyAutoPrompt/autogalaxy/latent_batch_mode_per_latent.md.PYAUTO_SKIP_LATENTS=1is now available alongsidePYAUTO_TEST_MODE. Auto-fires inside any test-mode run viaskip_latents() = is_test_mode() or PYAUTO_SKIP_LATENTS=1. Discoverable viaautoconf/test_mode.pydocstring; not added to the fast-smoke env set in workspaceCLAUDE.mdfiles becausePYAUTO_TEST_MODEalready covers smoke.test_autofit/non_linear/search/test_updater.py3/3, full smoke 44/44 across all 6 workspaces, end-to-end SLaM 29.6s.pending-release.