From 904cd64e3d10e3e75331a7cafa58a8dd7ecf1958 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Tue, 14 Jul 2026 13:21:47 +0100 Subject: [PATCH] fix(interferometer): resample non-PD inversion instead of crashing the search AnalysisInterferometer.log_likelihood_function returned the fit figure_of_merit unwrapped, so a non-positive-definite inversion matrix at a sampled model raised a raw numpy.linalg.LinAlgError (Cholesky log-det, abstract.py:743) that propagated through Nautilus and killed the whole search on the NumPy path (release profile PYAUTO_DISABLE_JAX=1). The JAX path returns NaN and resamples, masking it. Mirror the imaging analysis (imaging/model/analysis.py:132-144): split on _use_jax, wrap the NumPy path in try/except -> af.exc.FitException, which the fitness resamples. Apply the same guard to the point-source analysis, which had the identical unguarded return. Resolves release-validation tail item G (PyAutoHeart#72). Not jax-0.10.2 drift. Co-Authored-By: Claude Opus 4.8 --- autolens/interferometer/model/analysis.py | 17 +++++++++++++---- autolens/point/model/analysis.py | 8 +++++++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/autolens/interferometer/model/analysis.py b/autolens/interferometer/model/analysis.py index 640be47fc..2a9f1a652 100644 --- a/autolens/interferometer/model/analysis.py +++ b/autolens/interferometer/model/analysis.py @@ -167,10 +167,19 @@ def log_likelihood_function(self, instance, shared=None): instance=instance, ) - return ( - self.fit_from(instance=instance, preloads=shared).figure_of_merit - - log_likelihood_penalty - ) + if self._use_jax: + return ( + self.fit_from(instance=instance, preloads=shared).figure_of_merit + - log_likelihood_penalty + ) + + try: + return ( + self.fit_from(instance=instance, preloads=shared).figure_of_merit + - log_likelihood_penalty + ) + except Exception as e: + raise af.exc.FitException def shared_state_from(self, instance: af.ModelInstance): """ diff --git a/autolens/point/model/analysis.py b/autolens/point/model/analysis.py index 9341fb040..ededb9193 100644 --- a/autolens/point/model/analysis.py +++ b/autolens/point/model/analysis.py @@ -130,7 +130,13 @@ def log_likelihood_function(self, instance): float The log likelihood indicating how well this model instance fitted the imaging data. """ - return self.fit_from(instance=instance).log_likelihood + if self._use_jax: + return self.fit_from(instance=instance).log_likelihood + + try: + return self.fit_from(instance=instance).log_likelihood + except Exception as e: + raise af.exc.FitException def fit_from( self,