Skip to content

fix: PointSolver spurious candidates on r_core = 0 dPIE member cores #799

Closed

Description

@Jammy2211

Overview

On the autolens_visualization cluster model (autolens_profiling#439 / PR #440, stress draws 9 and 16, starting scales 1.0, 0.7, 0.5 and 0.3″), PointSolver returns a candidate exactly on an r_core = 0 scaling dPIE member core (e.g. (15.0, 9.0008), (5.5009, −6.4999)). The lens-equation residual there is 0.04″, against a last-step tolerance of about 0.002″. The deflection is discontinuous at a zero-core centre, so triangle containment passes without a true root, and the magnification filter does not catch it. This task adds an opt-in rejection rule (default off) that removes these points without losing true images. Part of epic cluster-pointsolver-speed (ledger).

Plan

  • Reproduce in a small unit test (one or two r_core = 0 dPIE members, eager + JIT). If that does not reproduce, extract a minimal case from docs(install): clone workspace at tag matching library version #440's viz draws 9/16.
  • Diagnose why the magnification filter passes the point (|μ| at 0.0008″ from a zero-core centre should be ≪ 0.1; the Hessian is likely sampled across the discontinuity).
  • Compare two rejection rules:
    • (A) a source-plane residual cut, |β(θ̂) − β| > k · pixel_scale_precision;
    • (B) a triangle consistency check: the traced final triangle's area vs |det A| × its image-plane area.
  • Neither rule may use the linearised |A⁻¹r|: it is huge near a singular core, so it would pass the spurious point.
  • Score both rules against existing evidence: the 1c/1d near-cusp candidates (workspace_test scripts/point_source/solver/image_accuracy_evidence.json) must lose no true image; the docs(install): clone workspace at tag matching library version #440 viz/simple draws must lose the spurious points with no change to oracle coverage.
  • Ship the winner as an opt-in solver option, default off, so behaviour is bit-identical. Turning it on by default is a human decision.
  • It must work as a static-shape mask under eager/JIT/vmap, leaving gradients and the custom-JVP rule untouched.

Tier: judge — merge mode: human /prm

Detailed implementation plan

Affected Repositories

  • PyAutoLens (primary)

Branch Survey

Repository Current Branch Dirty?
./PyAutoLens main clean (behind origin by 1)

Suggested branch: feature/point-solver-spurious-core
Worktree: ~/Code/PyAutoLabs-wt/point-solver-spurious-core/

Implementation Steps

  1. Repro tests. Fixture in test_autolens/point/triangles/test_solver_edge_cases.py: assert the spurious candidate exists with defaults (baseline) and is removed with the option on; run on NumPy and inside jax.jit.
  2. Diagnosis. Measure the residual, |μ| (_filter_low_magnification via LensCalc.magnification_2d_via_hessian_from) and the Hessian at the spurious point, against true images of similar |μ|.
  3. Option. New AbstractSolver.__init__ keyword named after the chosen rule (e.g. residual_threshold), default None:
    • threaded through for_grid, for_limits_and_scale and tree_flatten/tree_unflatten;
    • applied in PointSolver._solve_array beside _filter_low_magnification as an xp.where(..., nan) mask, so it becomes the inf sentinel;
    • in the JVP primal only, leaving the implicit fixed-point rule at the surviving positions unchanged.
  4. Evidence and threshold. A bounded diagnostic script (outside the library) checks A vs B on the 1c/1d fixtures and the docs(install): clone workspace at tag matching library version #440 viz/simple draws and fixes k. Results go in the PR body and an autolens_profiling ledger appendix.
  5. Tests. Defaults bit-identical (existing solver tests); eager/JIT/vmap parity with the option on; gradients finite and unchanged at true images.
  6. Out of scope:
    • starting-grid defaults (decided 2026-10-23: keep 1.0″);
    • workspace cluster scripts (validation-check draft);
    • the workspace_test CI witness (epic phase 2), filed once the rule is accepted.

Key Files

  • autolens/point/solver/point_solver.py — _solve_array, where the mask is applied
  • autolens/point/solver/shape_solver.py — AbstractSolver constructor, factories, pytree
  • autolens/point/solver/implicit_diff.py — custom-JVP wrapper (must stay untouched)
  • test_autolens/point/triangles/test_solver_edge_cases.py — new regression tests

Original Prompt

Click to expand starting prompt

@PyAutoLens PointSolver: spurious candidates exactly on r_core = 0 dPIE member cores

Type: feature
Target: autolens
Repos:

Why

On autolens_profiling#439's viz-model stress draws 9 and 16, at starting scales 1.0, 0.7, 0.5 and 0.3″, PointSolver returned a candidate exactly at an r_core = 0 scaling dPIE member core (e.g. (15.0, 9.0008)) with a lens-equation residual of 0.04″ against a last-step tolerance of about 0.002″. The deflection is discontinuous at a zero-core dPIE/SIS centre, so the triangle containment test passes without a true root. The independent oracle rejects these; the production solver does not.

Deliverables

  1. Reproduce on a single SIS-like member with r_core = 0 (unit test fixture, eager + JIT).
  2. Investigate an optional final residual filter (|β(θ) − β| below the precision) or core-aware containment; preserve JIT/vmap/gradient behaviour and the existing eager/JIT parity tests.
  3. Any default change is a human decision; add the regression to autolens_workspace_test per the epic's CI-witness contract (phase 2) once accepted.

Out of scope

Starting-grid defaults (decided separately); cluster workspace scripts.

Activity

  1. Jammy2211 commented on Oct 23, 2026

    @Jammy2211
    CollaboratorAuthor

    Library PR created

    • PyAutoLens#800 (a25ca735a, pending-release): an opt-in residual_threshold (default None, so behaviour is unchanged). It rejects candidates with |β(θ̂) − β| > k · pixel_scale_precision; k = 10 is recommended.
    • Evidence (diagnostic, laptop CPU fp64):
      • true candidates reach at most 3.58× the precision (viz), 2.21× (simple) and 1.075× (1c/1d near-cusp);
      • the core points are at least 38.5×;
      • at k = 10 all 4 known core points are removed and nothing else changes, and the 1c/1d rows are bit-identical to the default.
    • The rejected rule, a triangle-area consistency check, drops true near-cusp candidates.
    • Tests: 952 passed, 1 xfailed (the existing xfail).
    • No workspace impact: the default path is unchanged (guarded by residual_threshold is not None).
    • Tier judge: awaiting human /prm. Turning it on by default is a human decision; the workspace_test CI witness (epic phase 2) follows once the rule is accepted.
  2. Jammy2211 commented on Oct 23, 2026

    @Jammy2211
    CollaboratorAuthor

    Human decision 2026-10-23: residual_threshold is on by default at 10.0 (commit 58f561c04 on #800; None disables it).

    • Library: 952 passed, 1 xfailed.
    • Workspace smoke: autolens 41 + 2 notebooks, workspace_test 37, euclid 9, HowToLens 50, all passed.
    • Real-solve point-source scripts in workspace_test: 6 of 6 passed.
    • test_static_lattice_jax now pins None: it counts triangle-step traces, and the filter adds one trace of the padded candidates.
  3. Jammy2211 commented on Oct 23, 2026

    @Jammy2211
    CollaboratorAuthor

    Shipped

    Merged in #800 (67e9f1ff3), pending release. PointSolver now drops candidates whose source-plane residual exceeds residual_threshold × pixel_scale_precision. The default is 10.0; pass None to disable it. Pulse ledger: PyAutoPulse#73 (3aeeeae07). Next in the epic: the workspace validation check, then a workspace_test CI witness for the default-on filter.

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