Skip to content

feat: dispatch autogalaxy visualizers via fit_for_visualization#390

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/autogalaxy-viz-dispatch-swap
May 8, 2026
Merged

feat: dispatch autogalaxy visualizers via fit_for_visualization#390
Jammy2211 merged 1 commit into
mainfrom
feature/autogalaxy-viz-dispatch-swap

Conversation

@Jammy2211
Copy link
Copy Markdown
Collaborator

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 cached jax.jit wrapper when use_jax_for_visualization=True. PyAutoGalaxy received matching pytree registration for FitImaging (#364) and FitInterferometer (#376) but the visualizer dispatch was never switched over for either. As a result use_jax_for_visualization=True on ag.AnalysisImaging / AnalysisInterferometer was 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_visualization falls back to fit_from whenever use_jax_for_visualization=False.

Closes #389.

API Changes

None — internal changes only. The visualizer call sites are private; users construct Analysis instances and the visualizer is invoked by the search machinery, never called directly. Behaviour is unchanged on the NumPy path. JAX users who set use_jax_for_visualization=True now 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 pass
  • Broader sweep: pytest 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-up
Full API Changes (for automation & release notes)

Changed Behaviour

  • autogalaxy.imaging.model.visualizer.VisualizerImaging.visualize — now dispatches through analysis.fit_for_visualization(instance=...) instead of analysis.fit_from(instance=...). Behaviour identical when use_jax_for_visualization=False (default). When True, uses the cached jax.jit wrapper 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; no visualize_combined exists for interferometer in autogalaxy).

Migration

None required. fit_for_visualization was added to autofit's base Analysis (PyAutoFit #1228) and silently falls back to fit_from when the JAX visualization flag is off — so any caller that previously worked with fit_from continues to work.

Roadmap context

This is Phase 0b of PyAutoPrompt/z_features/jax_visualization.md. It unblocks the autogalaxy interferometer visualization scripts in autogalaxy_workspace_test (Phase 1C) and the eventual default-on flip of use_jax_for_visualization (Phase 2).

🤖 Generated with Claude Code

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.
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label May 8, 2026
@Jammy2211 Jammy2211 merged commit cbe3c31 into main May 8, 2026
5 checks passed
@Jammy2211 Jammy2211 deleted the feature/autogalaxy-viz-dispatch-swap branch May 8, 2026 19:02
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.

feat: ag visualizer dispatch via fit_for_visualization

1 participant