Skip to content

research: impact of PyAutoArray#671 gradient defects on the gradient campaign #515

Closed

Description

@Jammy2211

Overview

PyAutoArray#671 found two gradient defects. (a) A border-relocator tie bug: under jit the reverse-mode gradient of the ellipse semi-axis came out 2× / 0.5× whenever the lens sits on the mask's symmetry centre with border relocation on, for any pixelized mesh. It is fixed in PyAutoArray#672, pending release. (b) An evaluation-point artefact: on odd grids at pixelization over-sampling 1, a grid point sits exactly on the Isothermal centre at the prior medians. This task assesses which of the 73 likelihood-lifecycle gradient cells (results/**/gradient.json) these affected and whether any FD verdict flips. Requested by the human, 2026-11-02.

Plan

  • Classify all 73 cells against defects (a) and (b) from each cell's own config. Cells without a pixelized source (MGE, point source, cluster, weak) are unaffected by construction.
  • Measure the affected cells: value_and_grad with PyAutoArray before and after #672. The fix leaves values bit-identical, so the stored FD numbers stay valid and only the autodiff directional derivatives are recomputed and compared. Small cells run locally; big cells go on RAL only with a human go, on a private checkout.
  • Write up a research note (per-cell table, Δg, verdict flips, re-run list) in wiki/research/ and post a summary here.
  • Add a short PyAutoPulse knowledge entry on the symmetric-evaluation-point caveat.
  • Tier: judge. Merge mode: human /prm.
Detailed implementation plan

Affected Repositories

  • autolens_profiling (primary): wiki research note + index link
  • PyAutoPulse: knowledge entry

Branch Survey

Repository Current Branch Dirty?
./lens/autolens_profiling main (0278253) clean
./organs/PyAutoPulse main untracked tmp/ only

Suggested branch: feature/gradient-campaign-impact

Implementation Steps

  1. Classifier (scratch Science/scratch/gradient_campaign_impact_2026-11-02/): per cell, rebuild the dataset, mask, model and instance via the cell's runtime config. Record the mesh, use_border_relocator, centre vs mask origin at the evaluation point, exact ± border ties (max(|y′|) gap), grid parity, pixelization over-sampling, and whether a grid point sits on the mass centre.
  2. A/B: the cell's fused likelihood under PyAutoArray d7b642e2^ vs d7b642e2 (temporary checkouts). Compute directional derivatives along the stored FD directions and compare with the stored fd entries. CPU fp64, constant folding disabled.
  3. RAL leg for cells over 15 GB: a one-off array on a private checkout, partition ral, explicit human go.
  4. wiki/research/gradient_campaign_impact_border_tie.md + wiki/index.md; PyAutoPulse knowledge entry; summary comment; re-run recommendation after #672 is released.

Key Files

  • results/**/gradient.json: stored witness records (point, fd directions, analytic, rel_error)
  • scripts/misc/gradient/harness.py: seeded FD directions
  • scripts/*/*/likelihood_runtime.py: cell construction

Original Prompt

Click to expand starting prompt

Assess how PyAutoArray#671's two gradient defects affected the likelihood-lifecycle / PyAutoPulse gradient campaign verdicts

Type: research
Target: autolens_profiling
Repos:

  • autolens_profiling
    Themes:
  • jax-gradient
    Difficulty: medium
    Autonomy: supervised
    Priority: high
    Status: formalised
    Consequence: judge
    Witness: a table over every campaign gradient.json (v2 standard legs RAL 413791-413830 + p6 fiducial legs) marking each cell affected / unaffected by (a) the border-relocator tie bug and (b) the centre-on-grid Isothermal core, with the reasoning per cell family, plus a re-run list (cells whose fd.status verdict could flip) — posted on autolens_profiling#509 and the Pulse gradient knowledge entry
    Review-minutes: 10
    Unattended: never
    Filed: 2026-11-02

Human request (2026-11-02, during PyAutoArray#671): "when active work on this task is done we need to assess if this issue has impacted the PyAutoPulse gradient campaign in general."

The two defects (record: complete/2026/11/rectangular-gradient-rtu-sparse.md)

  1. Border-relocator tie gradient (library bug, FIXED in PyAutoArray#672, pending release). ellipse_params_via_border_pca_from took b = max(|y'|). A lens centred on the mask's symmetry centre traces the border into exact +/- pairs, so the maximum is an exact tie. JAX's tie-sharing max gradient is unstable under jit reverse mode: the gradient of b came out 2x / 0.5x. Eager mode was correct. Affects every jitted pixelized-source gradient with use_border_relocator=True evaluated with the lens on the mask's symmetry centre (prior medians typically are), for any mesh (rectangular, Delaunay, ...). It produced a 2–5% autodiff-vs-FD error on mass/shear in the repro.
  2. Centre-on-grid Isothermal core (evaluation-point artefact, not a library bug). On odd grids (HST 141x141) at pixelization over-sampling 1, one source-grid point sits exactly at the mass centre at prior medians; the psi softening (1e-8 core) gives d(deflection)/d(centre) ~1e8. This gave |g| ~2e9 on the imaging/rectangular/hst fiducial. The evaluation-point fix belongs to autolens_profiling#509 (p6c).

Questions

  • Which campaign cells were evaluated at a symmetric point (centre at the mask's symmetry centre) with the border relocator on? Their fd verdicts may be wrong, either way.
  • Which odd-grid instruments at os_pix=1 were evaluated with the centre on a grid point?
  • Do the Delaunay "no_plateau" / mismatch verdicts (Science/scratch/delaunay_hilbert_2026-11-01/README.md) change once PyAutoArray#672 is in the RAL checkout?
  • Re-run plan: which cells, which library pin (#672 needs a release or a private RAL checkout per [[RALpullMains]]).

Activity

  1. Jammy2211 commented on Nov 2, 2026

    @Jammy2211
    ContributorAuthor

    Result: no campaign verdict was affected by PyAutoArray#671

    PRs: #516 (research note) and PyAutoLabs/PyAutoPulse#89 (knowledge page). Tier judge, so human /prm.

    • Every pixelized campaign cell is --standard-size and is evaluated at iid draw 0 of the seeded production sequence (imaging mass centre (0.00085, −0.00035)″). It sits neither on the mask's symmetry centre nor on a grid point, so neither defect can trigger.
    • The cells really evaluated at the medians aren't pixelized. The imaging MGE cells also hold the mass fixed.
    • Before/after control: interferometer/rectangular/sma gives a bit-identical gradient with PyAutoArray before and after #672 (largest relative change 2.4e-16), and it reproduces the stored record.
    • Smallest-step check across all 73 cells: most pixelized cells' stored autodiff matches the stored h=1e-8 FD to ≲1e-3.

    Remaining disagreements, none from #671:

    • FD noise on small gradients (interferometer rectangular and the sma cells).
    • An unexplained CPU-sparse vs GPU-dense gap in four Delaunay cells.
    • An unexplained 0.1–0.4 % imaging-MGE gap, and 70 % in one direction for interferometer/mge/sma.
    • Image-plane cells give exactly zero gradients (known).

    Side finding: every standard driver except group/multi-galaxy records "point": "prior_medians" while evaluating at iid draw 0. Filed as a follow-up in PyAutoMind, together with the unexplained gradient gaps.

  2. Jammy2211 commented on Nov 2, 2026

    @Jammy2211
    ContributorAuthor

    Shipped

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