fix: skip _compute_latent_samples in PYAUTO_TEST_MODE (#1294)#1295
Merged
Conversation
Short-circuit SearchUpdater._compute_latent_samples to return None when autoconf.test_mode.skip_latents() is True. Test-mode runs already bypass the sampler but the post-fit latent pass still draws 100 PDF samples and dispatches analysis.compute_latent_samples per sample — under PyAutoGalaxy's AnalysisDataset.LATENT_BATCH_MODE = "jit" override that is a Python loop of 100 JIT dispatches per stage, ~750s per SLaM fit on CPU. End-to-end SLaM smoke now completes in 29.6s instead of timing out at 5min. PYAUTO_SKIP_LATENTS=1 also bypasses the path in real-mode fits where the user explicitly wants to skip latent post-processing. Real-mode behaviour with no env vars set is unchanged. Requires rhayes777/PyAutoConf PR (skip_latents helper) merged first. Fixes #1294. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Short-circuit
SearchUpdater._compute_latent_samplesto returnNonewhenautoconf.test_mode.skip_latents()isTrue. Eliminates the post-fit latent-processing cost in test-mode runs.Root cause. Under
PYAUTO_TEST_MODE=2the sampler is already bypassed (mocks the fit), but the post-fit pass still drawsoutput.latent_draw_via_pdf_size = 100samples and dispatchesanalysis.compute_latent_samplesfor each. With PyAutoGalaxy'sAnalysisDataset.LATENT_BATCH_MODE = "jit"override (forced because the einstein-radius latent'sjax_zero_contour.ZeroSolveruseslax.cond/lax.while_loopearly-termination and is notvmap-compatible), that's a Python loop of 100 JIT dispatches per stage — ~750 s per SLaM fit on CPU. The smoke caller hit the 5-min timeout still inside the first SLaM stage's latent loop.Fix. Two lines at the top of
_compute_latent_samples: importskip_latentsfromautoconf.test_modeand returnNonewhen it fires. Test-mode runs skip the path entirely; real-mode runs are unchanged.PYAUTO_SKIP_LATENTS=1provides the same bypass for real-mode users who don't want the post-fit latent work.Validation. SLaM
slam_start_here.pyend-to-end with the full smoke env (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) completes in 29.6 s — all 5 stages (source_lp[1]→source_pix[1]→source_pix[2]→light[1]→mass_total[1]) run to completion. Previously timed out at 5 min insidesource_lp[1]latent processing.Out of scope. The deeper architectural fix — splitting
LATENT_BATCH_MODEper-latent so fast latentsvmapwhileeinstein_radiusstays jit-per-sample — is a separate follow-up (real-mode SLaM perf). This PR only unblocks smoke testing.Dependency. Depends on the PyAutoConf PR that adds
skip_latents(). Merge that one first.Fixes #1294.
API Changes
Public API: no change. Purely internal — adds
if skip_latents(): return Noneat the top of the privateSearchUpdater._compute_latent_samplesmethod. ThePYAUTO_SKIP_LATENTSenv var is a new user-facing env knob but documented inline inautoconf.test_mode.skip_latents()'s docstring.See full details below.
Test Plan
python -m pytest test_autofit/— 1413 passed, 1 skipped.test_autofit/non_linear/search/test_updater.py— 3/3 (test-mode trigger,PYAUTO_SKIP_LATENTS=1trigger, config-gate regression).slam_start_here.pywith full smoke env completes in 29.6s (previously > 5min, hit timeout).Full API Changes (for automation & release notes)
Removed / Renamed
None.
Added
PYAUTO_SKIP_LATENTS=1environment variable — when set,SearchUpdater._compute_latent_samplesshort-circuits and returnsNone. New env-var knob; previously latent post-processing was only controlled by theoutput.latent_after_fit/output.latent_during_fitconfig gate.Changed Behaviour
SearchUpdater._compute_latent_samples(private) now also short-circuits whenautoconf.test_mode.skip_latents()returnsTrue— i.e., anyPYAUTO_TEST_MODElevel set, orPYAUTO_SKIP_LATENTS=1. Real-mode runs with neither env var set are unchanged.Migration
None for end users. Internal callers do not need to update — the method's
Optional[Samples]return type already accommodatedNone.🤖 Generated with Claude Code