Skip to content

feat: warn when PointSolver extent approaches observed positions #763

Closed

Description

@Jammy2211

Overview

Add a construction-time PointSolver extent diagnostic where observed point positions and a solver meet, making near-edge risks visible and offering an oversized-grid performance hint. Numerical solving and library defaults are unchanged.

Plan

  • Check observed positions and their noise against the solver bounds once per analysis.
  • Warn near/outside an edge; give an INFO hint for a much larger grid.
  • Test the geometry and logging with NumPy, then verify the existing JAX likelihood pin in a separate regression script.
  • Ship the library first with a linked workspace companion.

Detailed implementation plan

Proposed bounded implementation

  1. Add a private NumPy-only diagnostic called once by AnalysisPoint.__init__ in autolens/point/model/analysis.py when a solver and usable observed positions are present. Compare each position with the four stored solver bounds using margin 2 * initial scale + 3 * position sigma. Warn when outside/within that margin; the message must explain that observed-position coverage does not guarantee completeness over the model prior.
  2. Emit a softer INFO hint when both solver half-widths exceed three times the required observed-position envelope about the solver midpoint, including the same margin. Suppress the performance hint in test/small-dataset mode. No solver default or likelihood/JAX path changes. Handle solver=None, absent/empty positions and separate analyses independently.
  3. Add NumPy unit cases in test_autolens/point/model/test_analysis.py: safe, near-edge, outside, asymmetric/offset bounds, noise-scaled margins, oversize hint, absent inputs, test-mode behavior and one diagnostic per construction. Verify the full library suite. Existing autolens/analysis/result.py constructs solvers from the dataset mask grid; no extra masked-data fallback is proposed for those paths.
  4. Add one isolated workspace regression script beside scripts/point_source/jax_likelihood/image_plane.py to capture an undersized-grid warning and verify the established likelihood pin is unchanged, then run targeted point-source smoke. Library first, then workspace companion; keep the original campaign limits.

Survey and guard

Canonical PyAutoLens and autolens_workspace_test are both clean on main. Proposed branch: feature/pointsolver-extent-sanity-check. PyAutoLens is unclaimed. autolens_workspace_test is claimed by critical-curves-dispatch-audit, mesh-interpolator-numerics-audit, fit-util-masked-division and mesh-geometry-transformed-areas. start_workspace conflict guard refuses until the human permits coordinated disjoint work or the claims clear. No issue/worktree/source edits started for this phase.

Approval and coordination

Human: "I approve, continue" (2026-10-02), approving the implementation and coordinated disjoint workspace-test edits. Workspace work is restricted to a new point-source extent regression and its smoke registration/config; preserve other tasks' scripts and registrations. PyAutoLens tests use the existing test_analysis_point.py naming (the draft test_analysis.py path does not exist).

Branch survey

PyAutoLens and autolens_workspace_test are clean on main. Branch: feature/pointsolver-extent-sanity-check. Worktree: /home/jammy/Code/PyAutoLabs/.worktrees/pointsolver-extent-sanity-check. PyAutoLens is unclaimed. The human explicitly approved coordinated disjoint work alongside the active workspace-test tasks; this phase touches a new point_source/jax_likelihood/solver_extent.py and only its smoke registration/profile entry.

Original prompt

PointSolver grid-extent sanity check — warn when the data approach the solver grid edge, hint when the grid is oversized

Type: feature
Target: autolens
Repos:

  • PyAutoLens
  • autolens_workspace_test
    Themes:
  • point-source
  • profiling
    Difficulty: medium
    Autonomy: supervised
    Priority: high
    Status: formalised
    Consequence: judge
    Review-minutes: 20
    Unattended: ready
    Epic: point-source-cpu-speed
    Filed: 2026-09-26
    Parent: complete/2026/09/point-source-cpu-p4.md (issue autolens_profiling#314)

Human decision (2026-09-26, live)

"I think +-3" is a bit small for galaxy scale lenses and I think we would need to update it in
workspace accordingly for each package. but +-10" still wont do clusters well so I think a
workspace level task is right. We probabbly need some sort of a sanity check that prints or alerts
the user? and warning based on the extent of the masked data (or the Point dataset)?"

So there is no library default change for the solver extent. Each workspace package sets its own
extent (draft/feature/autolens_workspace/pointsolver_grid_extent_per_package.md, which depends on
this task). The library gets this sanity check, so that a wrong extent is visible to the user.

Goal

Add a one-off, construction-time, non-JAX sanity check where the solver and the data meet.

  1. WARN (risk of missed images) when the observed PointDataset positions, plus a margin, fall
    outside or near the edge of the solver's grid extent. The solver extent is
    y_min / y_max / x_min / x_max. The margin should be tied to the solver's initial scale (one or
    two step-0 triangles) and to the position noise, not a fixed arcsec. An image beyond the grid
    cannot be found, and one within a triangle of the edge may be missed.
  2. INFO / performance hint (softer) when the extent is much larger than the positions need, e.g.
    more than 3× the positions' bounding radius about the lens / positions centre. Quote the phase-4a
    cost: step-0 rows scale with extent², and step 0 is ≈ 66 % of the single-source likelihood.
  3. Fallback for imaging-based point workflows with no PointDataset: use the mask extent.
    Verify first whether this is needed. autolens/analysis/result.py (≈ L117–121 and L187–191)
    already builds its PointSolver from dataset.mask.derive_grid.all_false, so there the solver
    grid is the mask grid. Find any other imaging/interferometer path that pairs a user-built solver
    with masked data before designing a fallback.

Where (verify in code at start_dev)

  • Likely AnalysisPoint.__init__, in PyAutoLens autolens/point/model/analysis.py (≈ L40–105). It
    receives both dataset: PointDataset and solver: PointSolver and stores them. Nothing there is
    traced by JAX.
  • An alternative is the fit setup. Pick the single place a user always passes through before a
    search, and make it fire once per analysis, not per likelihood call.
  • The solver extent lives on AbstractSolver (autolens/point/solver/shape_solver.py ≈ L35–90:
    y_min, y_max, x_min, x_max, scale, pixel_scale_precision). for_grid (≈ L154) derives them from
    the grid.
  • Handle the multi-plane / multi-source case, where one solver serves several PointDatasets (a
    list of analyses), and datasets with fluxes / time delays but no positions (skip).

Conventions (grep before writing)

  • Logging: PyAutoLens uses a module-level logger = logging.getLogger(__name__) everywhere
    (autolens/point/solver/point_solver.py:32, shape_solver.py:30). There is a once-per-process
    logger.warning pattern with a module-global flag at point_solver.py ≈ L132–145 (the
    PYAUTO_SMALL_DATASETS short-circuit warning). warnings.warn is used only in lens/tracer.py and
    interop/coolest.py. Match the logger convention. Decide at start_dev whether the edge case is
    logger.warning and the oversize case logger.info.
  • Silent in test_mode where appropriate. autonerves.test_mode.is_test_mode() is re-exported in
    autolens/__init__.py. Also consider PYAUTO_SMALL_DATASETS=1, where the solve is already
    short-circuited. Workspace smoke runs must not fill with the perf hint.
  • Never touch the JAX path. Use NumPy on the observed positions and the stored floats only. Add
    nothing to solve() or the likelihood, and no jax.debug.

Evidence (phase 4a, RAL job 356367)

Source: lens/autolens_profiling/results/breakdown/point_source_image/solver_config_sweep_hpc_ral_cpu_fp64.json.
Ledger: lens/autolens_profiling/results/notes/point_source_cpu_campaign.md, section "Phase 4a".

  • Extent-only speed-ups at scale 0.2 against the ±9.9″ default: ±6″ 1.52×, ±4″ 1.78×, ±3″ 2.05×,
    ±2.5″ 2.24×. All are complete on 200 prior + 200 stress draws, with log L identical to the default.
    Step-0 rows: 11 859 → 4 428 → 2 075 → 1 197 → 848.
  • The images the workspace prior needs reach max |coord| 1.78″ and radius 1.81″. The broad stress
    set reaches 2.30″ / 2.52″. Real galaxy-scale lenses can go further (larger θ_E, offset centres),
    which is why the human rejected a tight default, and why the warning must key off the user's own
    data
    .

Tests

  • PyAutoLens unit tests: positions inside, near the edge, and outside the grid (warns); a grid more
    than 3× oversized (info); test_mode silence; no JAX import in the check; a multi-dataset case.
  • autolens_workspace_test: one script (or an assertion in point_source/jax_likelihood/image_plane.py)
    shows the check fires on a deliberately small grid and is silent on the default. Its log L pins
    must not move.

Out of scope

Changing any solver default (extent, scale, MAX_CONTAINING_SIZE); cluster solvers (epic
cluster-pointsolver-speed, though the check should behave sensibly there: warn on edge, and the
oversize hint is probably never triggered).

Approved implementation — 2026-10-02

The preceding issued epic member is complete: complete/2026/10/point-source-search-nautilus-leaf.md, inference#17 and profiling#361 merged. Broad timing-noise audit is a separate issue, profiling#362.

Proposed bounded implementation

  1. Add a private NumPy-only diagnostic called once by AnalysisPoint.__init__ in autolens/point/model/analysis.py when a solver and usable observed positions are present. Compare each position with the four stored solver bounds using margin 2 * initial scale + 3 * position sigma. Warn when outside/within that margin; the message must explain that observed-position coverage does not guarantee completeness over the model prior.
  2. Emit a softer INFO hint when both solver half-widths exceed three times the required observed-position envelope about the solver midpoint, including the same margin. Suppress the performance hint in test/small-dataset mode. No solver default or likelihood/JAX path changes. Handle solver=None, absent/empty positions and separate analyses independently.
  3. Add NumPy unit cases in test_autolens/point/model/test_analysis.py: safe, near-edge, outside, asymmetric/offset bounds, noise-scaled margins, oversize hint, absent inputs, test-mode behavior and one diagnostic per construction. Verify the full library suite. Existing autolens/analysis/result.py constructs solvers from the dataset mask grid; no extra masked-data fallback is proposed for those paths.
  4. Add one isolated workspace regression script beside scripts/point_source/jax_likelihood/image_plane.py to capture an undersized-grid warning and verify the established likelihood pin is unchanged, then run targeted point-source smoke. Library first, then workspace companion; keep the original campaign limits.

Survey and guard

Canonical PyAutoLens and autolens_workspace_test are both clean on main. Proposed branch: feature/pointsolver-extent-sanity-check. PyAutoLens is unclaimed. autolens_workspace_test is claimed by critical-curves-dispatch-audit, mesh-interpolator-numerics-audit, fit-util-masked-division and mesh-geometry-transformed-areas. start_workspace conflict guard refuses until the human permits coordinated disjoint work or the claims clear. No issue/worktree/source edits started for this phase.

Approval and coordination

Human: "I approve, continue" (2026-10-02), approving the implementation and coordinated disjoint workspace-test edits. Workspace work is restricted to a new point-source extent regression and its smoke registration/config; preserve other tasks' scripts and registrations. PyAutoLens tests use the existing test_analysis_point.py naming (the draft test_analysis.py path does not exist).

Activity

  1. Jammy2211 commented on Oct 2, 2026

    @Jammy2211
    CollaboratorAuthor

    Implementation progress — 2026-10-02

    Implemented the approved private NumPy construction-time diagnostic in AnalysisPoint and a new focused NumPy test module. Margin: 2 * initial scale + 3 * position sigma; all four bounds and each position's own noise are checked. Both half-widths must exceed three times the padded envelope for the INFO hint. No solver defaults or likelihood/solve paths change.

    • Focused unit tests: 27 passed.
    • Standalone JAX regression: PASS; existing -83.38049778 likelihood pin (rtol 1e-4), JIT/NumPy parity, one construction warning for an undersized grid, no repeat logs across JIT/vmap calls.
    • Full PyAutoLens suite and Heart isolated autolens_test smoke are running.
    • Heart refreshed to YELLOW (85): manifest drift (1 mismatch against repos.yaml), absent release rehearsal for current source. Human acknowledgment requested before PR opening.
    • Companion campaign ledger updates are scoped to wiki/campaigns/point_source_image_plane_cpu.md and results/notes/point_source_cpu_campaign.md, isolated from the critical-curves task.

    Worktree: .worktrees/pointsolver-extent-sanity-check; branch in all three repos: feature/pointsolver-extent-sanity-check.

  2. Jammy2211 commented on Oct 2, 2026

    @Jammy2211
    CollaboratorAuthor

    Validation complete — shipping checkpoint

    The approved construction-time extent diagnostic and companion JAX regression are implemented. No solver defaults or solve/likelihood paths changed.

    Validation Result
    New NumPy extent cases 27 passed
    Full PyAutoLens suite 820 passed, 1 expected failure; 44 warnings; 1413.88 s
    Heart autolens_test smoke All 33 distinct scripts have passing evidence across retained reports
    New extent smoke regression Final PASS in 56.2 s, unchanged 300 s cap

    The script initially missed the required __Env__ heading, causing its full-data guard to fail; corrected without weakening assertions. My concurrent environment preparation with a different Python executable rebuilt Heart's shared cache and caused 21 missing-NumPy failures; those 21 all passed after restoration. The subsequent extent timeout coincided with a host-wide delay (30 s requested wait returned after 428 s; JAX heartbeat jumped 30 → 438 s); its bounded retry passed unchanged. All original reports are retained, and the full smoke list is restored.

    Evidence is under .worktrees/pointsolver-extent-sanity-check: library-tests.log, extent-tests.log, extent-smoke-profile.log, smoke-first-report.json, smoke-recovery-report.json, smoke-rerun-report.json, smoke-combined-summary.json.

    Shipping checkpoint: Heart refreshed to YELLOW (85) with:

    • manifest drift: workspace checkouts (manifest ↔ disk) — 1 mismatch(es) vs PyAutoMind/repos.yaml
    • release validation incomplete: no rehearsal for current source

    The ship skills require human acknowledgment before development PR opening on YELLOW. That acknowledgment is pending; no source commits/PRs yet. Implementation, PR drafts and both campaign ledger updates remain in the isolated task worktrees on feature/pointsolver-extent-sanity-check. On acknowledgment: library PR first, workspace companion with PyAutoLens release gate, and campaign-record companion. No second phase issued.

  3. Jammy2211 commented on Oct 2, 2026

    @Jammy2211
    CollaboratorAuthor

    Shipped for review — 2026-10-02

    Human acknowledged the previously reported Heart YELLOW checkpoint with “prm and continue”. Shipping completed:

    Library and workspace PRs have the pending-release label. Local evidence remains 820 library passes/1 expected failure, 27 focused passes and all 33 distinct workspace scripts passing across the documented recovery reports. Campaign wiki check passes.

    CI judgment: library docs plus Python 3.12/3.13/no-JAX tests are in progress; workspace Python 3.12/3.13 smoke is in progress (changes job passed); profiling lint is in progress. All PRs are mergeable but UNSTABLE while checks run. Nothing merged.

    Per workspace AGENTS.md, the run stops after this judgment; no watcher is armed. Resume /prm when CI finishes, judging every exact-head run/leg and preserving library-first and PyAutoLens release gates. The task stays active; no second phase issued.

  4. Jammy2211 commented on Oct 2, 2026

    @Jammy2211
    CollaboratorAuthor

    prm — partial merge; release checkpoint

    All 8 jobs for the exact PR heads passed: library docs, Python 3.12/3.13/no-JAX; workspace changes and Python 3.12/3.13 smoke; profiling lint. Heart freeze: not frozen.

    Merged:

    • PyAutoLens#764 — 0dd420877e18da8e94cbb3dfb5dbe97ad34eb45c
    • autolens_profiling#363 — 134695058dd16752ddb3d9bad747422ff0173ee5

    Workspace-test#338 stays open and green behind its recorded PyAutoLens release gate. The latest release, 2026.10.2.1 (09:29:37 UTC), predates the library merge (10:41:21 UTC), and no fetched tag contains that merge. The ship-workspace release rule therefore still applies.

    Mind is updated to library-merged, awaiting-release, retaining the pending-release and release-gate links. Issue, prompt, claims and worktrees stay intact until the companion merges; no cleanup or second phase. After a release includes #764, resume /prm for #338 and full close-out. No release or background watcher was started.

  5. Jammy2211 commented on Oct 2, 2026

    @Jammy2211
    CollaboratorAuthor

    PointSolver extent sanity check — complete

    Shipped

    • PyAutoLens#764: 0dd420877e18da8e94cbb3dfb5dbe97ad34eb45c — NumPy-only diagnostic once at AnalysisPoint construction; warning for observed positions near/outside the grid using margin 2 * scale + 3 * position sigma; oversized-grid INFO suppressed in test/small-dataset mode.
    • autolens_workspace_test#338: 5140a56e9f6ee37d65effd82964cec0ab7ac5f7d — construction warning plus unchanged image-plane likelihood pin and repeated JIT/vmap parity; registered in smoke.
    • autolens_profiling#363: 134695058dd16752ddb3d9bad747422ff0173ee5 — campaign page and full ledger.

    Every claimed branch has zero commits ahead of origin/main after merge. No extent, scale, MAX_CONTAINING_SIZE or likelihood-path default changed. Observed-position coverage is explicitly not a proof of image completeness across the model prior. Cluster work remains separate.

    Validation

    27 focused NumPy tests passed; full library suite 820 passed, 1 expected failure. All 33 distinct workspace smoke scripts have passing evidence after the documented environment recovery; final new-script run 56.2 s under the unchanged 300 s cap. All 8 GitHub CI jobs passed across library docs, Python 3.12/3.13/no-JAX tests, workspace changes and Python 3.12/3.13 smoke, and profiling lint.

    The initial local smoke error was a missing Env heading. A concurrent environment rebuild caused 21 missing-package failures, all recovered. One subsequent timeout coincided with a host scheduling/suspension delay; the unchanged script passed its bounded retry. Original reports are retained in the task root.

    Human decisions and release

    Human acknowledged the reported Heart YELLOW development checkpoint through “prm and continue”. Library and campaign PRs merged first. Human subsequently instructed “can you merge and well do release after”, explicitly permitting workspace merge before the library release. The workspace release gate is discharged by that instruction; the library pending-release obligation above remains. No release was started.

    Follow-up and retention

    Next bounded epic member: draft/feature/autolens_workspace/pointsolver_grid_extent_per_package.md, choosing per-package galaxy-scale extents with fresh correctness/performance evidence. No next phase issued in this close-out. The broad timing-noise audit remains autolens_profiling#362.

    Task worktree retained pending the human's cleanup choice: roughly 884 KB of generated smoke datasets and 20 KB of aggregator output, plus validation logs. The earlier inference worktree/data remain preserved under the separate explicit instruction.

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