Skip to content

fix: test-mode-gate singular/non-PD inversion crash (release tail)#389

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/inversion-testmode-singular-guard
Jul 14, 2026
Merged

fix: test-mode-gate singular/non-PD inversion crash (release tail)#389
Jammy2211 merged 1 commit into
mainfrom
feature/inversion-testmode-singular-guard

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Closes part of PyAutoArray#388.

Summary

Return a benign dummy from the inversion reconstruction / log-det sites only when autoconf.is_test_mode() is active, instead of raising on a singular/non-PD curvature-regularization matrix. In test mode the fitted model is fabricated / under-converged and the inversion output is discarded, so an unguarded test-mode path (search chaining, preloads, result construction) should not crash — while the real likelihood path already resamples such solutions via FitException.

Normal operation is byte-for-byte unchanged: all four sites re-raise exactly as before (LinAlgError / InversionException), so real-mode numerics and search resample behaviour are untouched. numpy-only by construction (the JAX linalg path returns NaN rather than raising). No conditioning floor — nothing perturbs real evidences/reconstructions.

Sites gated on is_test_mode():

  • inversion_util.reconstruction_positive_negative_from (xp.linalg.solve)
  • inversion_util.reconstruction_positive_only_from (fnnls except)
  • abstract.log_det_curvature_reg_matrix_term (cholesky)
  • abstract.log_det_regularization_matrix_term (cholesky)

Corrective-PR exception (Heart RED)

Opened under the human-authorized corrective-PR exception (AUTONOMY.md), authorized in-session 2026-07-14.

  • Named RED reason: release validation FAILED (stage integrate)
  • Causal map: integrate stage FAILed on interferometer/.../multi_gaussian_expansion/slam.py + imaging/features/pixelization/cpu_fast_modeling.py (run 29341418859) → both crash on an unguarded singular inversion in test-mode chained paths → 4-site is_test_mode() dummy guard → this PR. Follow-up to PyAutoLens#607, which guarded the real/likelihood path but not these test-mode paths.
  • Scope: this one pending-release PR only; no merge, issue close, release, or rehearsal in this action. Merge is a separate human act.
  • Sibling RED reason remains: PyAutoArray: on branch feature/ticks-minus-in-math (not main) — Heart stays RED until that is also resolved and integrate validation re-runs.

Caveat on causal strength

Unlike #607 (deterministic repro), these two FAILs did not reproduce on clean main (TEST_MODE=1 and =2 both pass; the crash is flaky/non-deterministic). This is a test-mode-gated dummy, not a real-path correctness change. It plausibly removes the FAILs; confirmation comes only from the post-merge fresh-wheels re-validation of the integrate stage.

Validation checklist

  • New numpy-only unit tests: singular matrix raises normally; under monkeypatched PYAUTO_TEST_MODE returns finite dummies.
  • test_autoarray/inversion/inversion/ (util + abstract): 41 passed.
  • Full test_autoarray/inversion/: 233 passed.
  • No JAX in unit tests (per repo rule); JAX path covered by *_workspace_test parity scripts.
  • Post-merge: fresh wheels + re-run release integration on main + new Heart verdict (required before any release decision).

Self-review: CLEAN — commit 48fae1ac, 3 files (+101/−12), no mixed scope.

Return a benign dummy from the inversion reconstruction/log-det sites when
PYAUTO_TEST_MODE is active, instead of raising on a singular/non-PD
curvature-regularization matrix. In test mode the fitted model is fabricated /
under-converged and the inversion output is discarded, so an unguarded
test-mode path (search chaining, preloads, result construction) should not
crash — while the real likelihood path already resamples such solutions via
FitException.

Normal operation is byte-for-byte unchanged: the four sites re-raise exactly as
before (LinAlgError / InversionException), so real-mode numerics and the search
resample behaviour are untouched. numpy-only: the JAX linalg path returns NaN
rather than raising.

Sites gated on autoconf.is_test_mode():
- inversion_util.reconstruction_positive_negative_from (xp.linalg.solve)
- inversion_util.reconstruction_positive_only_from (fnnls except)
- abstract.log_det_curvature_reg_matrix_term (cholesky)
- abstract.log_det_regularization_matrix_term (cholesky)

Fixes the flaky release-tail FAILs slam.py / cpu_fast_modeling.py
(PyAutoArray#388; follow-up to PyAutoHeart#72, PyAutoLens#607).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Jul 14, 2026
@Jammy2211 Jammy2211 merged commit 1ff9028 into main Jul 14, 2026
4 checks passed
@Jammy2211 Jammy2211 deleted the feature/inversion-testmode-singular-guard branch July 14, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release PR queued for the next release build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant