Skip to content

refactor: MultiStart onto run(ctx), split into phases (search-ext A5 PR 3/4) - #1691

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/search-ext-a5-multistart
Oct 15, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/search-ext-a5-multistart

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Search-extensibility phase A5 (library), PR 3 of 4 (stacked on PR 2; merge in order): the four MultiStart searches move onto run(ctx), and the 800-line _fit is split into phases (survey 01 P5). Part of #1688.

AbstractMultiStartGradient.run now orchestrates four methods:

  • _step_functions — the scalar and batched stepped value_and_grad objectives on fitness.objective("scalar", compile=False), with the scaler/bijector/clipper set-up;
  • _restored_state — the step-loop state from an interrupted run's archived search_internal (same exception tuple and fresh-start fallback as before);
  • _fresh_state — the broad starting population (_broad_starts, unchanged, on _seed_for(0));
  • _step_loop — stepping, archiving and updating at every iterations_per_full_update boundary.

The quick-update cadence moves to fitness_overrides, so the bridge builds the identical Fitness. An intermediate boundary updates through ctx.update (which saves the dill resume state); the terminal boundary saves through ctx.checkpointer.save — the same atomic dill write paths.save_search_internal made, with no duplicate write. _seed_for and the A4 grid child_seed semantics are untouched. A resumed run that is already converged returns its stored search_internal, as before.

Decision flagged: the loop state passes between the phases as a dict unpacked into the loop's locals, so the loop body (and its source-level wiring tests) stays verbatim; the tests now read the joined source of the five methods.

API Changes

None — internal changes only.
See full details below.

Test Plan

  • Full suite, serial: 3791 passed, 1 skipped, 0 xfailed
  • unittest-nojax emulation: 3474 passed, 180 skipped
  • python docs/_generate_searches.py --check: clean · Sphinx: 30 warnings
  • 15-search invariants vs main df6d218: byte-identical for all 15
  • Seeded byte-identity (seed=1, gaussian_x1, JAX analysis, n_starts=8, n_steps=100) vs main df6d218: samples.csv IDENTICAL for MultiStartAdam, MultiStartProdigy, MultiStartADABelief, MultiStartLion; the full archived search_internal (22 keys, opt_state excluded) IDENTICAL for Adam and Prodigy, and for Adam with iterations_per_full_update=30 + resurrect=True (exercising ctx.update and the redraws)
  • autofit_workspace_test/scripts/searches/MultiStart{Adam,ADABelief,Lion,Prodigy,ResumeNaNCounters,Resurrect}.py at PYAUTO_TEST_MODE=1 and =2: 2/6 pass on both modes, the same pass set as main (Adam, Prodigy, ResumeNaNCounters, Resurrect fail identically on main df6d218 — script assertions under the reduced test-mode budget, e.g. KeyError: 'n_resurrections'; pre-existing, not touched here)
Full API Changes (for automation & release notes)

Changed Behaviour

  • None intended. AbstractMultiStartGradient no longer overrides _fit; new private methods run, fitness_overrides, _step_functions, _restored_state, _fresh_state, _step_loop.

Companion changes required

None beyond the A5 consumers task. The pre-existing autofit_workspace_test MultiStart/NUTS script failures (identical on main) are not introduced here; worth a separate look.

Validation checklist (--auto run — plan was not pre-approved)

  • Effective level: safe (header: supervised, cap: refactor → safe); tier judge — merge stays human (/prm), merge after PR 2
  • Plan: on the issue (refactor: A5 library — all searches onto run(ctx), delete legacy _fit/pool surface, template (search-extensibility) #1688), unmodified since
  • Gate: tests 3791 / 1 skipped full serial, nojax 3474 / 180 skipped · smoke: workspace_test MultiStart scripts = main (pyauto-heart smoke on PR 2 and PR 4 heads: rc 0, 53 PASS each) · review CLEAN (independent Opus reviewer; it also probed the resumed-and-converged path) · Heart STALE 85 within launch ack (reasons: "release validation incomplete: no rehearsal for current source")
  • Human: plan sound in hindsight?
  • Human: diff matches plan (no scope creep)?
  • Human: merge, amend, or reject — then log the outcome

🤖 Generated with Claude Code

…PR 3)

AbstractMultiStartGradient's 800-line _fit becomes run(ctx) plus four
phases: _step_functions (the scalar/stepped value_and_grad objectives,
scaler/bijector/clipper set-up), _restored_state (the archived
search_internal of an interrupted run), _fresh_state (the broad starting
population) and _step_loop (stepping, archive and update at each
iterations_per_full_update boundary). The quick-update cadence moves to
fitness_overrides, so the bridge builds the same Fitness. An intermediate
boundary updates through ctx.update, which also saves the dill resume
state; the terminal boundary saves through ctx.checkpointer (the same
atomic dill write save_search_internal made). _broad_starts, _seed_for and
the grid child_seed semantics are untouched.

Seeded samples.csv and the full search_internal (22 keys, opt_state
excluded) byte-identical to main df6d218 for all four MultiStart
variants, also with chunked updates and resurrect on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Jammy2211 Jammy2211 added pending-release PR queued for the next release build decision-taken labels Oct 14, 2026
Base automatically changed from feature/search-ext-a5-nest-blackjax to main October 15, 2026 12:21
@Jammy2211
Jammy2211 merged commit d3d4633 into main Oct 15, 2026
5 checks passed
@Jammy2211
Jammy2211 deleted the feature/search-ext-a5-multistart branch October 15, 2026 12:21
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant