Repository navigation
fix: restore BFGS and LBFGS checkpoint resume #1724
Description
Overview
fix: restore BFGS and LBFGS checkpoint resume
Plan
Load the saved OptimizeResult.x, restore a cumulative iteration count with a legacy nit fallback, persist that count at each checkpoint, and return the saved result when its budget is exhausted. Keep dill persistence and output identifiers unchanged. Add real interrupt/resume tests for BFGS and LBFGS, legacy checkpoints, and exhausted budgets.
Tier: glance — merge mode: human /prm; this session stops at PR-open by explicit agreement.
Detailed implementation plan
Affected repository: PyAutoLabs/PyAutoFit. Files: autofit/non_linear/search/mle/bfgs/search.py; test_autofit/non_linear/search/mle/test_bfgs_resume.py.
Load the saved OptimizeResult.x, restore a cumulative iteration count with a legacy nit fallback, persist that count at each checkpoint, and return the saved result when its budget is exhausted. Keep dill persistence and output identifiers unchanged. Add real interrupt/resume tests for BFGS and LBFGS, legacy checkpoints, and exhausted budgets.
Run focused regression tests and the full PyAutoFit suite; compare failures against main rather than claiming unverified green. No public signature changes planned.
Branch survey: main clean; no existing PyAutoFit claim in current Mind active.md; no open PyAutoFit PRs or matching open issue found. Branch: feature/bfgs-checkpoint-resume. These four separately reviewed tasks are coordinated in one user-authorized group, with isolated worktrees and sequential edits.
Authorization and Heart RED
User request: "Find 4 grouped tasks and do them". After the exact Heart RED reasons were disclosed and development-only authorization requested, the user replied "Yes I authorise". Applies to selecting, implementing and testing these four tasks and opening reviewable PRs; no merge or release. Tests and author diff review will be recorded at PR-open, not claimed in advance.
Published RED reasons:
- install verification FAILED (testpypi; checks F)
- release validation FAILED (stage integrate)
- PyAutoHeart/workflows/Release Integrate: failure
- manifest_drift/checks/workspace checkouts (manifest ↔ disk): red
- Release readiness: release validation FAILED (stage integrate)
- Release readiness: install verification FAILED (testpypi; checks F)
- PyAutoArray/test_autoarray/inversion/inversion/interferometer/test_interferometer.py::test__interferometer_sparse_operator__mapped_reconstructed_data_dict_matc…
- Unit-test timing: 1 test regressions (>3× baseline), 11 slow (>1.5×)
- Release validation: NOT release_ready — v2026.10.25.1.dev83701 profile=release (2026-10-25T07:21:05+00:00)
- validation_report/stages/integrate: fail
- verify_install FAILED: verify_install FAILED
- F: colab gate: finufft (declared by autoarray, absent on Colab, imported)
- Install verification: FAILED (testpypi; F) (2026-10-25T07:42:48.134987+00:00)
- verify_install: red
- PyAutoBrain: red
- PyAutoLens: red
- autolens_profiling: red
- Worktree drift: 1 orphan / 0 missing / 3 dirty
Original prompt
@PyAutoFit BFGS/LBFGS resume reads ["x0"] from the saved scipy result and cannot resume an interrupted run
Type: bug
Target: autofit
Repos:
- PyAutoFit
Difficulty: low
Autonomy: safe
Priority: normal
Status: formalised
Consequence: glance
Witness: an Emcee-style interrupt/resume test for BFGS and LBFGS (run with a smallmaxiter, kill after the first checkpoint, re-run the samesearch.fit) completes withoutKeyErrorand reaches the same optimum as an uninterrupted run; a resume withtotal_iterations >= maxiterleavessearch_internalpopulated soSamplesbuild.
Filed: 2026-10-14
Found by the A5 library worker (PyAutoFit#1689–#1692) and verified identical on main df6d218, so it is not an A5 regression and was deliberately left unchanged there. autofit/non_linear/search/optimize/bfgs/search.py resumes by reading ["x0"] from its dill-saved scipy OptimizeResult, which has no such key, so every resume of an interrupted BFGS/LBFGS run raises KeyError: 'x0'. Separately, when the saved total_iterations already meets maxiter, the resume path skips the optimiser and never sets search_internal, so samples cannot be built. Fix on top of the A5 run(ctx) version of the search (after #1692 merges); keep Zeus/BFGS's own dill save/resume (A5 decision 2) rather than introducing resume_state.
Implementation and validation — 2026-10-25
PR: #1731
Full library suite: 3919 passed, 1 skipped, 1 xfailed (Python 3.12.14). Broader search/conformance/clipper tests: 201 passed. Six new regressions pass for real interrupted BFGS/LBFGS fits, legacy checkpoint counts, and exhausted budgets; all six fail on unchanged main. Author diff review passed. Real scipy fits resume at the saved point and match uninterrupted runs.
Published vitals: organism RED / PyAutoFit scope GREEN. Development-only authorization applies; no merge or release. Awaiting required CI and human review.
Activity
Jammy2211 commentedon Oct 25, 2026
Shipped in #1731, merged after every head CI workflow and job passed. Human Prm authorized merge; the checked head was unchanged. Completion and validation are being recorded in PyAutoMind. Pending release; no release performed.