Repository navigation
refactor: Dynesty, BlackJAX NUTS, SMC onto run(ctx) (search-ext A5 PR 2/4) - #1690
Merged
Merged
Conversation
… PR 2) DynestyStatic/DynestyDynamic (via AbstractDynesty), BlackJAXNUTS and SMC replace their _fit overrides with run(ctx) on the A2 bridge: the Fitness comes from the bridge (Dynesty's compile override was already resolved through execution_settings), start points from ctx.start_points (Dynesty keeps the search's start_points helper because it needs unit-cube live points without a start-point plot), chunk sizes from ctx.schedule.next_budget and mid-run updates through ctx.update. The bridge runs the JAX REQUIRED gate for NUTS/SMC. dynesty's ForkPool now takes its worker pool from the fit's PoolFactory (ctx.pool(n, initializer=..., initargs=...)), so the JAX fork rule and the context's pool shutdown apply to it; the pool-creation RuntimeError fallback, _sampler_kwargs and the rstate precedence are unchanged. The NUTS/SMC backend_seed (legacy 42, child_seed) is unchanged. Seeded samples.csv byte-identical to main df6d218 for DynestyStatic, DynestyDynamic, BlackJAXNUTS and SMC (also chunked). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
_fork_pool_cls now takes the fit's PoolFactory; the worker-shape test builds one and checks the pool came from it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 2 of 4 (stacked on #1689; merge in order): DynestyStatic, DynestyDynamic (pooled and single-core), BlackJAXNUTS and SMC move from
_fitontorun(ctx). Part of #1688.AbstractDynesty.runreplaces_fit: the bridge builds the sameFitness(Dynesty already resolved it throughexecution_settings),ctx.pool.number_of_cores/ctx.pool.is_jaxreplace the per-fit factory reads, and mid-run updates go throughctx.update(Dynesty's resume state is its nativesavestate.save, so the update's save is a no-op)._sampler_kwargs()and the A4rstateprecedence are untouched.ForkPoolnow takes its workers from the fit'sPoolFactory(ctx.pool(njobs, initializer=..., initargs=...)) instead of callingfork_context().Poolitself, so the JAX fork rule and the context's pool shutdown apply to it andPoolFactoryis the only pool source. TheRuntimeError-on-creation fallback to single core is unchanged. Decision flagged (_fork_pool_clsnow takes the factory).start_pointshelper for its live points: it needs the unit-cube points and no start-point plot, whichctx.start_points(frozen return shape) does not give. Decision flagged.BlackJAXNUTS.run/SMC.run: start points fromctx.start_points, chunk sizes fromctx.schedule, updates throughctx.update; the per-chunk pickle archive (output_search_internal) stays; the JAX REQUIRED gate is the bridge's.backend_seed(legacy 42, gridchild_seed) unchanged.test_fork_context.pybuilds the fork-pinned dynesty pool from aPoolFactory(779f64a).API Changes
None — internal changes only (
_fork_pool_cls(pools)is private).See full details below.
Test Plan
test_fork_context.pycalled_fork_pool_cls()without the factory; fixed in 779f64a, then re-run)unittest-nojaxemulation: 3470 passed, 180 skippedpython docs/_generate_searches.py --check: clean · Sphinx: 30 warnings (baseline 30)hash_list,to_dict, constructor-argument set,__identifier_fields__, MRO) vs main df6d218: byte-identical for all 15seed=1, gaussian_x1,samples.csvvs main df6d218): DynestyStatic IDENTICAL (also withiterations_per_full_update=1000), DynestyDynamic IDENTICAL, BlackJAXNUTS IDENTICAL (also chunked,iterations_per_full_update=40), SMC IDENTICAL. Pooled DynestyStatic (number_of_cores=2) is not reproducible on main itself (two main runs differ); the branch's pooled runs complete through thePoolFactory-built pool.autofit_workspace_test/scripts/searches/{DynestyStatic,DynestyDynamic,Dynesty_jax,BlackJAXNUTS,SMC}.pyatPYAUTO_TEST_MODE=1and=2: 4/5 pass on both modes, the same pass set as main (BlackJAXNUTS.pyfails identically on main: its "unexpected divergences" assertion under the reduced budget)pyauto-heart smoke autofit autolenson this head: rc 0, 53 PASS, 0 FAILFull API Changes (for automation & release notes)
Changed Behaviour
AbstractDynesty,BlackJAXNUTS,SMCno longer override_fit....using poolINFO line per pool (thePoolFactorylog).Changed Signature (private)
autofit.non_linear.search.nest.dynesty.search.abstract._fork_pool_cls()→_fork_pool_cls(pools).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), merge after refactor: Emcee, Zeus, BFGS/LBFGS onto run(ctx) (search-ext A5 PR 1/4) #1689pyauto-heart smoke autofit autolensrc 0 (53 PASS) + workspace_test searches = main · review CLEAN (independent Opus reviewer over PRs 1–3; it also ran a real pooled DynestyStatic fit on this stack and main) · Heart STALE 85 within launch ack (reasons: "release validation incomplete: no rehearsal for current source")🤖 Generated with Claude Code