Repository navigation
refactor: Emcee, Zeus, BFGS/LBFGS onto run(ctx) (search-ext A5 PR 1/4) - #1689
Merged
Merged
Conversation
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>
7 of 10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Search-extensibility phase A5 (library), PR 1 of 4 (stacked; merge in order): Emcee, Zeus, BFGS and LBFGS move from
_fitontorun(ctx)(the A2 bridge,docs/design/run_ctx.md). Part of #1688.Each search's
_fitoverride is deleted and replaced byrun(ctx):Fitnessis built by the bridge (BFGS addsstore_historythroughfitness_overrides, so its history samples are unchanged);ctx.pool(Emcee'sSneakyPoolthroughPoolFactory.sneaky, Zeus's pool throughctx.pool());ctx.start_points(n), chunk sizes fromctx.schedule.next_budget, mid-run updates throughctx.update;ctx.rngstream 1 — the same streambackend_random_statedrew;PYAUTO_TEST_MODE=1(test_mode_samples=False); that is now a search-side class attribute_start_points_in_test_mode = False, whichctx.start_pointsforwards. Decision flagged: this is a new search-side hook, not aFitContextmember, recorded in the PR 4run_ctx.mdrevision.ctx.paths.save_search_internal/load_search_internal); they declare noresume_state, soctx.updatesaves nothing extra. Decision flagged: not moved onto a declaredresume_statehere, 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_modeonSearchExecutionMixin.)See full details below.
Test Plan
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-nojaxemulation (import-hook plugin): 3466 passed, 180 skippedpython docs/_generate_searches.py --check: cleanhash_list,to_dict, constructor-argument set,__identifier_fields__, MRO) vs main df6d218: byte-identical for all 15seed=1, gaussian_x1,samples.csvon this branch vs a scratch checkout of main df6d218): Emcee IDENTICAL (also withiterations_per_full_update=120, exercisingctx.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}.pyatPYAUTO_TEST_MODE=1and=2: 4/4 pass on both modes, same pass set as mainFull API Changes (for automation & release notes)
Changed Behaviour
Emcee,Zeus,BFGS,LBFGSno longer override_fit;NonLinearSearch._fit(the bridge) drives theirrun(ctx).Added
SearchExecutionMixin._start_points_in_test_mode(private class attribute, defaultTrue;ZeussetsFalse).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)
/prm), PRs merge in stack order 1 → 4autofit_workspace_testsearches Emcee/Zeus/BFGS/LBFGS m1+m2 4/4 = main (pyauto-heart smokeruns 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")🤖 Generated with Claude Code