Honour PYAUTO_TEST_MODE in LOSSampler to fix los_halos simulator timeouts#559
Merged
Conversation
…outs LOSSampler.galaxies_from now caps the line-of-sight halo population to a few per plane and loosens the negative-kappa quad integration when PYAUTO_TEST_MODE is active. This collapses the los_halos simulator runtime under the workspace integration runner (simulator.py 320s timeout -> 28s; simulator_jax.py timeout -> 45s) while keeping the full sampling and ray-tracing code paths exercised. Non-test-mode behaviour is bit-identical (still samples ~1100 halos with full-accuracy kappa). Co-Authored-By: Claude Opus 4.8 (1M context) <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
The
los_halosworkspace simulators (simulator.pyandsimulator_jax.py) timed out at the 300s cap under the integration runner, even withPYAUTO_TEST_MODE=2. These scripts run no non-linear search, so test mode had nothing to short-circuit. The real cost is inLOSSampler.galaxies_from():negative_kappa_fromruns a nested adaptivescipy.quadwith an innerfsolve(~22.5k fsolve calls per plane) — ~3.8s × 9 planes ≈ 35s, and it is grid-independent, soPYAUTO_SMALL_DATASETS=1never reduced it.simulator_jax.pycallsgalaxies_from9× (1 + a batch of 8) ≈ 290s of sampling alone.This change makes
LOSSamplerhonourPYAUTO_TEST_MODE: it caps the halo population to at most 3 per plane and callsnegative_kappa_fromwithquad_limit=1, quad_epsrel=0.1. The expected scipyIntegrationWarningfrom the low limit is suppressed only in test mode. With test mode off, behaviour is unchanged (signature unchanged).Verified under the real workspace integration env (
PYAUTO_TEST_MODE=2 PYAUTO_SMALL_DATASETS=1 PYAUTO_FAST_PLOTS=1 PYAUTO_DISABLE_JAX=1):simulator.pysimulator_jax.pyNon-test-mode output is bit-identical to
main: still 1100 halos with full-accuracy kappa values to 10 decimal places.API Changes
autolens.lens.los.negative_kappa_fromgains two optional keyword arguments,quad_limit=50andquad_epsrel=1.49e-8(both scipy's ownquaddefaults), threaded into its inner and outer integrals. Existing callers are unaffected.LOSSampler.galaxies_fromnow readsautoconf.test_mode.is_test_mode()internally; its signature is unchanged. No removals or renames. See full details below.Test Plan
pytest test_autolens/lens/test_los.py(new file): loose-quad result matches a finer reference and stays negative;galaxies_fromunderPYAUTO_TEST_MODEcaps halos to <=3 per plane and emits one negative-kappa MassSheet per plane.simulator.pyandsimulator_jax.pyrun to exit 0 under the integration env in <50s each.galaxies_fromis bit-identical tomain(1100 halos, same 9 kappas).Full API Changes (for automation & release notes)
Added
autolens.lens.los.negative_kappa_from(..., quad_limit=50, quad_epsrel=1.49e-8)— two optional kwargs controlling the adaptive subdivision limit and relative tolerance of bothscipy.integrate.quadcalls. Defaults equal scipy's own defaults, so behaviour is unchanged for existing callers.Changed Behaviour
autolens.lens.los.LOSSampler.galaxies_from()— whenPYAUTO_TEST_MODEis active (autoconf.test_mode.is_test_mode()), caps sampled LOS halos to at most 3 per plane and callsnegative_kappa_fromwithquad_limit=1, quad_epsrel=0.1. The expected scipyIntegrationWarningfrom the low limit is suppressed only in test mode. With test mode off, behaviour is unchanged (signature unchanged).Migration
🤖 Generated with Claude Code