fix(interferometer): resample non-PD inversion instead of crashing the search#607
Merged
Merged
Conversation
…e 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 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a hard crash where the interferometer (and point-source) analyses kill the whole non-linear search when a sampled model produces an invalid inversion.
AnalysisInterferometer.log_likelihood_functionreturned the fit'sfigure_of_meritunwrapped, so a non-positive-definite inversion matrix at a sampled model raised a rawnumpy.linalg.LinAlgError: Matrix is not positive definite(Cholesky log-det evidence term,PyAutoArray/.../abstract.py:743) that propagated through Nautilus's multiprocessing pool and killed the search (~38 s) on the NumPy path (release profilePYAUTO_DISABLE_JAX=1). The JAX path returns NaN → resampled, silently masking it. This is not jax-0.10.2 numerical drift (the original hypothesis) — it is a NumPy/JAX backend divergence.The imaging analysis already guards this (
imaging/model/analysis.py:132-144): split onself._use_jax, wrap the NumPy path intry/except → af.exc.FitException, whichautofit/non_linear/fitness.py:235catches and resamples. This PR mirrors that guard in the interferometer analysis, and applies the same guard to the point-source analysis, which had the identical unguarded return. Both method docstrings already promised this discard-on-exception behaviour.Resolves release-validation tail item G (PyAutoHeart#72). Refs #606 (issue kept open pending corrective validation — fresh wheels + release-integration rerun + new Heart verdict).
API Changes
None — internal behaviour change only.
log_likelihood_functionkeeps its signature; on the NumPy backend it now raisesaf.exc.FitException(a resample signal the search already handles) instead of propagating a rawLinAlgErrorfor a failed inversion. The JAX branch is byte-for-byte unchanged.Test Plan
autolens_workspace_test/scripts/interferometer/model_fit.py(PYAUTO_DISABLE_JAX=1 JAX_ENABLE_X64=True, real search) — completes (bad point resampled) vs.LinAlgErrorcrash before the fix.interferometer/model_fit.py(no disable) — still completes (unchanged branch).pytest test_autolens/interferometer/— 22 passed.pytest test_autolens/point/— 58 passed.pytest test_autolens/— full suite: 381 passed.Heart-RED corrective-PR exception (human-authorized)
Opened under the
AUTONOMY.mdcorrective-PR exception while Heart is RED.release validation FAILED (stage integrate)— this PR repairs the interferometermodel_fit.pystage-integrate crash (tail item G).release validation FAILED (stage integrate)→ fix(interferometer): resample non-PD inversion instead of crashing the search #606 diagnosis (NumPy-path unguarded Cholesky log-det crash) → NumPy-pathtry/except → FitExceptionguard mirroring imaging → this PR.workspace validation not passing (3 failed, 2026-07-09),58 stale parked script(s),PyAutoMind: open PR 14d old,install verification not run.Validation checklist (--auto run — corrective-red)
bug→ supervised); shipped via the human-authorized Heart-RED corrective-PR exception, not the standard autonomous gate.test_autolens/) incl. 22 interferometer + 58 point · smoke = the NumPy-pathmodel_fit.pyreal-search repro (now completes) · review self-CLEAN (two files, mirrors imaging) · Heart RED — corrective exception, reason quoted above.Generated by the PyAutoLabs agent workflow.