Repository navigation
Description
Overview
The interferometer analysis crashes the whole non-linear search when a sampled model produces a non-positive-definite inversion matrix. AnalysisInterferometer.log_likelihood_function returns the fit's figure_of_merit unwrapped, so a numpy.linalg.LinAlgError: Matrix is not positive definite from the Cholesky log-det term (PyAutoArray/autoarray/inversion/inversion/abstract.py:743) propagates through Nautilus's multiprocessing pool and kills the search (~38 s). The imaging analysis already guards this; interferometer does not. Surfaced on the 2026-07-13 release-validation tail (resolves item G, PyAutoHeart#72).
This is NOT jax-0.10.2 numerical drift (the original hypothesis). It is a NumPy/JAX backend divergence: the release profile runs interferometer/model_fit.py with PYAUTO_DISABLE_JAX=1 (NumPy path), where np.linalg.cholesky raises on a non-PD matrix; the JAX path returns NaN, which the fitness resamples — so JAX silently rejects the same pathological point that NumPy crashes on. Reproduced locally on jax 0.10.2: crashes with PYAUTO_DISABLE_JAX=1, completes cleanly without it.
Plan
- Mirror the imaging analysis's NumPy-path guard in the interferometer analysis so a non-PD inversion at a sampled model resamples instead of crashing.
- Split
log_likelihood_functiononself._use_jax: JAX path returns unwrapped (must stay exception-free for tracing); NumPy path wraps the fit intry/except Exception → raise af.exc.FitException(caught byautofit/non_linear/fitness.py→resample_figure_of_merit). - Verify whether the point-source analysis has the same missing guard; align only if it shares the unwrapped figure_of_merit path.
- Validate: NumPy-path
interferometer/model_fit.pycompletes (bad point resampled) instead ofLinAlgError; JAX path unchanged; PyAutoLens unit suite green.
Detailed implementation plan
Affected Repositories
- PyAutoLens (primary — the fix)
- autolens_workspace_test (repro / validation only; no edit expected)
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| ./PyAutoLens | main | clean |
| ./autolens_workspace_test | main | clean |
Suggested branch: feature/interferometer-analysis-fitexception
Implementation Steps
autolens/interferometer/model/analysis.py—log_likelihood_function(~L166–173): replace the directreturn (fit… - penalty)with the imaging pattern fromautolens/imaging/model/analysis.py:132-144:(log_likelihood_penalty = self.log_likelihood_penalty_from(instance=instance) 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: raise af.exc.FitException
afis already imported at analysis.py:22.)autolens/point/model/analysis.py— inspectlog_likelihood_function(L91–160); align to the same guard only if it returns an unwrapped NumPy-path figure_of_merit.- Add/mirror a unit test asserting a non-PD interferometer inversion raises
FitExceptionon the NumPy path, if an imaging analogue exists to mirror.
Testing
- Repro (must now pass): wipe
output/build/model_fit/interferometer, then
PYAUTO_TEST_MODE=0 PYAUTO_SKIP_WORKSPACE_VERSION_CHECK=1 PYAUTO_DISABLE_JAX=1 JAX_ENABLE_X64=True python scripts/interferometer/model_fit.py→ completes instead ofLinAlgError. - JAX path unchanged: same script with no env → still completes.
- Unit:
pytest test_autolens/interferometer/(NumPy-only). - Trade-off: catching broad
Exception → FitExceptionis the accepted sibling (imaging) pattern; real bugs still surface on the unwrapped JAX path.
Key Files
autolens/interferometer/model/analysis.py— the fix (missing_use_jaxsplit + try/except).autolens/imaging/model/analysis.py:132-144— the reference pattern to mirror.PyAutoArray/autoarray/inversion/inversion/abstract.py:743— where the rawLinAlgErrororiginates (Cholesky log-det of the regularization matrix).autofit/non_linear/fitness.py:235,239— whereFitException/ NaN becomeresample_figure_of_merit.
Original Prompt
Click to expand starting prompt
interferometer/model_fit crashes with numpy.linalg.LinAlgError: Matrix is not positive definite on the 2026-07-13 release-validation tail (PyAutoHeart#72), under the release profile (PYAUTO_TEST_MODE=0). Confirmed diagnosis (2026-07-14): the release profile runs the script with PYAUTO_DISABLE_JAX=1 (NumPy path); np.linalg.cholesky raises on a non-PD regularization matrix at a sampled model, whereas the JAX path returns NaN and resamples. The interferometer analysis lacks the NumPy-path try/except → FitException guard that the imaging analysis has (imaging/model/analysis.py:132-144). Fix: mirror the imaging guard in interferometer/model/analysis.py; verify point_source. NOT jax-0.10.2 drift.
Activity
Jammy2211 commentedon Jul 14, 2026
⏸ Parked at ship sign-off —
--autosupervised (bug cap)The fix is implemented and validated in the worktree but not committed/pushed. Under the autonomy contract, the
bugwork-type caps atsupervised, so the ship step (commit / push / PR) is a human sign-off gate — this run stops here rather than opening the PR. Answer below to ship (or adjust scope) and I'll runship_libraryfrom the recorded state.What was done
Diagnosis (overturns the original hypothesis): not jax-0.10.2 drift. The release profile runs
interferometer/model_fit.pywithPYAUTO_DISABLE_JAX=1(NumPy path). A non-PD regularization matrix at a sampled model makesnp.linalg.cholesky(PyAutoArray/.../abstract.py:743, log-det evidence term) raiseLinAlgError, which propagates through Nautilus and kills the search. The JAX path returns NaN → resampled, so it silently rejects the same point. The interferometer analysis simply lacked the NumPy-path guard the imaging analysis already has.Fix —
autolens/interferometer/model/analysis.py, mirroringimaging/model/analysis.py:132-144:The JAX branch is byte-for-byte unchanged (it must stay exception-free for tracing; NaN → resample already handles it). The NumPy branch now raises
af.exc.FitException, whichautofit/non_linear/fitness.py:235catches →resample_figure_of_merit. The method docstring already promised this behaviour ("the model is discarded and its likelihood value is passed to the non-linear search in a way that it ignores it").Validation (worktree, jax 0.10.2)
interferometer/model_fit.py,PYAUTO_DISABLE_JAX=1(release config)LinAlgError(exit 1)Search complete, exit 0interferometer/model_fit.py, JAX path (no disable)pytest test_autolens/interferometer/Self-review (ship-gate leg 3)
CLEAN — single causal file, 13/4 lines, no unrelated scope; mirrors the established sibling (imaging) pattern; the accepted broad
except Exceptionmatches imaging and is guarded to the NumPy path only (real bugs still surface on the unwrapped JAX path).Sign-off question — scope
autolens/point/model/analysis.pyhas the same latent gap:log_likelihood_functionreturnsself.fit_from(instance=instance).log_likelihoodunwrapped, no_use_jaxsplit, no try/except — and its docstring makes the same discard-on-exception promise. It is not the reported/reproduced bug and uses a different return path (.log_likelihood, no penalty/shared), so I kept this PR narrow.How should I ship?
point/model/analysis.pyin the same style now.On A or B I run
ship_library(commit → push → open the pending-release PR against PyAutoLens; merge stays yours). This resolves release-validation tail item G (PyAutoHeart#72).Jammy2211 commentedon Jul 14, 2026
✅ Shipped under the Heart-RED corrective-PR exception — PR #607 (open, not merged)
Human authorization (verbatim, contemporaneous, 2026-07-14):
RED reason cleared (contributor):
release validation FAILED (stage integrate)— re-read frompyauto-heart readinessat ship time, unchanged from the authorized string.Causal map: Heart RED
release validation FAILED (stage integrate)→ #606 diagnosis (NumPy-path unguarded Cholesky log-det crash on a non-PD inversion) → NumPy-pathtry/except → af.exc.FitExceptionguard mirroringimaging/model/analysis.py:132-144→ commit904cd64e3→ PR #607.Diff (exactly as authorized — no mixed scope):
autolens/interferometer/model/analysis.py(+13/−4)autolens/point/model/analysis.py(+7/−1)Validation:
interferometer/model_fit.py(PYAUTO_DISABLE_JAX=1, real search) — completes (bad point resampled); was aLinAlgErrorcrash at the first sampled point.pytest test_autolens/— 381 passed (incl. 22 interferometer + 58 point).Scope & limits (AUTONOMY.md): this permitted commit/push/open-one-PR only. No merge, no issue close, no release. This PR clears only the interferometer contributor to the stage-integrate failure; the sibling RED reasons remain and Heart stays RED / release stays blocked until each clears by its own path:
workspace validation not passing (3 failed, 2026-07-09)58 stale parked script(s)PyAutoMind: open PR 14d oldinstall verification not runRecovery sequence (resumes only along this path): a human merges #607 (separate human act) → fresh post-merge wheels are built → release-integration validation is re-run on
main→ Heart emits a new verdict. Release stayshuman-requiredthroughout.Jammy2211 commentedon Jul 14, 2026
🔀 PR #607 merged (squash
5250d80a5) — issue kept openMerged by explicit human direction (2026-07-14). Per the corrective-red recovery sequence, this issue stays open and release stays blocked until the corrective validation completes:
main.The RED reason
release validation FAILED (stage integrate)is only partially cleared — this fix removes the interferometermodel_fit.pycontributor (tail item G); the sibling RED reasons remain (workspace validation 3 failed,58 stale parked scripts,PyAutoMind open PR 14d old,install verification not run), so Heart stays RED. Every release remainshuman-required.Jammy2211 commentedon Jul 14, 2026
Corrective validation GREEN — closing
The fresh
mode=releasevalidation run on the currentmainHEADs passed end-to-end:v2026.7.14.1.dev66001— all 5 wheels built + uploaded.release_ready: true; Heart is now YELLOW (no RED reasons remain).This fix is on the validated
mainHEADs (commit_shasmatched), so its corrective validation is satisfied. Closing.