Click to expand starting prompt
Today Analysis.__init__ in PyAutoFit takes two independent flags:
# @PyAutoFit/autofit/non_linear/analysis/analysis.py:36
def __init__(
self,
use_jax: bool = False,
use_jax_for_visualization: bool = False,
**kwargs,
):
A user who wants the JAX-accelerated visualization path has to remember to
set both flags. Across all production workspaces (autolens_workspace,
autogalaxy_workspace, autofit_workspace) zero scripts set
use_jax_for_visualization=True today (audit, 2026-05-08), even where
use_jax=True would benefit. The flag is effectively dead weight — it
exists to gate the still-evolving JIT visualization path, but once the
underlying coverage is green there is no reason it should not follow
use_jax.
This task changes the default so that whenever use_jax=True, the
jit-cached visualization path is on by default. Users keep the explicit
opt-out via use_jax_for_visualization=False.
Why this matters
This is Phase 2 of z_features/jax_visualization.md. The user-facing
goal stated in the z_feature is:
"I want us to be at a point where all default runs do JAX visualization
and the notion of it being a separate thing is no longer relevant
(unless the user doesn't have JAX installed or has use_jax=False)."
This prompt delivers that.
Blockers — must land first
All Phase 1 coverage prompts must be merged before flipping the default,
otherwise dataset types with no JAX viz smoke coverage will silently
regress for any user who runs them with use_jax=True:
autolens_workspace_test/jax_viz_interferometer_coverage.md
autolens_workspace_test/jax_viz_point_source_coverage.md
autogalaxy_workspace_test/jax_viz_dataset_coverage.md
Phase 0 prerequisites (fit_imaging_pytree.md, the autogalaxy dispatch
swap, the autogalaxy other-datasets pytree registration) must also be
done. Verify all of these in complete.md before starting.
What to change
@PyAutoFit/autofit/non_linear/analysis/analysis.py:36-79 — change the
default of use_jax_for_visualization from False to a sentinel that
follows use_jax. Recommended signature:
def __init__(
self,
use_jax: bool = False,
use_jax_for_visualization: Optional[bool] = None,
**kwargs,
):
...
if use_jax_for_visualization is None:
use_jax_for_visualization = use_jax
...
None means "follow use_jax"; True/False are explicit opt-in/opt-out.
Resolution must happen before the existing
if use_jax_for_visualization and not use_jax guard at line 71 so the
guard's wording ("requires use_jax=True; disabling...") still applies
correctly when a user explicitly passes True without use_jax.
The PYAUTO_DISABLE_JAX=1 short-circuit at lines 42-45 already forces
both flags to False, so the env-var override path is unaffected — but
double-check that branch still resolves cleanly with the new sentinel.
The "JAX not installed" warning branch at lines 50-69 already sets
use_jax_for_visualization = False. That still works because the new
sentinel resolution happens after this branch — but be careful about
ordering: the warning branch sets use_jax = False, so the sentinel
resolution downstream picks up False correctly.
Update the docstring at lines 82-122 to reflect the new default behaviour.
The warning at line 71-76 must remain — passing
use_jax_for_visualization=True, use_jax=False explicitly is still a user
error (deserves a warning, then disabled).
What to verify
-
Unit tests for the resolution logic. Add cases to
@PyAutoFit/test_autofit/non_linear/analysis/test_analysis.py (or
create the file if missing) covering:
Analysis() → both off
Analysis(use_jax=True) → _use_jax_for_visualization=True
Analysis(use_jax=True, use_jax_for_visualization=False) → off (explicit opt-out works)
Analysis(use_jax=False, use_jax_for_visualization=True) → off + warning logged
Analysis(use_jax=True, use_jax_for_visualization=None) → on
PYAUTO_DISABLE_JAX=1 env-var override forces both off regardless
- JAX-not-installed branch still sets both off
-
Workspace smoke. Run /smoke_test on each workspace_test repo and
on the production workspaces. The Phase 1 coverage protects against
regressions; this is the moment of truth.
-
No silent-warning regressions. Grep production workspaces and tests
for use_jax_for_visualization= and confirm no script's behaviour
changes meaningfully. Any script that previously ran with use_jax=True
and no explicit use_jax_for_visualization was implicitly opting out;
after this change it will opt in. That is the intended behaviour but
should be verified case-by-case if any script's runtime changes
significantly.
Out of scope
- Phase 3 (production workspace tutorial adoption — opting tutorials into
use_jax=True) is a separate prompt.
- Phase 4 (subprocess visualization).
- Phase 5 (live Jupyter / Colab cell).
- Removing the
use_jax_for_visualization parameter entirely. The
parameter stays — only its default changes.
Reference
@PyAutoFit/autofit/non_linear/analysis/analysis.py:36-79 — site of the change
@PyAutoFit/autofit/non_linear/analysis/analysis.py:82-122 — fit_for_visualization docstring to update
complete.md entries jax-visualization, mge-jit-visualization (2026-04-19) — original Phase 0 ship notes
PyAutoPrompt/z_features/jax_visualization.md — Phase 2 in the sequenced roadmap
Overview
Phase 2 of the JAX visualization roadmap (
z_features/jax_visualization.md).Today
Analysis.__init__takesuse_jaxanduse_jax_for_visualizationastwo independent boolean flags both defaulting to
False. With Phases 0 and 1shipped, every dataset type across PyAutoLens + PyAutoGalaxy now has a
working JIT visualization path. This task flips the default so
use_jax_for_visualizationfollowsuse_jaxunless the user explicitlyopts out, making the two-flag model invisible to users.
Plan
use_jax_for_visualizationdefault fromFalsetoNone(sentinelmeaning "follow
use_jax") inAnalysis.__init__.use_jax=True" guard soexplicit-True-without-use_jax still warns.
PYAUTO_DISABLE_JAX=1env-var override and the JAX-not-installedfallback — both should remain hard-off paths.
__init__andfit_for_visualizationdocstrings.test_use_jax_for_visualization.pywith four new casescovering sentinel resolution, explicit opt-out, and env-var override under
the new default.
behaviour changes unexpectedly.
Detailed implementation plan
Affected Repositories
Work Classification
Library
Branch Survey
Suggested branch:
feature/use-jax-for-vis-defaultWorktree root:
~/Code/PyAutoLabs-wt/use-jax-for-vis-default/(created later by/start_library)Blocker — must serialise behind in-flight work
PyAutoFit is currently claimed by
nss-checkpointing-and-visualization(branch
feature/nss-checkpointing-and-visualization, worktree at~/Code/PyAutoLabs-wt/nss-checkpointing-and-visualization). This task isparked in
planned.mduntil the NSS PR merges.Phase 0 / Phase 1 prerequisites — all confirmed shipped
fit-imaging-pytreeseries (PyAutoFit + PyAutoLens + PyAutoGalaxy)autogalaxy-viz-dispatch-swap— PyAutoGalaxy PR Graphical Model w/ EP Output Structure #390ag-ellipse-quantity-pytree— PyAutoGalaxy PR Graphical: model.info file summarizing full graphical model #401autolens-interferometer-jax-viz— PyAutoLens Maximum recursion depth exceeded when using EP + hierarchical modelling #500 + workspace test_dataset.py failing #87point-source-jax-viz— PyAutoLens Use Result object of project when using summed Analysis #506 + workspace Feature/aggregator #91ag-interferometer-jax-viz(workspace Don't resume a MultiNest run if model.results exists #44),ag-quantity-jax-viz(workspace Attributes of hyper combined phase need to default to None #46),analysis-ellipse-jax(lib Feature/search drawer #412 + workspace Raise error is 'result.model' or 'result.instance' is not called #48)
Implementation Steps
Signature change —
autofit/non_linear/analysis/analysis.py:36-79:change the default of
use_jax_for_visualizationfromFalsetoNone(typed
Optional[bool]). Insert a sentinel-resolution block:Placement: after the
PYAUTO_DISABLE_JAXenv-var check(lines 42-45) and the JAX-not-installed fallback (lines 50-69), and
before the existing
if use_jax_for_visualization and not use_jaxwarning guard at line 71. Ordering matters: the env-var path and the
JAX-missing path already explicitly set both flags to
False, so thesentinel resolution downstream picks up the already-resolved
Falsecorrectly. The explicit-True-without-use_jax warning at lines 72-75 must
still fire for the explicit-opt-in-without-use_jax case (this is still a
user error worth a warning).
Docstring updates —
Analysis.__init__— add a short docstring documenting the new sentinelsemantics of
use_jax_for_visualization=None.fit_for_visualizationdocstring at lines 82-122: replace"use_jax_for_visualization=False (default) — plain self.fit_from..."with language reflecting that the default now mirrors
use_jax.Tests — extend
test_autofit/analysis/test_use_jax_for_visualization.py(existing file, six tests today). Add (skip-if-jax-installed where
appropriate to match the existing pattern):
test_use_jax_true_implicit_visualization_on—Analysis(use_jax=True)→_use_jax_for_visualization is Truetest_explicit_opt_out_when_use_jax_true—Analysis(use_jax=True, use_jax_for_visualization=False)→_use_jax_for_visualization is Falsetest_explicit_none_is_sentinel—Analysis(use_jax=True, use_jax_for_visualization=None)→_use_jax_for_visualization is Truetest_pyauto_disable_jax_forces_both_off_with_sentinel—set
PYAUTO_DISABLE_JAX=1thenAnalysis(use_jax=True, use_jax_for_visualization=None)still resolves to bothFalse.Smoke verification —
/smoke_testacross both workspace_test reposand the three production workspaces. Per audit, zero production scripts
currently set
use_jax_for_visualization=explicitly, so the onlybehaviour change is for scripts that already set
use_jax=True— thosewill now also turn on JAX viz. Phase 1 coverage exists for every dataset
type that gets touched.
Key Files
PyAutoFit/autofit/non_linear/analysis/analysis.py— signature + docstringchanges (lines 36-122)
PyAutoFit/test_autofit/analysis/test_use_jax_for_visualization.py— extendwith four new cases (note: this is the ACTUAL location; the prompt's
reference to
test_autofit/non_linear/analysis/test_analysis.pywas stale)Original Prompt
Click to expand starting prompt
Today
Analysis.__init__in PyAutoFit takes two independent flags:A user who wants the JAX-accelerated visualization path has to remember to
set both flags. Across all production workspaces (
autolens_workspace,autogalaxy_workspace,autofit_workspace) zero scripts setuse_jax_for_visualization=Truetoday (audit, 2026-05-08), even whereuse_jax=Truewould benefit. The flag is effectively dead weight — itexists to gate the still-evolving JIT visualization path, but once the
underlying coverage is green there is no reason it should not follow
use_jax.This task changes the default so that whenever
use_jax=True, thejit-cached visualization path is on by default. Users keep the explicit
opt-out via
use_jax_for_visualization=False.Why this matters
This is Phase 2 of
z_features/jax_visualization.md. The user-facinggoal stated in the z_feature is:
This prompt delivers that.
Blockers — must land first
All Phase 1 coverage prompts must be merged before flipping the default,
otherwise dataset types with no JAX viz smoke coverage will silently
regress for any user who runs them with
use_jax=True:autolens_workspace_test/jax_viz_interferometer_coverage.mdautolens_workspace_test/jax_viz_point_source_coverage.mdautogalaxy_workspace_test/jax_viz_dataset_coverage.mdPhase 0 prerequisites (
fit_imaging_pytree.md, the autogalaxy dispatchswap, the autogalaxy other-datasets pytree registration) must also be
done. Verify all of these in
complete.mdbefore starting.What to change
@PyAutoFit/autofit/non_linear/analysis/analysis.py:36-79— change thedefault of
use_jax_for_visualizationfromFalseto a sentinel thatfollows
use_jax. Recommended signature:Nonemeans "followuse_jax";True/Falseare explicit opt-in/opt-out.Resolution must happen before the existing
if use_jax_for_visualization and not use_jaxguard at line 71 so theguard's wording (
"requires use_jax=True; disabling...") still appliescorrectly when a user explicitly passes
Truewithoutuse_jax.The
PYAUTO_DISABLE_JAX=1short-circuit at lines 42-45 already forcesboth flags to
False, so the env-var override path is unaffected — butdouble-check that branch still resolves cleanly with the new sentinel.
The "JAX not installed" warning branch at lines 50-69 already sets
use_jax_for_visualization = False. That still works because the newsentinel resolution happens after this branch — but be careful about
ordering: the warning branch sets
use_jax = False, so the sentinelresolution downstream picks up
Falsecorrectly.Update the docstring at lines 82-122 to reflect the new default behaviour.
The warning at line 71-76 must remain — passing
use_jax_for_visualization=True, use_jax=Falseexplicitly is still a usererror (deserves a warning, then disabled).
What to verify
Unit tests for the resolution logic. Add cases to
@PyAutoFit/test_autofit/non_linear/analysis/test_analysis.py(orcreate the file if missing) covering:
Analysis()→ both offAnalysis(use_jax=True)→_use_jax_for_visualization=TrueAnalysis(use_jax=True, use_jax_for_visualization=False)→ off (explicit opt-out works)Analysis(use_jax=False, use_jax_for_visualization=True)→ off + warning loggedAnalysis(use_jax=True, use_jax_for_visualization=None)→ onPYAUTO_DISABLE_JAX=1env-var override forces both off regardlessWorkspace smoke. Run
/smoke_teston each workspace_test repo andon the production workspaces. The Phase 1 coverage protects against
regressions; this is the moment of truth.
No silent-warning regressions. Grep production workspaces and tests
for
use_jax_for_visualization=and confirm no script's behaviourchanges meaningfully. Any script that previously ran with
use_jax=Trueand no explicit
use_jax_for_visualizationwas implicitly opting out;after this change it will opt in. That is the intended behaviour but
should be verified case-by-case if any script's runtime changes
significantly.
Out of scope
use_jax=True) is a separate prompt.use_jax_for_visualizationparameter entirely. Theparameter stays — only its default changes.
Reference
@PyAutoFit/autofit/non_linear/analysis/analysis.py:36-79— site of the change@PyAutoFit/autofit/non_linear/analysis/analysis.py:82-122—fit_for_visualizationdocstring to updatecomplete.mdentriesjax-visualization,mge-jit-visualization(2026-04-19) — original Phase 0 ship notesPyAutoPrompt/z_features/jax_visualization.md— Phase 2 in the sequenced roadmap