Skip to content

feat: route visualizer fit construction through fit_for_visualization - #443

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/jax-visualization
Apr 19, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/jax-visualization

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Swaps analysis.fit_from(instance=...) for analysis.fit_for_visualization(instance=...) in the imaging, interferometer, and point-source visualizers. This plugs PyAutoLens into the new PyAutoFit dispatch seam added in PyAutoLabs/PyAutoFit#1228.

Today the dispatch method is a pass-through to fit_from, so runtime behaviour is unchanged — but with use_jax=True, use_jax_for_visualization=True, the visualizer now goes through the JAX-aware path that will eventually wrap fit_from in jax.jit (tracked in admin_jammy/prompt/autolens/fit_imaging_pytree.md — requires FitImaging pytree registration first).

API Changes

None — internal changes only. All three visualizers now call analysis.fit_for_visualization(instance=...) instead of analysis.fit_from(instance=...); the method they call is new in PyAutoFit and dispatches to fit_from today, so end-user behaviour is unchanged.

See full details below.

Test Plan

  • pytest test_autolens/ full suite — 246 passed
  • autolens_workspace_test/scripts/imaging/visualization.py — non-JAX baseline still produces fit.png / tracer.png / inversion plots across all three source types
  • autolens_workspace_test/scripts/imaging/visualization_jax.py — new pilot; produces fit.png + tracer.png with use_jax=True, use_jax_for_visualization=True on the MGE parametric source

Dependency

Requires PyAutoLabs/PyAutoFit#1228 — Analysis.fit_for_visualization is introduced there.

Full API Changes (for automation & release notes)

Changed Behaviour

  • autolens.imaging.model.visualizer.VisualizerImaging — visualize and the rectangular/Delaunay inversion path now call analysis.fit_for_visualization(instance=...) instead of analysis.fit_from(instance=...).
  • autolens.interferometer.model.visualizer.VisualizerInterferometer.visualize — same swap.
  • autolens.point.model.visualizer.VisualizerPoint.visualize — same swap.

Behaviour is unchanged today (the new method is a pass-through); the swap lets downstream JAX-visualization work plug in at a single seam in PyAutoFit rather than each visualizer.

Added / Removed / Renamed

None.

Migration

No migration required for users of VisualizerImaging / VisualizerInterferometer / VisualizerPoint. Custom Analysis subclasses that override fit_from continue to work unchanged — fit_for_visualization dispatches to fit_from by default.

🤖 Generated with Claude Code

Swaps analysis.fit_from(instance=...) for analysis.fit_for_visualization
in the imaging, interferometer, and point-source visualizers. Today this
is a pass-through, but the new dispatch method is the seam that will
switch to a jax.jit-wrapped fit once use_jax_for_visualization=True is
supported end-to-end.
@Jammy2211

Copy link
Copy Markdown
Collaborator Author

Workspace PR: PyAutoLabs/autolens_workspace_test#31

@Jammy2211
Jammy2211 merged commit 84ee562 into main Apr 19, 2026
5 checks passed
@Jammy2211
Jammy2211 deleted the feature/jax-visualization branch April 19, 2026 11:55
nataliehogg pushed a commit to nataliehogg/PyAutoLens that referenced this pull request Jun 3, 2026
AnalysisInterferometer's explicit __init__ omitted **kwargs, so any
kwarg not in its named-parameter list (notably use_jax_for_visualization
from the autofit base Analysis) raised TypeError instead of being
forwarded to super.

This left use_jax_for_visualization=True silently unusable on
al.AnalysisInterferometer despite:
- the interferometer visualizer dispatching via fit_for_visualization
  (visualizer.py:96, 209, since PyAutoLabs#443)
- AnalysisInterferometer having full pytree registration via
  _register_fit_interferometer_pytrees

Compare ag.AnalysisImaging which has had **kwargs passthrough all along.
AnalysisDataset (the parent) already accepts and forwards **kwargs, so
this just plugs the gap in the subclass override.

Discovered while drafting interferometer/visualization_jax.py and
modeling_visualization_jit.py for autolens_workspace_test (Phase 1A of
the JAX visualization roadmap). The workspace_test scripts follow in
PyAutoLabs/autolens_workspace_test#86 sibling PR.
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Sep 4, 2026
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