Skip to content

perf: certified solver phase C1 — uncertified-lane rate on real Nautilus batches #304

Closed

Description

@Jammy2211

Overview

This decides whether the certified solver's batched uncertified-lane guard (phase C2, a four-repo library change) is worth building. It captures real Nautilus proposal batches at the production batch size, n_batch=20 (the source_pix stages in euclid_strong_lens_modeling_pipeline/scripts/full_model.py). It replays them on an A100 in fp64 under library certified + certified_fallback="none" in jit(vmap) to measure the uncertified-lane rate, and runs a matched timing table. There are no library edits. It runs against the library mains, including the unreleased PyAutoArray#567; the release block was overridden by the human on 2026-09-24.

Plan

  • Capture real Nautilus proposal batches at n_batch=20 on the HST fixed-light cell, for Delaunay N=1500 and rectangular.
  • Replay them on an A100 in fp64 under certified+none jit(vmap). Report the uncertified-lane rate overall and by Nautilus phase, plus max passes against the budget of 16.
  • Time a matched table at B=16/20/50/100: PDIP vmap, certified+none vmap, scalar certified+PDIP, scalar PDIP. Every lane must be within 1e-9 of scalar library PDIP.
  • Projected guarded cost = certified+none batch + rate × scalar re-run. Build C2 only if that is at least 15% below the best zero-code option at B=20 and the rate is near zero. The zero-code options are library PDIP vmap, or scalar certified via config opt-in plus use_jax_vmap=False on the pixelized stages.
  • Write a verdict note that includes the vmap policy stated with its batch size, then update the Mind prompts.
Detailed implementation plan

Affected Repositories

  • autolens_profiling (primary, and the only repo edited)

Branch Survey

Repository Current Branch Dirty?
lens/autolens_profiling main untracked dataset/abell_1201/ only

Suggested branch: feature/certified-solver-phase-c1-lane-rate. The claim on autolens_profiling overlaps with point-source-cpu-p3, but the file sets don't overlap, so a parallel-claim is recorded.

Implementation Steps

  1. New scripts/imaging/likelihood_breakdown/nautilus_batch_capture.py.
    • Reuse the fixed_light_trace.py dataset, model and settings builder (the phase-B cell).
    • Run af.Nautilus(n_batch=20, n_live=<pipeline value>) with the library PDIP default, capping n_like_max so the run takes about 1 h on the GPU.
    • A script-level Fitness.call_wrap recorder saves each batch with its call index to results/breakdown/imaging/nautilus_batches_{delaunay,rectangular}.npz, plus a provenance JSON.
  2. Extend fixed_light_trace.py with --lanes captured --batches <npz> [--batch-sample K].
    • Rate pass (untimed): per-lane certified/passes via the existing jax.debug.callback injection (scripts/misc/likelihood_breakdown/library_solver_injection.py:356-400) under --solver certified --fallback off.
    • Timed pass: reuse the phase-B harness and the 1e-9 gate. Don't pin tighter than 1e-9, because of the Delaunay floor.
  3. New submit hpc/batch_gpu/submit_breakdown_imaging_fixed_light_certified_lane_rate_a100_hst_fp64.
    • Array over mesh × {capture, rate, time@B∈{16,20,50,100}}; the replay tasks depend on capture.
    • --export PYAUTO_HPC_BASE=/mnt/ral/jnightin/PyAuto.
    • Static test scripts/misc/test/test_fixed_light_certified_lane_rate_submit.py.
    • Run a laptop CPU witness (small capture + replay) first.
  4. Note results/notes/certified_solver_phase_c1_lane_rate_2026_09.md plus a job provenance JSON.
    • Rate overall and by phase, and max passes.
    • Matched table per B, and memory limits at B=50/100.
    • Projected guarded cost, a "vmap policy with batch size" section, and the verdict.
    • Regenerate the README dashboards (build_readme.py --check).
  5. Mind. The C1 verdict gates draft/feature/autofit/certified_solver_batched_guard_c2.md, which already holds the guard design.

Key Files

  • scripts/imaging/likelihood_breakdown/fixed_light_trace.py: the phase-B cell, which gets the captured-lane mode.
  • scripts/misc/likelihood_breakdown/library_solver_injection.py: extracts per-lane certified flags.
  • hpc/batch_gpu/submit_breakdown_imaging_fixed_light_certified_policy_a100_hst_fp64: the template for the new submit.
  • results/notes/certified_solver_policy_phase_b_2026_09.md: the phase-B baseline.

Original Prompt

Click to expand starting prompt

Certified solver phase C1 — uncertified-lane rate and batched timing on real Nautilus batches

Type: feature
Target: autolens_profiling
Repos:

  • autolens_profiling
    Themes:
  • profiling
  • inversion
  • hpc-gpu
    Difficulty: medium
    Autonomy: supervised
    Priority: normal
    Status: sliced 2026-09-24 — measurement only; release block overridden by the human ("Build it now against main", then "yes meaurement only"): runs against library mains incl. unreleased PyAutoArray#567, no library edits
    Epic: certified-positive-solver
    Phase: C1
    Consequence: judge
    Witness: captured real Nautilus proposal batches at production n_batch=20 (euclid pipeline source_pix stages) for HST Delaunay N=1500 and rectangular; A100 fp64 replay under library certified+fallback none jit(vmap) reporting the uncertified-lane rate (overall and by Nautilus phase) and max passes vs budget 16; matched timing table at B=16/20/50/100 (PDIP vmap, certified+none vmap, scalar certified+PDIP, scalar PDIP) with every lane <= 1e-9 against scalar library PDIP; a verdict note deciding C2 (draft/feature/autofit/certified_solver_batched_guard_c2.md).
    Review-minutes: 20
    Unattended: no
    Filed: 2026-09-24

Scope (sliced 2026-09-24)

Only item 1 (measure) and item 4 (vmap policy stated with batch size) of the original What below.
Items 2-3 (flag + Fitness fallback) moved to C2. Verdict rule: build C2 only if projected guarded
cost (certified+none batch + rate x scalar certified+PDIP re-run) at B=20 is >= 15% below the best
zero-code option (library PDIP vmap; or scalar certified via config opt-in + use_jax_vmap=False on
the pixelized stages), with the rate near zero.

Why

Certified-solver phase B (autolens_profiling#300, PR #302; note
autolens_profiling/results/notes/certified_solver_policy_phase_b_2026_09.md) measured the library
solvers under the production composition jax.jit(jax.vmap(fn)) on an A100. Under vmap the
certified solver's PDIP fallback lax.cond becomes a select, so every lane pays both solvers:
certified+PDIP is slower than library PDIP at every B (B16: 45.6 vs 38.9 ms/lane Delaunay, 38.6 vs
30.7 rectangular). Certified with certified_fallback="none" is the fastest batched row (B16 1.50x
Delaunay / 1.25x rectangular over PDIP vmap) and passed the 1e-9 gate with 0 uncertified lanes, but
with none an uncertified lane silently returns the last active-set iterate.

The policy adopted by the human on 2026-09-24 ("This sounds good, follow the proposed plan.") keeps
library PDIP as the vmap default now and moves to certified+none only once an uncertified-lane guard
exists. This prompt is that guard (policy item 4), plus the measurement that decides whether it is
worth building.

What

  1. Measure first (autolens_profiling). The phase-B lanes were one seeded draw family near the
    fiducial. Measure the uncertified-lane rate (and max passes vs the packaged budget 16) on real
    Nautilus batches: lanes drawn across the prior / from an actual Nautilus run's proposal batches,
    Delaunay and rectangular, at the batch size Nautilus uses in production. At a rate near zero the
    guard is cheap; at a high rate the host-side second pass erodes the gain and the vmap default
    should stay PDIP. Record the verdict before any library work.
  2. Per-lane certified flag (small PyAutoArray / PyAutoGalaxy surface). The vmapped likelihood
    also returns the per-lane certified flag of the positive-only solve (the library already
    exposes it through the stats= out-dict), threaded out through the fit so Fitness can see it
    without changing the scalar return contract.
  3. Cond-free fallback (PyAutoFit). Fitness._vmap (autofit/non_linear/fitness.py) runs the
    batch with certified + fallback none, then re-evaluates only the uncertified lanes through the
    scalar certified+PDIP program (a rare, host-side second pass outside the traced program) and
    splices their values back. Result: certified+none batch cost with PDIP semantics.
  4. State the vmap policy with the batch size (policy item 5): against the scalar certified
    default the best batch wins only at B16 (1.14x / 1.15x), ties at B8 and loses at B4 — the policy
    must name the Nautilus batch size it applies to; small batches stay scalar.

Context

  • Epic: certified-positive-solver. Phase A = PyAutoArray#566 / PyAutoArray#567 (opt-in certified solver).
    Phase B = autolens_profiling#300 (policy grid, A100 array 350588).
  • The scalar default flip (certified + PDIP fallback on jit(fn) only) was retired 2026-09-24 as
    superseded by this phase (complete/2026/09/certified-solver-scalar-default-flip.md): production
    always runs jit(vmap), so this phase is the lever that reaches real fits.
  • Delaunay carries a ~2e-10 run-to-run nondeterminism floor and a ~2.5e-9 cross-composition
    residual (program properties, not solver); do not draw pins tighter than 1e-9 on Delaunay.

Activity

  1. Jammy2211 commented on Sep 24, 2026

    @Jammy2211
    ContributorAuthor

    Progress: code done, A100 jobs submitted (2026-09-24)

    Branch feature/certified-solver-phase-c1-lane-rate, pushed with no PR yet:

    • ae12a71: capture script, --lanes captured replay, A100 submit and tests.
    • f59f84d: regularization freed with production priors, and --stage pix1|pix2 added.
      • pix1 = mass, shear and AdaptSplit free, as in source_pix_1.
      • pix2 = mass fixed, regularization free, as in source_pix_2.
      • Rectangular frees Constant instead, because the cell can't build AdaptSplit.
    • pytest scripts/misc/test/: 834 passed, 5 skipped. ruff, build_readme --check and check_submits --check are clean.

    RAL (worktree /mnt/ral/jnightin/autolens_profiling_wt/certified-solver-phase-c1-lane-rate; libraries are at the local mains, including #567):

    • Capture array 350659 (tasks 0-3).
    • Replay array 350663 (tasks 4-37), which runs after the capture succeeds (afterok:350659).

    Laptop test (CPU, n_batch=4, 60 lanes each, prior and exploration phases only; this proves the code runs and is not the measurement):

    Run Uncertified
    Fixed regularization (round 1), both meshes 0/60
    Free regularization, Delaunay pix1 10/60
    Free regularization, Delaunay pix2 9/60
    Free regularization, rectangular pix1 14/60
    • The uncertified lanes are the weakly regularized ones. Their none values differ from PDIP by up to 3e-4 relative.
    • The timed-pass gate passed on every lane tested.

    Remaining: pull the results, write the verdict note and provenance, apply the verdict rule, then run ship_workspace. B=100 may run out of GPU memory (the PSF cube is about 389 MB per lane).

  2. added 4 commits that reference this issue on Sep 25, 2026
  3. Jammy2211 commented on Sep 25, 2026

    @Jammy2211
    ContributorAuthor

    Shipped to PR — 2026-09-25

    PRs

    Summary

    Phase C1 replayed real af.Nautilus proposal batches (HST fixed-light; Delaunay N=1500 and rectangular 39x39; pix1 and pix2) on an A100 in fp64 (RAL arrays 350659 / 350766 / 350768). The pre-registered own-composition 1e-9 gate FAILED. It is recorded as it came out and was not loosened. The uncertified-lane rate is 1.9–4.9% at B=20 and 0 in the late half of every run. B=50 jit(vmap) returns wrong likelihoods on 44–50/50 lanes, which is filed as PyAutoMind/draft/bug/autoarray/batched_jit_vmap_b50_wrong_log_likelihood_a100.md. B=100 runs out of memory.

    Session Notes

    • The human's decisions from 2026-09-25 are in the note's ## Decisions (human, 2026-09-25) section (results/notes/certified_solver_phase_c1_lane_rate_2026_09.md). C2 proceeds under a pre-registered near-peak nats gate. Rectangular pix1 stays on library PDIP jit(vmap).
    • The PR is awaiting a human /prm merge. This issue stays open until then.

    Heart RED override

    Development-only override per PyAutoBrain/AUTONOMY.md "Human override for Heart RED (development only)". It permits commit, push and opening the PR only. Merge is not authorized.

    Authorization (live human, 2026-09-25). The agent asked:

    "Heart RED override for shipping C1. The RED is release validation FAILED (stage integrate), and the YELLOW reasons are the autolens cluster/weak notebook failures and manifest drift. None of it is from this branch. The PR body is drafted and ready, and on your go I push and open the PR. Merging still waits for green CI and your /prm."

    The human replied, verbatim: "do these:" followed by that item.

    Heart RED reasons at ship time (verbatim): release validation FAILED (stage integrate)

    Branch gates passed (78cd546): build_readme.py --check exit 0; check_submits.py --check 11 contracted, 0 failing; pytest scripts/misc/test/ 834 passed, 5 skipped.

    Merge requires a separate human /prm with all required checks green. Heart remains RED for release purposes. This PR does not fix Heart.

  4. added a commit that references this issue on Sep 25, 2026
  5. Jammy2211 commented on Sep 25, 2026

    @Jammy2211
    ContributorAuthor

    Shipped

    Merged: #309 (merge commit 21875f3, 2026-09-25).

    Phase C1: uncertified-lane rate on real Nautilus batches

    • Captured real Nautilus proposal batches at production n_batch=20 (HST fixed-light, Delaunay N=1500 + rectangular pix1/pix2) on RAL (captures 350659 / 350766, replay 350768) and replayed them on an A100 at fp64 under certified + fallback none jit(vmap).
    • The uncertified-lane rate is 1.9–4.9 % overall and 0 in the late half of the run.
    • The pre-registered 1e-9 own-composition per-lane gate FAILED. That is recorded, and the gate was not loosened. The failing lanes sit 6e4–2.2e5 nats below the peak, plus the uncertified none iterates.
    • B=50 jit(vmap) is silently wrong. Filed as draft/bug/autoarray/batched_jit_vmap_b50_wrong_log_likelihood_a100.md.
    • B=100 runs out of memory at ~74 GiB. This is the pre-registered memory-limit row.
    • Human decisions (2026-09-25): C2 goes ahead with a near-peak gate of Δ=100 nats and a 0.1 nat pin. Rectangular pix1 stays on library PDIP.
    • The PR also re-pinned the xla_attribution log-det anchors to PyAutoArray 5f8a8dee. They had been stale since PyAutoArray#571, and the re-pin makes main's lint green.
    • Write-up: results/notes/certified_solver_phase_c1_lane_rate_2026_09.md.

    Shipped under a recorded development-only Heart RED override (release validation FAILED at stage integrate, not caused by this branch).

    Next: C2, draft/feature/autofit/certified_solver_batched_guard_c2.md.

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