Repository navigation
refactor: A4c family bases out of the MRO (deprecated thin subclasses, per-posterior_kind defaults and plotter) - #1687
Merged
Conversation
Jammy2211
force-pushed
the
feature/search-ext-a4-family-bases
branch
from
October 14, 2026 12:51
946835f to
09834b9
Compare
…, POINT) NonLinearSearch.plot_results dispatches on the declared posterior_kind, replacing the family plot_results; the chain/weighted/point defaults (initializer, clipper, auto-correlation settings) are applied by each concrete __init__, never on NonLinearSearch. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…n subclasses Distinct NonLinearSearch subclasses keeping the former defaults and plots; subclassing one warns (FutureWarning via __init_subclass__); removed one release later. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… drops auto_correlation_settings Emcee/Zeus/BlackJAXNUTS apply CHAIN defaults (auto-correlation settings now built at construction, so a run-time PYAUTO_TEST_MODE reaches them), Dynesty/Nautilus/NSS/SMC WEIGHTED (nested samplers still reject InitializerParamBounds), BFGS/LBFGS/MultiStart/ Drawer POINT. Drawer names clipper explicitly so search.json is unchanged. An old SMC search.json carrying auto_correlation_settings still loads. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…kind defaults; repair the auto-correlation xfails Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Re-parenting gave Drawer an explicit `clipper` mid-signature and removed SMC's `auto_correlation_settings` mid-signature, so valid positional calls silently rebound: Drawer(None, None, None, 50, None, 12, 34, True) read full=34, quick=1, silence=False, clipper=12; an old positional SMC call put the AutoCorrelationsSettings in the quick-update slot (TypeError). - Drawer: `clipper` is now the last named argument (after `session`); the serialized argument set (+clipper) and identifier are unchanged. - SMC: the arguments after `inverse_mass_matrix` are keyword-only, behind a deprecated `*legacy_positional` that binds an old positional call to its former slots (auto-correlation settings dropped) with a FutureWarning, and raises a clear TypeError past the old arity. dictable's serialized argument set is unchanged; the conformance golden signature set for SMC records the new `legacy_positional` name. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Jammy2211
force-pushed
the
feature/search-ext-a4-family-bases
branch
from
October 14, 2026 13:10
09834b9 to
4b86167
Compare
This was referenced Oct 14, 2026
Collaborator
Author
|
Companion PRs: PyAutoLabs/PyAutoBrain#522, PyAutoLabs/autofit_workspace_developer#33 |
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 A4c (PR 3 of 3, stacked on #1686, which is stacked on #1685). It applies decision D14:
AbstractMCMC/AbstractNest/AbstractMLEare no longer in any public search's MRO. Their modules still export them as distinct deprecated thin subclasses ofNonLinearSearch. These keep the former defaults and plots, and warn (FutureWarning) via__init_subclass__when subclassed. They will be removed one release later.posterior_kinddefault objects (autofit/non_linear/search/posterior_kind.py:CHAIN,WEIGHTED,POINT). Each concrete__init__applies them;NonLinearSearchnever does.posterior_kind:NonLinearSearch.plot_resultsdispatches on it, replacing the familyplot_results.weightedsearch with evidence and dropsauto_correlation_settings. An oldsearch.jsoncarrying it still loads. The module stays atmcmc/blackjax/smc/.AbstractDynestystays as shared backend code.Closes #1684
What changed, by sub-step
d92529b2a).CHAIN:InitializerBall(0.49, 0.51),AutoCorrelationsSettingsbuilt at construction, the cornerpy corner plot oncepdf_converged,plots_search.mcmc.WEIGHTED:InitializerPrior,nested_initializer_for(still rejectsInitializerParamBoundsfor nested samplers), the anesthetic corner plot,plots_search.nest.POINT:InitializerBall,ClipperNone, the parameter / log-likelihood / figure-of-merit traces,plots_search.mle.plot_resultslives insearch/updates.py. A search with noposterior_kindstill raisesNotImplementedError, as before.0f2f1dbca). Each has the same constructor signature and defaults as before, plus itssamples_cls(SamplesMCMC/SamplesNest) and its kind's plot.deprecated_family.warn_family_subclassemits theFutureWarningand points to the replacement.756713ba7):NonLinearSearchwithsamples_cls = SamplesMCMCandCHAINdefaults.samples_cls = SamplesNest; they, NSS and SMC takeWEIGHTEDdefaults, and Dynesty, Nautilus and NSS still reject bounded initializers.POINTdefaults. BFGS and MultiStart keep"clipper"in__identifier_fields__.946835f2a).test_family_bases.py.test_family_basenow asserts the public searches are not family subclasses and checks theirposterior_kind.test_default_auto_correlation_settings_follow_run_time_test_modeis repaired. Chain defaults are built at construction, so a run-timePYAUTO_TEST_MODEreachescheck_size, and the Emcee stand-in constructor argument in layer (ii) is removed. SMC leaves that test because it is not a chain.Invariants
af.exportsaf.exports and are still importable from their moduleshash_lists and__identifier_fields__byte-identical to PR 2 and therefore to main for default constructions (scripted dump +test_identifier_golden,test_seed.py)search.json, serialized constructor-argument setsautonerves.dictable.get_arguments(cls)andaf.to_dict(cls())are identical to PR 2 for 14 of 15 searches. The exception is SMC, which losesauto_correlation_settingsas the spec requires.test_search_json_round_trippasses for all 15. An old SMCsearch.jsonwithauto_correlation_settingsloads without an unknown-kwarg warning (test_old_smc_search_json_with_auto_correlation_settings_loads)samples_info["class_path"]samples_clspath equals main's (test_samples_class_path_unchanged, all 15)test_nested_samplers_have_no_clipper,test_clipper_forks_mle_identifier,test_drawer_identifier_ignores_clipperpass. The clipper is applied byPOINTin the point searches'__init__onlyNonLinearSearchis anAbstractFactorOptimisertest_search_is_still_a_factor_optimiser)test_deprecated_{mcmc,nest,mle}_keeps_its_defaults). The developer-tier searches import, construct and fit (see Witness)Resultone classWitness
test_subclassing_a_deprecated_family_base_warnscovers all three. Constructing any of the 15 public searches raises noFutureWarning.dictable.py) match PR 2, apart from SMC as above.search.jsonround-trips.samples_info["class_path"]is unchanged for all 15 searches.autofit_workspace_developerthrough the symlink without editing it.autofit_workspace_developer/searches/nss/no longer exists (NSS was promoted into the library), so two external searches remain:pyswarms/{abstract,globe,local}.py(AbstractPySwarms(AbstractMLE)): imports with theFutureWarning, constructs withInitializerBall+ClipperNone, and fits atPYAUTO_TEST_MODE=1(real PySwarms run) and=2.ultranest/search.py(UltraNest(AbstractNest)): imports with theFutureWarning, constructs withInitializerPrior+SamplesNest, and fits atPYAUTO_TEST_MODE=2. At=1the UltraNest backend fails withImportError: numpy.core.multiarray failed to import. This is an environment problem (the installedultranestwheel is built against an older numpy) and fails identically on main 8437a3b.Tests
unittest-nojaxemulation: 3438 passed, 175 skipped._generate_searches.py --check: up to date.pyauto-heart smoke autofit autolens, worktree source, this branch includes PR 2's seed and initializer changes): autofit_workspace 8/8 scripts + 2/2 notebooks pass, and autolens_workspace 41/41 scripts + 2/2 notebooks pass.autofit_workspace_testscripts/searches+scripts/graphical: 25/32 atPYAUTO_TEST_MODE=1, 23/32 at=2. The failing scripts are the same set as on main 8437a3b and PR 1: real-search assertions not meant for test mode.graphical/ep_parity.pyfirst failed at level 1 in this run. The cause was a stale level-2 bypass output left by an earlier run, which loaded as "Fit Already Completed". With its output folder cleared it passes.Decisions taken
Drawernamesclipperexplicitly in its signature. It used to receiveclipperfromAbstractMLE, sosearch.jsonrecorded it. Naming it keeps Drawer's serialized argument set andsearch.jsonidentical. It is not an identifier field, so feat: put the clipper in the search identifier (MLE searches only) #1493 still holds. The conformance goldenconstructor_argumentsfor Drawer gainsclipper, and SMC's losesauto_correlation_settings. These are the only two signature changes.Nonein the signatures (Emcee, Zeus, BlackJAXNUTS) and are built at construction. NUTS keepscheck_for_convergence=False. Values andsearch.jsonare unchanged outside test mode. This is what repairs the run-time test-mode xfail.plots_search.nest. It used to use the cornerpy chain plot gated onpdf_converged.initializerfrom**kwargs. Their signatures never named it; it reachedAbstractNestthrough kwargs. They pass it throughWEIGHTED.nested_initializer_for, soInitializerParamBoundsis still rejected.FutureWarning(visible to end users, like the deprecated JAX knobs) withstacklevel=3.mcmc/nest/mle) remains as the registry's documentation field and the rosterfamily.Companion changes required
Shipped separately by the main session. None of these is required for this PR's tests.
skills/sampler_pipeline/reference.md, lines 129–133. Replace "subclass of the group abstract (AbstractNest/AbstractMCMC/AbstractMLE) … anis_test_modeshort-circuit" with: "subclass ofautofit.NonLinearSearch. Declare the static capabilities (posterior_kind = PosteriorKind.WEIGHTED | CHAIN | POINT,test_mode_budget = {...}, …) and apply that kind's defaults in__init__fromautofit.non_linear.search.posterior_kind(initializer=WEIGHTED.nested_initializer_for(initializer),self.clipper = POINT.clipper_for(clipper),self.auto_correlation_settings = CHAIN.auto_correlation_settings_for(...)). Setsamples_cls. Implementrun(ctx)+raw_samples_from(docs/design/run_ctx.md) rather than_fit. The test-mode reduction comes fromtest_mode_budgetthrough the post-init hook, so do not callapply_test_modein__init__and do not add anis_test_modeshort-circuit. The search-levelseedis inherited; do not add aseedkwarg unless the backend needs it as a static identifier field." Line 136 ("NSSamples(SamplesNest)… when the group abstract does the heavy lifting") should become "… ~25 lines on top ofSamplesNest".autofit_workspace_developer/searches/ultranest/search.py:from autofit.non_linear.search.nest import abstract_nestandclass UltraNest(abstract_nest.AbstractNest)tofrom autofit.non_linear.search.abstract_search import NonLinearSearch,from autofit.non_linear.search.posterior_kind import WEIGHTED,from autofit.non_linear.search import capabilities as capandclass UltraNest(NonLinearSearch).samples_cls = SamplesNestandposterior_kind = cap.PosteriorKind.WEIGHTED(andproduces_evidence = True).initializer=WEIGHTED.nested_initializer_for(kwargs.pop("initializer", None))tosuper().__init__.if is_test_mode(): self.apply_test_mode()tail (:152) and the:157) with a class attributeapply_test_modeoverride (test_mode_budget = {"max_iters": 1, "max_ncalls": 1}. With the current code the reduction runs twice (tail + post-init hook), which is harmless but redundant.autofit_workspace_developer/searches/pyswarms/abstract.py:from autofit.non_linear.search.mle.abstract_mle import AbstractMLE/class AbstractPySwarms(AbstractMLE)toNonLinearSearch+from autofit.non_linear.search.posterior_kind import POINT.posterior_kind = cap.PosteriorKind.POINT.__init__, setself.clipper = POINT.clipper_for(kwargs.pop("clipper", None))(or add an explicitclipper=Noneargument) and passinitializer=POINT.initializer_for(initializer).is_test_mode()/apply_test_mode()tail (:123) and the:297) withapply_test_modeoverride (test_mode_budget = {"iters": 1}.rng=initializer_rng(self)(autofit.non_linear.search.seed) to its directself.initializer.samples_from_model(...)call (~:171) soseed=reproduces its start points, or callself.start_points(...)instead.globe.py/local.pyneed no change.searches/nss/no longer exists, so there is nothing to update there.Adversary review 07 (Codex gpt-6-astra) — enacted
This branch is rebased onto the fixed PR 2 (
175d91a58, which enacts findings 1–3; see #1686). The rebase was clean. Finding 4 is fixed in09834b9c0.Drawer'sclippermid-signature and removed SMC'sauto_correlation_settingsmid-signature, so valid positional calls silently rebound.Drawer(None, None, None, 50, None, 12, 34, True)gives full=12, quick=34, silence=True, clipper=ClipperNone. On the old PR 3 head it gave full=34, quick=1, silence=False, clipper=12. An old positional SMC call withAutoCorrelationsSettingsraisedTypeError: float() argument must be … not 'AutoCorrelationsSettings'.clipperis now the last named argument (aftersession), so main's positional slots bind as before. Its serialized argument set (+clipper) and its identifier are unchanged. SMC: the arguments afterinverse_mass_matrixare keyword-only, behind a deprecated*legacy_positional. An old positional call is bound to its former slots (auto_correlation_settings,iterations_per_quick_update,iterations_per_full_update,number_of_cores,silence,session), drops the auto-correlation settings and emits aFutureWarning. More positionals than the old arity raise a clearTypeError. Keyword construction is unchanged and does not warn.test_drawer_positional_slots_are_unchanged(the review's exact call),test_drawer_clipper_still_accepted_by_keyword_and_serialized,test_smc_old_positional_auto_correlation_slot_binds_as_before,test_smc_too_many_positional_arguments_raise,test_smc_keyword_construction_does_not_warnDocumented change to the conformance golden: SMC's
inspect.signatureparameter set gainslegacy_positional, because the*argsshim is a named parameter. The serialized constructor-argument set (autonerves.dictable.get_arguments, whichsearch.jsonuses) is unchanged: SMC is still −auto_correlation_settingsand Drawer still +clipper, as stated above.Gates on this head (
09834b9c0):unittest-nojaxemulation: 3459 passed, 180 skipped._generate_searches.py --check: up to date.hash_list,to_dictand argument-set dump: identical to the previous PR 3 head. Against main it differs only by the declaredseedadditions, NUTS/SMCseed: 42 → nulland SMC −auto_correlation_settings.autofit_workspace_testgraphical/analytic_gaussian.py(seeded Dynesty joint fit): PARITY: PASS (41/41), both unchanged and with the PR 2 companion edit applied in a scratch copy.🤖 Generated with Claude Code