Skip to content

refactor: Emcee, Zeus, BFGS/LBFGS onto run(ctx) (search-ext A5 PR 1/4) - #1689

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

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

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Search-extensibility phase A5 (library), PR 1 of 4 (stacked; merge in order): Emcee, Zeus, BFGS and LBFGS move from _fit onto run(ctx) (the A2 bridge, docs/design/run_ctx.md). Part of #1688.

Each search's _fit override is deleted and replaced by run(ctx):

  • the Fitness is built by the bridge (BFGS adds store_history through fitness_overrides, so its history samples are unchanged);
  • pools come from ctx.pool (Emcee's SneakyPool through PoolFactory.sneaky, Zeus's pool through ctx.pool());
  • start points from ctx.start_points(n), chunk sizes from ctx.schedule.next_budget, mid-run updates through ctx.update;
  • Emcee seeds its backend from ctx.rng stream 1 — the same stream backend_random_state drew;
  • Zeus always drew real start points under PYAUTO_TEST_MODE=1 (test_mode_samples=False); that is now a search-side class attribute _start_points_in_test_mode = False, which ctx.start_points forwards. Decision flagged: this is a new search-side hook, not a FitContext member, recorded in the PR 4 run_ctx.md revision.
  • Zeus and BFGS keep their own dill archive/resume idiom (ctx.paths.save_search_internal / load_search_internal); they declare no resume_state, so ctx.update saves nothing extra. Decision flagged: not moved onto a declared resume_state here, because that would change which file is written when (behaviour-preserving refactor).

API Changes

None — internal changes only. (New private class attribute _start_points_in_test_mode on SearchExecutionMixin.)
See full details below.

Test Plan

  • Full suite, serial (python -m pytest test_autofit -p no:cacheprovider -q): 3783 passed, 1 skipped, 0 xfailed (main baseline 3776/1/0; +7 new bridge tests)
  • unittest-nojax emulation (import-hook plugin): 3466 passed, 180 skipped
  • python docs/_generate_searches.py --check: clean
  • Sphinx: 30 warnings (baseline 30)
  • 15-search invariants dump (identifier, hash_list, to_dict, constructor-argument set, __identifier_fields__, MRO) vs main df6d218: byte-identical for all 15
  • Seeded byte-identity (seed=1, gaussian_x1, samples.csv on this branch vs a scratch checkout of main df6d218): Emcee IDENTICAL (also with iterations_per_full_update=120, exercising ctx.update), BFGS IDENTICAL (also chunked), LBFGS IDENTICAL (also chunked). Zeus: its backend draws from numpy's global state and is not reproducible on main itself (two main runs differ), so the start points and their log posteriors were compared instead: IDENTICAL (20 walkers).
  • autofit_workspace_test/scripts/searches/{Emcee,Zeus,BFGS,LBFGS}.py at PYAUTO_TEST_MODE=1 and =2: 4/4 pass on both modes, same pass set as main
Full API Changes (for automation & release notes)

Changed Behaviour

  • None intended. Emcee, Zeus, BFGS, LBFGS no longer override _fit; NonLinearSearch._fit (the bridge) drives their run(ctx).

Added

  • SearchExecutionMixin._start_points_in_test_mode (private class attribute, default True; Zeus sets False).

Companion changes required

None beyond the A5 consumers task (search_ext_a5_consumers.md). No public symbol changed.

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

  • Effective level: safe (header: supervised, cap: refactor → safe); tier judge — merge stays human (/prm), PRs merge in stack order 1 → 4
  • 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 3783 passed / 1 skipped full serial, nojax 3466 / 180 skipped · smoke: autofit_workspace_test searches Emcee/Zeus/BFGS/LBFGS m1+m2 4/4 = main (pyauto-heart smoke runs on PR 2 and PR 4) · review CLEAN (independent Opus reviewer over PRs 1–3: no findings) · 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

Each search's _fit override is replaced by run(ctx) on the A2 bridge: the
Fitness comes from the bridge (BFGS adds store_history via
fitness_overrides), pools from ctx.pool (Emcee's SneakyPool through
PoolFactory.sneaky), start points from ctx.start_points, chunk sizes from
ctx.schedule.next_budget and mid-run updates through ctx.update. Emcee
seeds its backend from ctx.rng stream 1, the same stream
backend_random_state drew. Zeus keeps drawing real start points under
PYAUTO_TEST_MODE=1 through a new search-side hook
_start_points_in_test_mode, which ctx.start_points forwards as
test_mode_samples.

Seeded samples.csv byte-identical to main df6d218 for Emcee, BFGS and
LBFGS (also chunked); Zeus start points identical (its backend draws from
numpy's global state and is not reproducible on main either).

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
@Jammy2211
Jammy2211 merged commit de577ef into main Oct 15, 2026
5 checks passed
@Jammy2211
Jammy2211 deleted the feature/search-ext-a5-library 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