Repository navigation
refactor: close the run(ctx) framework, new-search template (search-ext A5 PR 4/4) - #1692
Merged
Merged
Conversation
…(search-ext A5 PR 4) - Delete the legacy pool shims of the _fit contract (make_pool, make_sneaky_pool and their one-core decorator check_cores); PoolFactory is the only pool source (SneakyPool stays, via PoolFactory.sneaky). An external search that still overrides _fit keeps working through self._pools(analysis). - Unknown-kwarg guard: warn (never raise) only for keywords no __init__ in the MRO names; use_jax_vmap=None, which SettingsSearch.search_dict hands every search, is no longer reported for searches without it. - autofit/non_linear/search/_template/search.py: a runnable template search whose module docstring states the run(ctx) contract and the six PyAutoFit touch points; test_template_search.py runs both conformance layers on a renamed copy (template_toy_search.ToyHillClimb, 158 lines). - docs/design/run_ctx.md revision 4; FitLifecycle not introduced (D22). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ision 4, no class cache, inline config fixture Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 25, 2026
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 4 of 4 (stacked on PR 3; merge last): close the
run(ctx)framework and ship the new-search template. Closes #1688.execution.py:make_pool,make_sneaky_pooland their one-core decoratorcheck_cores(runtime.py, plus itsabstract_searchre-export).PoolFactoryis now the only pool source;SneakyPoolstays, built only byPoolFactory.sneaky. An external search that still overrides_fit(the developer-tiernss/ultranest/pyswarms) keeps working and reaches the pools throughself._pools(analysis). Nothing in PyAutoFit, PyAutoLens, PyAutoGalaxy, PyAutoCTI, PyAutoArray or the workspaces referenced the shims (grep).NonLinearSearch.__init__is logged as unknown only when no__init__in the search's MRO names it (runtime.warn_unknown_kwargs).SettingsSearch/use_jax_vmap:search_dict_foralready filtered the knob; the remaining gap was**settings_search.search_dict(used by every autolens_workspace SLaM script), which handeduse_jax_vmap=Noneto every search and logged it as unknown. The defaultNoneis now not reported for searches that do not accept it; a set value still is. Decision flagged:search_dictkeeps its key (its shape is tested and consumed); the filter is in the guard.autofit/non_linear/search/_template/search.py— a complete, runnable search (a random-walk hill climber) whose module docstring states therun(ctx)contract and the six PyAutoFit touch points of a new search. Template smoke:test_autofit/non_linear/search/template_toy_search.py(the template renamed — a test asserts the sources match — 158 lines, ≤250) passes both A0a conformance layers through the very same test functions (test_template_search.py, 18 cases: layer (i) construction, family, identifier fields, golden identifier, constructor set,search.jsonround trip, config untouched; layer (ii) reduced test-mode run, output file set, completed-path resume without the backend, NullPaths result, samples fallbacks, restored-output samples,samples_infokey set).docs/design/run_ctx.mdrevision 4.FitLifecycle: not introduced (D22). PRs 1–3 left no lifecycle code duplicated across searches that the mixins cannot host — the chores (Fitness, pools, start points, seed streams, schedule, update, cleanup) all live in the bridge andFitContext, and what remains in eachrunis its backend loop. The residual per-search idioms (Zeus/BFGS's own dill resume, Dynesty's unit-cube start points, MultiStart's_broad_starts) are backend-specific, not shared lifecycle.Witness:
grep -rn "def _fit(" autofit/non_linear/search→ onlyabstract_search.py;grep make_pool|make_sneaky_pool|check_coresover PyAutoFit/PyAutoLens/PyAutoGalaxy/PyAutoCTI/PyAutoArray and the workspaces → no hits.API Changes
Removed the deprecated legacy pool shims of the
_fitcontract (deprecated since A4, no known callers); unknown-kwarg warnings are narrower.See full details below.
Test Plan
unittest-nojaxemulation: 3495 passed, 180 skippedpython docs/_generate_searches.py --check: clean · Sphinx: 30 warningsautofit_workspace_test/scripts/searches/*.py(all 19) atPYAUTO_TEST_MODE=1and=2: 14/19 pass at mode 1 and 13/19 at mode 2 — the identical pass set to main df6d218 (failing on both: BlackJAXNUTS, MultiStartAdam, MultiStartProdigy, MultiStartResumeNaNCounters, MultiStartResurrect, and NSS at mode 2 — script assertions/keys under the reduced test-mode budget, e.g.KeyError: 'n_resurrections',KeyError: 'log_evidence_error'; pre-existing)pyauto-heart smoke autofit autolenson this head: rc 0, 53 PASS, 0 FAILold_outputs.py): outputs written by pre-A2 PyAutoFit (0dbf258) and by A4-era main (df6d218) — 11 completed fits (Emcee, Zeus, DynestyStatic, DynestyDynamic, Nautilus, BFGS, LBFGS, Drawer, MultiStartAdam, BlackJAXNUTS, SMC) and 3 interrupted fits (Emcee mid-HDF, DynestyStatic mid-savestate, Nautilus mid-checkpoint.hdf5) — loaded with this branch:from_directory): all 11 completed outputs + interrupted Emcee/Nautilus load search, samples and summary (sameSearchOutput.ids for both eras); the interrupted DynestyStatic output has nosamples_summaryyet (interrupted before its first update) — identical on a main control run;Full API Changes (for automation & release notes)
Removed
NonLinearSearch.make_pool()— usectx.pool(inrun(ctx)) orself._pools(analysis)()(PoolFactory).NonLinearSearch.make_sneaky_pool(fitness)— usectx.pool.sneaky(fitness)/self._pools(analysis).sneaky(fitness).autofit.non_linear.search.runtime.check_cores(and its re-export fromabstract_search).Added
autofit.non_linear.search._template.search.TemplateSearch— the template (not exported, not registered).autofit.non_linear.search.runtime.warn_unknown_kwargs(search, kwargs, known=()).Changed Behaviour
__init__in the MRO names, anduse_jax_vmap=None.Migration
pool = self.make_sneaky_pool(fitness)in a custom_fitpool = self._pools(fitness.analysis).sneaky(fitness), or move the search ontorun(ctx)and usectx.pool.sneaky(ctx.fitness)(see the template).Companion changes required
None beyond the A5 consumers task (
search_ext_a5_consumers.md), which should point the Brainsampler_pipeline/reference.mdanatomy atsearch/_template/search.py. No caller of the removed shims exists in the workspaces or dependent libraries.Gate evidence note: smoke, workspace and old-output checks ran on 81de70d; the follow-up review-fix commit 9c78451 changes only docstrings, removes the class-keyed
lru_cachefrom_mro_init_parametersand inlines a test fixture — suites, docs check and Sphinx were re-run on the final head.Validation checklist (--auto run — plan was not pre-approved)
/prm), merge last (after PR 3)pyauto-heart smoke autofit autolensrc 0 (53 PASS) + all 19 workspace_test search scripts = main · review: independent Opus reviewer FINDINGS (5, all low) → dispositions: (1) staleSettingsSearch.search_dictdocstring — fixed; (2) NSS missing from the revision-4 list — fixed; (3)lru_cachekeyed on classes keeps dynamic classes alive / stale on__init__swap — fixed (cache removed); (4) the warning now logs from...search.runtime— accepted, nothing filters on the logger name; (5) test used pytest's__wrapped__on a fixture — fixed (inlined) · Heart STALE 85 within launch ack (reasons: "release validation incomplete: no rehearsal for current source")🤖 Generated with Claude Code