Skip to content

fix: intrinsic regularization log det H uses the pseudo-determinant #682

Closed

Description

@Jammy2211

Overview

The smoothness regularization schemes (Constant, ConstantSplit, Adapt, AdaptPower, AdaptSplit, AdaptSplitPower) build an H whose rows sum to zero, so the constant vector is a null mode held up only by the net 1e-8 diagonal jitter. The evidence term log det H therefore contains log(1e-8 + O(eps·‖H‖)): an arbitrary constant plus rounding noise. At large coefficients that noise breaks eager/jit agreement and gradient checks. It's latent on main for Delaunay + AdaptSplit, and it's what blocks the #609 KNN fix. Found while investigating #609 (mechanism write-up).

Plan

  • Mark each regularization scheme with whether its H has the constant vector as an exact null mode by construction. Measured: the six smoothness schemes yes; the zeroth and kernel schemes no.
  • For those schemes, normalise the evidence with the pseudo-determinant (the standard intrinsic-GMRF treatment): ground one pixel per regularized mapper block, log pdet(H) = Σ_b log P_b + log det(H with those rows/cols removed). This stays sparse and jit-static.
  • A unit test pins each scheme's flag to its measured spectrum, and the pseudo-determinant is checked against an eigenvalue oracle.
  • Validate with autolens_workspace_test jax_grad/delaunay.py (log det H eager/jit, latent drift on main) and the full PyAutoArray suite. fix: Preserve KNN neighbors in a partial final point block #609's PR then follows and must leave jax_grad/knn.py green with no tolerance changes.
  • Likelihood change (approved by the maintainer 2026-11-09): every fit using these six schemes shifts its log evidence by a constant +½·ln(1e8) = +9.21 nats per regularized mapper. Parameter inference is unchanged apart from noise removal.
  • Tier: judge. Merge mode: human /prm.
Detailed implementation plan

Affected Repositories

  • PyAutoArray (primary)

Branch Survey

Repository Current Branch Dirty?
./PyAutoArray main clean

Suggested branch: feature/intrinsic-reg-pseudo-det. PyAutoArray is also claimed by magnification-maps-wiring; the maintainer override of 2026-11-08 applies.

Implementation Steps

  1. autoarray/inversion/regularization/abstract.py: add has_constant_null_mode: bool = False with a docstring explaining the intrinsic prior.
  2. Set it True on Constant, ConstantSplit, Adapt, AdaptPower, AdaptSplit, AdaptSplitPower. Set it explicitly False on AdaptSplitZeroth / AdaptSplitZerothPower, which subclass Adapt and add a zeroth term. CurvatureMask / FourthOrderMask stay False: higher-order operators may have larger null spaces, which is a follow-up.
  3. autoarray/inversion/inversion/abstract.py log_det_regularization_matrix_term: compute the grounded indices (first parameter of each intrinsic regularized block, in regularization_matrix_reduced coordinates). Return Σ log P_b + _log_det_symmetric_from(H[keep][:, keep]). The per-scheme slogdet hook (kernel schemes) is untouched.
  4. Tests in test_autoarray/inversion/: (a) flag vs measured spectrum for every scheme on Delaunay and rectangular fixtures; (b) the grounded log det equals the eigen pseudo-determinant and is independent of the jitter; (c) a multi-mapper block case; (d) update hard-coded evidence values that shift by exactly +9.21 nats per intrinsic mapper.
  5. Validate: full unit suite, autolens_workspace_test jax_grad/delaunay.py and jax_likelihood/*. Pinned likelihood values there may shift (expected: log_likelihood pins unaffected; evidence/figure-of-merit pins shift +9.21). Report them rather than editing workspace pins (library-first).

Key Files

  • autoarray/inversion/regularization/*.py: scheme flags
  • autoarray/inversion/inversion/abstract.py: log_det_regularization_matrix_term

Original Prompt

Click to expand starting prompt

Mind prompt draft/bug/autoarray/intrinsic_regularization_log_det_pseudo_determinant.md (Priority high, Consequence judge).

Witness:

  • For every intrinsic scheme (Constant, ConstantSplit, Adapt, AdaptPower, AdaptSplit, AdaptSplitPower), log det H equals the pseudo-determinant (Σ log P_b + log det of H grounded on one pixel per block), independently of the jitter.
  • autolens_workspace_test jax_grad/delaunay.py: log det H eager/jit agree to 1e-10 (1.2e-8 on main).
  • A unit test pins has_constant_null_mode to the measured spectrum of every scheme.

Symptom. The smoothness schemes build an H whose rows sum to zero by construction, so the constant vector is a null mode held up only by the net 1e-8 diagonal jitter. Measured on Delaunay and rectangular fixtures: λ_min(H) = 1.000e-8, with eigenvector exactly 1/√P, for Constant, ConstantSplit, Adapt, AdaptPower, AdaptSplit and AdaptSplitPower. The zeroth and kernel schemes have λ_min of order 1. log det H therefore contains log(1e-8 + O(eps·‖H‖)). At large coefficients (AdaptSplit outer = 10, ‖H‖ ≈ 3e4), rounding moves it by about 1e-4 relative:

Fix. Treat H as the precision of an intrinsic GMRF and normalise with the pseudo-determinant over the non-constant modes. For a symmetric H with null vector 1/√P, pdet(H) = P · det(H with one row and column deleted), which stays sparse and static-indexed under jit.

  • Gate per scheme with an explicit has_constant_null_mode attribute: False by default, explicitly False on zeroth-term subclasses.
  • CurvatureMask / FourthOrderMask stay unchanged; higher-order operators may have larger null spaces (follow-up).

The maintainer approved changing likelihood values on 2026-11-09. Every fit using these six schemes shifts its log evidence by a constant +½·ln(1e8) = +9.21 nats per regularized mapper; parameter inference is unchanged apart from noise removal. This ships before the #609 KNN fix (two-PR decision, 2026-11-08).

Activity

  1. Jammy2211 commented on Nov 9, 2026

    @Jammy2211
    CollaboratorAuthor

    Library PR Created

    API change summary:

    • Added AbstractRegularization.has_constant_null_mode.
    • log_det_regularization_matrix_term is now the pseudo-determinant for Constant, ConstantSplit, Adapt, AdaptPower, AdaptSplit and AdaptSplitPower. Log evidence / figure_of_merit rises by +9.21 nats per such regularized mapper.
    • No code migration is needed.

    Workspace impact (option ii, pins). Six autolens_workspace_test scripts pin figure-of-merit values that shift by exactly +9.21 or +18.42:

    • imaging/jax_likelihood/delaunay.py
    • imaging/jax_likelihood/rectangular.py
    • imaging/jax_likelihood/rectangular_rtu.py
    • imaging/jax_likelihood/rectangular_mge.py
    • imaging/jax_likelihood/rectangular_dspl.py
    • imaging/jax_likelihood/rectangular_dspl_rtu.py

    rectangular_mge_rtu.py hangs in its vmap step on main as well, so it can't be re-measured here.

    Next: /start_workspace → companion autolens_workspace_test PR updating those pins.


    Generated by Claude Code

  2. Jammy2211 commented on Nov 9, 2026

    @Jammy2211
    CollaboratorAuthor

    Shipped — 2026-11-09


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions