Overview
al.reg.ConstantZeroth is a public, exported regularization scheme that has never worked through its class API — two independent defects make it dead code presenting as a feature (found in the wsdev#104 reg-logdet investigation, independently confirmed by a second reviewer who ran it, and re-verified against main on 2026-08-17). Fixing it resurrects a genuinely useful well-conditioned alternative: the zeroth-order + lambda_z^2 * I term is exactly what lifts the graph-Laplacian null mode that makes Constant/Adapt fragile (the 1e-8-below-the-noise-floor conditioning collapse). This is Phase 8C of the inference-methods programme (autolens_profiling#134): ConstantZeroth is an ALTERNATIVE regularization model, never a silent AdaptSplit replacement.
Plan
- Reproduce both failures on clean main FIRST (a two-line call through the class API, then through the util function with correct args).
- Fix defect 1:
constant_zeroth_regularization_matrix_from builds zeroth = xp.eye(P) where P = neighbors.shape[1] is the neighbour count (e.g. 4), not S = mesh pixel count — const + zeroth broadcasts/raises. The zeroth term must be the full S x S scaled identity.
- Fix defect 2:
ConstantZeroth.regularization_matrix_from (class API) omits the required neighbors_sizes argument — TypeError before the shape bug is even reached. Verify the exact call site/signature on main first.
- Check siblings
adapt_split_zeroth.py / brightness_zeroth.py for the same copy-paste pattern (eye(P) / missing arg); fix if present.
- Unit tests (numpy-only per repo policy): matrix shape
(S, S); positive-definiteness (smallest eigenvalue >= lambda_z^2, i.e. NO null mode — the whole point of the zeroth-order term); class-API path returns without raising; zeroth term reduces to Constant's matrix + lambda_z^2*I where the schemes overlap.
- Run the full suite
pytest test_autoarray/.
- Do NOT bundle with the reg-logdet log-det change or the Adapt double-square probe — independent, self-contained defect. Do NOT change Constant/Adapt/AdaptSplit numerics.
Detailed notes
Affected Repositories
- PyAutoArray (primary, only)
Key Files
autoarray/inversion/regularization/constant_zeroth.py — both defects (shape bug ~lines 68-72; missing-arg at the class API ~lines 121-129 as of the 2026-07 read; re-verify line numbers on main).
autoarray/inversion/regularization/abstract.py / regularization_util.py — reference for the correct call signatures.
- Possible siblings:
adapt_split_zeroth.py, brightness_zeroth.py.
Suggested branch: feature/constant-zeroth-repair
Coordination
PyAutoArray also carries the version-stamp-sync-guards branch (touches only autoarray/__init__.py + files/release.sh) and this work is file-disjoint. This issue is prepared for a REMOTE (cloud) session: clone PyAutoLabs/PyAutoArray, branch from main, PR when green. Merge is a human act.
Science classification
Target-changing relative to AdaptSplit (a different regularization model) — this fix makes the scheme WORK, it does not recommend it. Record the null-mode-lift verification (spectrum before/after) in the PR so autolens_profiling Phase 8C can cite it.
Original Prompt
Click to expand starting prompt
See PyAutoMind/active/constant_zeroth_broken_dead_code.md (filed 2026-07-17 during the reg-logdet investigation; re-verified against main 2026-08-17 — both defects still present).
Overview
al.reg.ConstantZerothis a public, exported regularization scheme that has never worked through its class API — two independent defects make it dead code presenting as a feature (found in the wsdev#104 reg-logdet investigation, independently confirmed by a second reviewer who ran it, and re-verified against main on 2026-08-17). Fixing it resurrects a genuinely useful well-conditioned alternative: the zeroth-order+ lambda_z^2 * Iterm is exactly what lifts the graph-Laplacian null mode that makes Constant/Adapt fragile (the 1e-8-below-the-noise-floor conditioning collapse). This is Phase 8C of the inference-methods programme (autolens_profiling#134): ConstantZeroth is an ALTERNATIVE regularization model, never a silent AdaptSplit replacement.Plan
constant_zeroth_regularization_matrix_frombuildszeroth = xp.eye(P)whereP = neighbors.shape[1]is the neighbour count (e.g. 4), notS= mesh pixel count —const + zerothbroadcasts/raises. The zeroth term must be the fullS x Sscaled identity.ConstantZeroth.regularization_matrix_from(class API) omits the requiredneighbors_sizesargument —TypeErrorbefore the shape bug is even reached. Verify the exact call site/signature on main first.adapt_split_zeroth.py/brightness_zeroth.pyfor the same copy-paste pattern (eye(P)/ missing arg); fix if present.(S, S); positive-definiteness (smallest eigenvalue >= lambda_z^2, i.e. NO null mode — the whole point of the zeroth-order term); class-API path returns without raising; zeroth term reduces to Constant's matrix + lambda_z^2*I where the schemes overlap.pytest test_autoarray/.Detailed notes
Affected Repositories
Key Files
autoarray/inversion/regularization/constant_zeroth.py— both defects (shape bug ~lines 68-72; missing-arg at the class API ~lines 121-129 as of the 2026-07 read; re-verify line numbers on main).autoarray/inversion/regularization/abstract.py/regularization_util.py— reference for the correct call signatures.adapt_split_zeroth.py,brightness_zeroth.py.Suggested branch:
feature/constant-zeroth-repairCoordination
PyAutoArray also carries the
version-stamp-sync-guardsbranch (touches onlyautoarray/__init__.py+files/release.sh) and this work is file-disjoint. This issue is prepared for a REMOTE (cloud) session: clone PyAutoLabs/PyAutoArray, branch from main, PR when green. Merge is a human act.Science classification
Target-changing relative to AdaptSplit (a different regularization model) — this fix makes the scheme WORK, it does not recommend it. Record the null-mode-lift verification (spectrum before/after) in the PR so autolens_profiling Phase 8C can cite it.
Original Prompt
Click to expand starting prompt
See
PyAutoMind/active/constant_zeroth_broken_dead_code.md(filed 2026-07-17 during the reg-logdet investigation; re-verified against main 2026-08-17 — both defects still present).