Skip to content

fix(viz): make _compute_critical_curve_lines failures loud, not silent - #527

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/fast-viz-zero-contour-perf
May 21, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/fast-viz-zero-contour-perf

Conversation

@Jammy2211

@Jammy2211 Jammy2211 commented May 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Tightens the broad except Exception: in _compute_critical_curve_lines so future regressions of the "ZeroSolver raised, viz fell back to all-zero" failure mode fail loud, not silent.

Two recent reverts share the same shape — a JAX-tracing failure inside the visualization path that the broad except masked into (None, None, None, None):

  • 2026-04-19 — PyAutoGalaxy commit abd7b717 reverted the YAML default flip to zero_contour. Critical curves silently vanished on HPC runs.
  • 2026-05-17 — PyAutoFit PR #1280 reverted the use_jax_for_visualization=True default. Source-plane FITS files wrote all-zero across every Euclid DR1 tile and Einstein-radius posteriors collapsed to the full prior.

Both were invisible at run time. The next attempt to flip the default needs a loud failure if it regresses, so this PR:

  • Keeps ModuleNotFoundError silent (the jax_zero_contour absence is already warned upstream in plot_utils._critical_curves_method).
  • Keeps ValueError silent (no zero crossings in the eigenvalue grid — curves genuinely don't exist for the model).
  • Logs anything else as WARNING with exc_info=True via the module logger, then still returns the no-overlay tuple so plotting itself doesn't crash.

Companion PR in PyAutoGalaxy (Jammy2211/PyAutoGalaxy#434) fixes the underlying perf bug that made zero_contour unusable as a default.

Closes PyAutoLabs/PyAutoGalaxy#433 (alongside the PyAutoGalaxy companion).

API Changes

_compute_critical_curve_lines is a private helper — no public API surface changes. Behavioural change: unexpected exceptions now emit a WARNING log with traceback before falling back to no-overlay rendering, instead of being silently swallowed.

See full details below.

Test Plan

  • New parametrized test test__compute_critical_curve_lines__known_recoverable_exceptions__silent — confirms ModuleNotFoundError and ValueError fall through with no log record emitted.
  • New test test__compute_critical_curve_lines__unexpected_exception__logs_warning — confirms an unexpected RuntimeError produces exactly one WARNING record with exc_info attached.
  • pytest test_autolens/imaging/plot/ — 15 passed locally.
  • autolens_workspace_test/scripts/imaging/modeling_visualization_jit.py Part 1 + Visualization Sanity block run cleanly under the new exception flow.
Full API Changes (for automation & release notes)

Removed

  • None.

Added

  • None public.

Changed Signature

  • None.

Changed Behaviour

  • autolens.imaging.plot.fit_imaging_plots._compute_critical_curve_lines — replaces bare except Exception: with specific catches. ModuleNotFoundError and ValueError still fall through silently; anything else logs WARNING with traceback via the module logger before returning the no-overlay tuple.

Migration

  • None required. Downstream callers that previously relied on the silent fallback still get the same return value (None, None, None, None); they additionally see a WARNING log when an unexpected failure occurs.

🤖 Generated with Claude Code

The bare `except Exception: return None, None, None, None` in
_compute_critical_curve_lines silently swallowed ZeroSolver failures
during model fits, which is the root cause behind two recent viz
default reverts:
- PyAutoGalaxy abd7b717 (2026-04-19): zero_contour YAML default
  reverted because critical curves silently vanished on HPC.
- PyAutoFit #1280 (2026-05-17): use_jax_for_visualization=True
  default reverted because Euclid source planes wrote all-zero.

Both shared the same shape - a JAX-trace failure inside the viz
path that the broad except masked. Tighten so:
- ModuleNotFoundError (jax_zero_contour missing): silent (already
  warned upstream in plot_utils).
- ValueError (no zero crossings in eigenvalue grid): silent (the
  curves genuinely do not exist for the model).
- Anything else: WARNING log with exc_info=True so the next
  regression of this class fails loud.

Closes PyAutoLabs/PyAutoGalaxy#433 alongside the PyAutoGalaxy
companion PR.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Jammy2211

Copy link
Copy Markdown
Collaborator Author

Workspace PR: PyAutoLabs/autolens_workspace_test#111

@Jammy2211
Jammy2211 merged commit a91febc into main May 21, 2026
6 checks passed
@Jammy2211
Jammy2211 deleted the feature/fast-viz-zero-contour-perf branch May 21, 2026 17:46
@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.

perf: cache zero_contour solver + viz sanity net (fast_viz A')

1 participant