Repository navigation
Description
Overview
With PYAUTO_WORKSPACE_SMALL_DATASETS=1 and PYAUTO_DISABLE_CRITICAL_CAUSTICS=1 (shipped in PyAutoLabs/autolens_workspace#34), smoke test scripts still take ~40-50s each under PYAUTOFIT_TEST_MODE=2. Profiling shows the remaining time is dominated by PyAutoFit-level operations: VRAM estimation (16s), pre-fit file I/O (10s), model.info formatting (7s), and result deserialization (5s). Addressing these should bring total runtime under 10s per script.
Plan
- Skip
print_vram_use()whenPYAUTOFIT_TEST_MODE >= 2— avoids expensive JAX JIT compilation + memory analysis - Reduce file I/O in
_fit_bypass_test_mode()— skip saving samples, results, and visualization in test mode - Speed up or skip
model.infoformatting for large models in test mode - Speed up
result_info_from()— skip expensive sigma quantile calculations in test mode
Detailed implementation plan
Affected Repositories
- PyAutoFit (primary)
Work Classification
Library
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| PyAutoFit | main_build | clean |
Suggested branch: feature/smoke-test-fast-pyautofit
Implementation Steps
-
Skip VRAM estimation in test mode — In
autofit/non_linear/analysis/analysis.py:319, add early return inprint_vram_use()whentest_mode_level() >= 2. Saves ~16s per script. -
Reduce file I/O in test mode bypass — In
autofit/non_linear/search/abstract_search.py:790, the_fit_bypass_test_mode()method callssave_samples_summary(),save_samples(),save_results(),save_results_combined(), andpaths.completed(). Skipsave_samples(),save_results(), andsave_results_combined()in test mode 2+ (keepsave_samples_summaryfor result access). Saves ~8-10s. -
Speed up model.info — In
autofit/mapper/prior_model/abstract.py:1775, theinfoproperty iterates all path/prior tuples, callsfind_groups(), and formats viaTextFormatter. For MGE models with ~40 gaussians this takes 7s. Options: cache the property, or return a minimal stub whentest_mode_level() >= 2. -
Speed up result_info_from — In
autofit/text/text_util.py:53,result_info_from()callssamples_text.summary()twice (sigma=3.0, sigma=1.0). Thevalues_at_sigma()computation is expensive. Skip in test mode 2+.
Key Files
autofit/non_linear/analysis/analysis.py:319—print_vram_use()autofit/non_linear/search/abstract_search.py:790—_fit_bypass_test_mode()autofit/mapper/prior_model/abstract.py:1775—infopropertyautofit/non_linear/result.py:85—result.infoautofit/text/text_util.py:53—result_info_from()autofit/text/samples_text.py:15—summary()autofit/non_linear/test_mode.py—test_mode_level()
Original Prompt
Click to expand starting prompt
Continuation of the smoke test speed-up work. The first phase shipped env vars
for small datasets and disabled critical curves (autolens_workspace#34). This
phase targets the remaining PyAutoFit-level bottlenecks identified by profiling.
With PYAUTO_WORKSPACE_SMALL_DATASETS=1 and PYAUTO_DISABLE_CRITICAL_CAUSTICS=1,
the imaging and interferometer modeling scripts still take ~40-50s each under
PYAUTOFIT_TEST_MODE=2. The remaining time is dominated by:
-
VRAM estimation: ~16s — analysis.print_vram_use() does full JAX JIT
compilation + memory analysis. Should be skipped when PYAUTOFIT_TEST_MODE >= 2. -
search.fit pre-fit I/O: ~10s — _fit_bypass_test_mode() writes model.info,
visualization, saves samples, saves results. Much of this can be skipped in
test mode 2+. -
model.info formatting: ~7s — The info property on MGE models with ~40
gaussians takes 7s to format. Can be cached or stubbed in test mode. -
Result access: ~5s — max_log_likelihood_instance takes ~5s to
deserialize. The result_info_from() function calls expensive
samples_text.summary() twice.
Target: get both scripts under 10s total with all env vars set.
Activity
Jammy2211 commentedon Apr 7, 2026
Progress Update — 2026-04-07
PRs Merged
Library PRs:
Workspace PRs:
Infrastructure:
Optimizations Implemented
PYAUTO_WORKSPACE_SMALL_DATASETS=1PYAUTO_DISABLE_CRITICAL_CAUSTICS=1PYAUTO_DISABLE_JAX=1PYAUTO_FAST_PLOTS=1PYAUTO_FAST_PLOTS=1Results —
imaging/simulator.pybenchmarkRemaining time is dominated by Python imports (~4.7s) and numba JIT (~0.7s).
Remaining Work
Jammy2211 commentedon Apr 7, 2026
Progress Update — 2026-04-07 (session 2)
PRs Merged (this session)
Results
imaging/simulator.py: ~100s → 3.6s (96% reduction, warm cache)
imaging/modeling.py: ~100s → 19.5s (80% reduction)
Remaining bottleneck identified
subplot_fit_imagingspends 4.8s on data computation, not rendering:angular_diameter_distance_kpc_z1z2called 176 times (1.5s) — excessive for a 2-plane lenstraced_grid_2d_list_from(2.3s) — ray-tracing repeated per subplot panelNext session will investigate speeding up cosmology/ray-tracing data computation.
Jammy2211 commentedon Apr 7, 2026
Progress Update — 2026-04-07 (session 3)
PRs Merged
Results —
imaging/modeling.pyResults —
imaging/simulator.py~100s → 3.6s (warm cache)
What's left
search.fittest-mode bypass takes 5.9s — dominated by search setup/teardown overheadJammy2211 commentedon Apr 7, 2026
Progress Update — 2026-04-07 (session 3, final)
PRs Merged (this session)
Final Results
imaging/simulator.pyimaging/modeling.pyKey bug found
AnalysisDataset.__init__had a staleself._use_jax = use_jaxthat overwrote thePYAUTO_DISABLE_JAXenv var check fromAnalysis.__init__. This caused JAX JIT to run during smoke tests (~3.5s wasted per likelihood eval). Fix saved 5.3s onsearch.fitalone.Remaining time breakdown (imaging/modeling.py)
Jammy2211 commentedon Apr 7, 2026
Smoke Test Results — 2026-04-07
All 27 smoke tests passed across 4 workspaces.
Changes shipped this session
Library PRs (already merged):
if xp is np:)dataset_utilforag.util.dataset.should_simulate()dataset_utilforal.util.dataset.should_simulate()should_simulate()utility (auto-deletes stale datasets whenPYAUTO_WORKSPACE_SMALL_DATASETS=1)Workspace PRs (just merged):
should_simulate()in smoke-tested scriptsshould_simulate(), swap real-data smoke tests for auto-simulating equivalents, fix MGE iteration bug inmulti/modeling.pySmoke test skill update:
PYAUTO_DISABLE_JAX=1orPYAUTO_WORKSPACE_SMALL_DATASETS=1, ensuring the JAX code path is actually exercisedJammy2211 commentedon Apr 9, 2026
Smoke Test Results — 2026-04-09
Ran after
feature/setup-notebook-boilerplatechanges (replace pyprojroot boilerplate withautoconf.setup_notebook()).Failures
autolens_workspace_test/database/scrape/general.py
Pre-existing issue —
PYAUTO_WORKSPACE_SMALL_DATASETS=1creates a 15x15 mask but the checked-in dataset is 100x100:Not related to the setup_notebook changes.
Jammy2211 commentedon Apr 9, 2026
Shipped — 2026-04-09
PRs
Library:
Workspace:
Summary
Added
autoconf.setup_notebook()— a single-call utility that replaces the 5-line pyprojroot boilerplate in every workspace script. Updated 375 files across 6 repos, simplified the notebook generation pipeline from 5 regex rules to 1, and removed thepyprojrootdependency entirely. All smoke tests pass (26/27, 1 pre-existing failure).Session Notes
config/directory as the workspace root marker instead of.git— more specific to PyAuto workspaces and avoids matching wrong repos in nested setups.setup_colabpattern in autoconf — sameos.chdir+conf.instance.push()approach.autolens_workspace_testandautofit_workspace_teststill have old pyprojroot boilerplate (commented out, harmless) — could be migrated in a follow-up.Jammy2211 commentedon Apr 12, 2026
Smoke Test Results — 2026-04-12
Failures (9 total)
autogalaxy_workspace/imaging/start_here.py
Bypass mode sample keys don't match
lp_linearprofile_list paths when reconstructingmax_log_likelihood_instance.autogalaxy_workspace/interferometer/start_here.py
Same root cause as imaging/start_here.py.
autogalaxy_workspace/multi/start_here.py
Same
profile_listpath mismatch insubsamplesduring graphical model result construction.autolens_workspace_test/aggregator/fit_imaging.py
draw_randomly_via_pdffails — bypass mode produces sample weights that don't sum to 1.autolens_workspace_test/aggregator/fit_interferometer.py
Same root cause as aggregator/fit_imaging.py.
autolens_workspace_test/jax_likelihood_functions/imaging/delaunay_mge.py
JAX vmap returns -1e99 (penalty) instead of expected likelihood.
autolens_workspace_test/jax_likelihood_functions/interferometer/rectangular.py
Missing dataset file — simulator script can't find input FITS.
autolens_workspace_test/jax_likelihood_functions/point_source/point.py
JAX vmap likelihood doesn't match NumPy reference.
autolens_workspace_test/jax_likelihood_functions/multi/mge.py
JAX vmap returns -1e99 (penalty) for all datasets instead of expected likelihoods.
Jammy2211 commentedon May 5, 2026
Smoke Test Results — 2026-05-05
All 7 smoke tests passed across autolens_workspace.
Scripts tested: imaging/modeling.py, imaging/fit.py, interferometer/modeling.py, group/modeling.py, multi/modeling.py, guides/galaxies.py, guides/modeling/cookbook.py