Skip to content

Fast subplot_fit_quick: sub-second rendering for quick updates#547

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/fast-quick-render
May 27, 2026
Merged

Fast subplot_fit_quick: sub-second rendering for quick updates#547
Jammy2211 merged 1 commit into
mainfrom
feature/fast-quick-render

Conversation

@Jammy2211
Copy link
Copy Markdown
Collaborator

Summary

Rewrites subplot_fit_quick to render in <1s by bypassing the autoarray/autogalaxy plotting pipeline and rendering directly via imshow on pre-converted numpy arrays.

Three root causes of the previous 9-10s render time:

  1. Source-plane panel evaluated 20 MGE Gaussians twice on the full 141×141 oversampled grid (6.2s). Now uses a 50×50 grid with no oversampling (~0.1s).
  2. model_data / subtracted_images_of_planes_list are uncached @property — each access recomputed the entire inversion (5-20s for Delaunay). Now accesses model_images_of_planes_list once and derives everything manually.
  3. array.native conversion via array_2d_via_indexes_from numba function (~0.4s per call × 16 calls). Now uses numpy boolean-mask fill (~0.001s).

Render times (HST, 15k pixels, 20-Gaussian MGE lens):

  • MGE source: 9.2s → 0.63s (15x)
  • Delaunay source: 10.6s → 0.39s (27x)

API Changes

None — subplot_fit_quick has the same signature. Internal rendering pipeline is different but the output PNG is the same 6-panel layout.

Test Plan

  • Profiling confirms sub-second render for both MGE and Delaunay
  • Manual: fit_quick.png output looks correct for both model types
  • pytest test_autolens/ — must pass

🤖 Generated with Claude Code

Rewrites subplot_fit_quick to bypass the autoarray/autogalaxy plotting
pipeline and render directly via imshow on pre-converted numpy arrays.

Key optimizations:
- Access fit.model_images_of_planes_list once and derive model_data,
  subtracted, and residuals manually — avoids repeated recomputation
  of the inversion via uncached @Property accessors (model_data was
  recomputing ~5-20s per access for pixelized sources)
- Use numpy boolean-mask fill instead of numba array_2d_via_indexes_from
  for slim-to-native conversion (~0.4s → ~0.001s per array)
- Skip the autoarray/autogalaxy plot_array wrapper (zoom_array, .native
  conversion chain) — direct imshow on raw numpy 2D arrays
- Source plane panel for MGE: 50x50 grid, no oversampling, no zoom-to-
  brightest first pass (was evaluating 20 Gaussians twice on full
  141x141 oversampled grid = 6.2s; now ~0.1s)
- Source plane panel for pixelized: plot_mapper with zoom_to_brightest
  disabled
- 100 DPI for the PNG save (vs 200/300)

Render times (HST, 15k pixels, 20-Gaussian MGE lens):
  MGE source:     9.2s → 0.63s  (15x faster)
  Delaunay source: 10.6s → 0.39s (27x faster)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label May 27, 2026
@Jammy2211 Jammy2211 merged commit cbdbb69 into main May 27, 2026
6 checks passed
@Jammy2211 Jammy2211 deleted the feature/fast-quick-render branch May 27, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release PR queued for the next release build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant