Fast subplot_fit_quick: sub-second rendering for quick updates#547
Merged
Conversation
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>
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
Rewrites
subplot_fit_quickto render in <1s by bypassing the autoarray/autogalaxy plotting pipeline and rendering directly viaimshowon pre-converted numpy arrays.Three root causes of the previous 9-10s render time:
model_data/subtracted_images_of_planes_listare uncached@property— each access recomputed the entire inversion (5-20s for Delaunay). Now accessesmodel_images_of_planes_listonce and derives everything manually.array.nativeconversion viaarray_2d_via_indexes_fromnumba function (~0.4s per call × 16 calls). Now uses numpy boolean-mask fill (~0.001s).Render times (HST, 15k pixels, 20-Gaussian MGE lens):
API Changes
None —
subplot_fit_quickhas the same signature. Internal rendering pipeline is different but the output PNG is the same 6-panel layout.Test Plan
fit_quick.pngoutput looks correct for both model typespytest test_autolens/— must pass🤖 Generated with Claude Code