Skip to content

perf: cache cosmology distances and cap MGE gaussians for smoke tests#329

Merged
Jammy2211 merged 1 commit intomainfrom
feature/smoke-test-perf-cache
Apr 7, 2026
Merged

perf: cache cosmology distances and cap MGE gaussians for smoke tests#329
Jammy2211 merged 1 commit intomainfrom
feature/smoke-test-perf-cache

Conversation

@Jammy2211
Copy link
Copy Markdown
Collaborator

Summary

Two performance optimizations:

  1. Cosmology distance cache: Cache angular_diameter_distance_kpc_z1z2 results 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.

  2. MGE gaussian cap: When PYAUTO_WORKSPACE_SMALL_DATASETS=1, mge_model_from uses 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

  • All 811 PyAutoGalaxy tests pass
  • imaging/modeling.py subplot_fit_imaging: 1.9s → 0.78s

🤖 Generated with Claude Code

- 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>
@Jammy2211 Jammy2211 merged commit 298ad58 into main Apr 7, 2026
2 checks passed
@Jammy2211 Jammy2211 deleted the feature/smoke-test-perf-cache branch April 7, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant