feat: dispatch autogalaxy visualizers via fit_for_visualization#390
Merged
Conversation
Closes #389. - imaging/model/visualizer.py — both single-analysis visualize() and visualize_combined() multi-analysis path - interferometer/model/visualizer.py — single-analysis visualize() PyAutoLens made the same swap in #443 (2026-04-19) when use_jax_for_visualization landed in autofit. PyAutoGalaxy got matching pytree registration for FitImaging (#364) and FitInterferometer (#376) but the dispatch call sites were never swapped, leaving use_jax_for_visualization=True a silent no-op on autogalaxy. This PR fixes that. Safe for the NumPy default path: fit_for_visualization falls back to fit_from whenever use_jax_for_visualization=False.
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
PyAutoLens visualizers were updated in #443 (2026-04-19) to dispatch through
analysis.fit_for_visualization(instance=instance)so the fit reused for plotting goes through autofit's cachedjax.jitwrapper whenuse_jax_for_visualization=True. PyAutoGalaxy received matching pytree registration forFitImaging(#364) andFitInterferometer(#376) but the visualizer dispatch was never switched over for either. As a resultuse_jax_for_visualization=Trueonag.AnalysisImaging/AnalysisInterferometerwas a silent no-op for visualization. This PR swaps the three call sites.The change is safe for the NumPy default path because
fit_for_visualizationfalls back tofit_fromwheneveruse_jax_for_visualization=False.Closes #389.
API Changes
None — internal changes only. The visualizer call sites are private; users construct
Analysisinstances and the visualizer is invoked by the search machinery, never called directly. Behaviour is unchanged on the NumPy path. JAX users who setuse_jax_for_visualization=Truenow actually get the jit-cached path that the pytree registration was set up for.See full details below.
Test Plan
pytest test_autogalaxy/imaging/model/ test_autogalaxy/interferometer/model/— 14 tests passpytest test_autogalaxy/imaging/ test_autogalaxy/interferometer//smoke_test autogalaxy_workspace_test imaging/visualization.py imaging/visualization_jax.py interferometer/visualization.py— to be run after merge as part of the JAX visualization roadmap follow-upFull API Changes (for automation & release notes)
Changed Behaviour
autogalaxy.imaging.model.visualizer.VisualizerImaging.visualize— now dispatches throughanalysis.fit_for_visualization(instance=...)instead ofanalysis.fit_from(instance=...). Behaviour identical whenuse_jax_for_visualization=False(default). WhenTrue, uses the cachedjax.jitwrapper from autofit.autogalaxy.imaging.model.visualizer.VisualizerImaging.visualize_combined— same swap inside the per-analysis fit list comprehension that builds combined-fit images for multi-analysis searches.autogalaxy.interferometer.model.visualizer.VisualizerInterferometer.visualize— same swap (single-analysis path; novisualize_combinedexists for interferometer in autogalaxy).Migration
None required.
fit_for_visualizationwas added to autofit's baseAnalysis(PyAutoFit #1228) and silently falls back tofit_fromwhen the JAX visualization flag is off — so any caller that previously worked withfit_fromcontinues to work.Roadmap context
This is Phase 0b of
PyAutoPrompt/z_features/jax_visualization.md. It unblocks the autogalaxy interferometer visualization scripts inautogalaxy_workspace_test(Phase 1C) and the eventual default-on flip ofuse_jax_for_visualization(Phase 2).🤖 Generated with Claude Code