perf: cache cosmology distances and cap MGE gaussians for smoke tests#329
Merged
perf: cache cosmology distances and cap MGE gaussians for smoke tests#329
Conversation
- Cache angular_diameter_distance_kpc_z1z2 results keyed on (z1, z2) to avoid redundant 8193-point Simpson integrations for repeated redshift pairs (104 → 4 unique calls for a 2-plane lens). - When PYAUTO_WORKSPACE_SMALL_DATASETS=1, cap mge_model_from to 2 total gaussians with 1 basis, dramatically reducing model composition time and all downstream computation (likelihood, ray-tracing, plots). Co-Authored-By: Claude Opus 4.6 (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
Two performance optimizations:
Cosmology distance cache: Cache
angular_diameter_distance_kpc_z1z2results keyed on(z1, z2, n_steps)to avoid redundant 8193-point Simpson integrations. For a 2-plane lens, this reduces 104 integrations to 4 unique calls.MGE gaussian cap: When
PYAUTO_WORKSPACE_SMALL_DATASETS=1,mge_model_fromuses 2 total gaussians with 1 basis instead of the requested count. This speeds up model composition, likelihood evaluation, ray-tracing, and plotting.API Changes
None — cosmology cache is transparent, MGE cap is gated behind opt-in env var.
Test Plan
imaging/modeling.pysubplot_fit_imaging: 1.9s → 0.78s🤖 Generated with Claude Code