Skip to content

Commit 5250d80

Browse files
Jammy2211Jammy2211claude
authored
fix(interferometer): resample non-PD inversion instead of crashing the search (#607)
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: Jammy2211 <JNightingale2211@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 242e54e commit 5250d80

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

autolens/interferometer/model/analysis.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,19 @@ def log_likelihood_function(self, instance, shared=None):
167167
instance=instance,
168168
)
169169

170-
return (
171-
self.fit_from(instance=instance, preloads=shared).figure_of_merit
172-
- log_likelihood_penalty
173-
)
170+
if self._use_jax:
171+
return (
172+
self.fit_from(instance=instance, preloads=shared).figure_of_merit
173+
- log_likelihood_penalty
174+
)
175+
176+
try:
177+
return (
178+
self.fit_from(instance=instance, preloads=shared).figure_of_merit
179+
- log_likelihood_penalty
180+
)
181+
except Exception as e:
182+
raise af.exc.FitException
174183

175184
def shared_state_from(self, instance: af.ModelInstance):
176185
"""

autolens/point/model/analysis.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,13 @@ def log_likelihood_function(self, instance):
130130
float
131131
The log likelihood indicating how well this model instance fitted the imaging data.
132132
"""
133-
return self.fit_from(instance=instance).log_likelihood
133+
if self._use_jax:
134+
return self.fit_from(instance=instance).log_likelihood
135+
136+
try:
137+
return self.fit_from(instance=instance).log_likelihood
138+
except Exception as e:
139+
raise af.exc.FitException
134140

135141
def fit_from(
136142
self,

0 commit comments

Comments
 (0)