Repository navigation
Description
Overview
Every EP factor update is a full autofit non-linear search. On the ep_toy_gaussian hierarchical toy a 1-parameter Dynesty factor search takes 2.45 s, of which only 1.47 s is dynesty and 0.98 s is autofit wrapper overhead: a redundant second run_nested pass (13 %), per-search corner/model-fit/data plots (23 %), instance_from_vector at 57 % of the likelihood callback, and scipy.stats.norm.cdf in truncated-normal message maths. This task cuts those costs (~2x on the toy, ~15-20 min saved per 1000-search N=50 EP repeat) while keeping ordinary non-EP fits behaviour-preserving.
Plan
- Fix Dynesty finished-detection so a converged first pass is recognised (no second
perform_update+ checkpoint restore + no-oprun_nested). - Swap
scipy.stats.norm.cdfforscipy.special.ndtrin the truncated-normal message maths, and makemanage_quick_updatereturn early when quick updates are disabled. - Let EP factor searches skip per-search visuals by default (new config key), drawing before-fit visuals only for the first search of each factor.
- Mapper fast path: frozen-cached prior tuple and instance plan on the model hot path.
- Measure each PR on the toy (run_nested count, per-search wall, parent moments under a seeded harness); full
test_autofitserially each time. - Ship as three PRs from one worktree/issue: PR 1 = steps 1+2 (output-identical, small), PR 2 = step 3 (adds a config key, changes EP default output), PR 3 = step 4 (shared hot path, supervised review).
- Nautilus has the same double-run shape but needs a different fix (
iterations_fromcounts posterior samples, not likelihood calls) — filed as a separate Mind draft, not done here. - Witness correction: the prompt's 1e-6 same-seed moment check is unreachable as written (dynesty gets no rstate; Laplace refine uses global np.random) — the harness seeds both, see detailed plan.
Detailed implementation plan
Affected Repositories
- PyAutoFit (primary, only)
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| ./fit/PyAutoFit | main @ a736840 | clean |
No other active.md claim on PyAutoFit; worktree_check_conflict clean.
Suggested branch: feature/ep-factor-search-overhead
Worktree root: ~/Code/PyAutoLabs-wt/ep-factor-search-overhead/ (created by start_library)
Implementation Steps
PR 1a — Dynesty finished-detection
File: autofit/non_linear/search/nest/dynesty/search/abstract.py, run_search_internal (~413-459). Dynesty stops on its own criterion iff the run consumed no more calls than the maxcall=iterations budget it was handed. Replace the tail:
iterations_after_run = np.sum(search_internal.results.ncall)
if isinstance(self.paths, NullPaths):
return True
if self.maxcall is not None and iterations_after_run >= self.maxcall:
return True # global cap
if iterations > 0 and iterations_after_run - total_iterations <= iterations:
return True # dynesty stopped itself under budget
return total_iterations == iterations_after_run # legacy no-progress criterionDefault iterations_per_full_update: 1e99 → every converged run finishes in one pass; a finite cadence still loops through perform_update. Resume path unchanged. Test mode (maxcall=1) finishes after one pass. Update the docstring.
Tests in test_autofit/non_linear/search/nest/test_dynesty.py: fake sampler → converged first pass finished; chunk-limited (cadence 50, 51+ calls) not finished; global maxcall finished; real dynesty static+dynamic on a 1-param af.ex.Gaussian (nlive 20) wrapping run_nested with a counter → exactly one call and zero during_analysis=True updates; finite-cadence patched fake → 3 runs, 2 intermediate updates.
PR 1b — ndtr swap + quick-update early return
autofit/messages/truncated_normal.py:norm.cdf→scipy.special.ndtrinlog_partition(~60),kl(~350),_normal_gradient_hessian_from(~426); reuse_norm_cdffromautofit/mapper/prior/_erf_helpers.py, bindingndtr/ndtrionce at module level there for the numpy branch. Keeplog(ndtr(b) - ndtr(a))(bit-identical to scipy'snorm._cdf). Do not touchtruncnorm.stats. Testtest_autofit/messages/test_truncated_normal.py::test__ndtr_swap_bit_identicalover a grid of mean/sigma/limits incl. infinite limits vsscipy.stats.norm.autofit/non_linear/fitness.pymanage_quick_update(~652): early return wheniterations_per_quick_update is None or >= 1e90. MoveITERATIONS_NEVERintofitness.pyand re-export fromabstract_search.py(multi_start_gradient/search.pyimports it there). Checktest_quick_update_parameter_types.py:73(quick_update_count == 1) andtest_quick_update_invalid_instance.pystill hold or adjust them deliberately.- Keep the per-search
gc.collect()(abstract_search.py:~684): fix(ep): release each factor search's internals so JAX executables are collectable #1634's release relies on cycle collection.
PR 2 — EP factor searches skip per-search visuals
- Config:
autofit/config/general.yamlunderoutput:addvisualize_ep_factor_searches: false(True → each EP factor search draws its own corner/fit visuals and redraws before-fit visuals; False → only the first search per factor draws before-fit visuals, none draw per-search visuals). autofit/non_linear/search/abstract_search.py: class attrs_visualize_fit = True,_visualize_before_fit = TrueonNonLinearSearch. Inoptimise(~321), beforeself.fit: read the key;_visualize_fit = on,_visualize_before_fit = on or number == 0(number = self.optimisation_counter[factor.name]); reset both infinally.pre_fit_output(~762): gatevisualize_before_fit/_combinedonself._visualize_before_fit._updatersetsself._search_updater.visualization_enabled = self._visualize_fit.autofit/non_linear/search/updater.py:SearchUpdater(visualization_enabled=True);visualize()returns immediately when False. Samples, summary, andEPOptimiser's ownVisualise(graph.png etc.) unchanged.- Tests: new
test_autofit/graphical/test_ep_factor_search_visuals.py(two AnalysisFactors with a recording Visualizer, named DynestyStatic small nlive/maxcall,optimise(..., paths=DirectoryPaths, max_steps=2)): default → zerovisualize/plot_results,visualize_before_fitonce per factor,graph.info/graph.png/ep_historypresent; key True → per-search calls happen. Addtest__visualize__disabled_skips_alltotest_autofit/non_linear/search/test_updater.py. - PR body flag: users lose per-factor
model_fit.pngby default under EP (intended).
PR 3 — Mapper fast path (behaviour-preserving)
Model is frozen for the whole _fit; frozen_cache (autofit/mapper/model.py:30) already invalidates on unfreeze()/__setstate__.
autofit/mapper/prior_model/abstract.pyinstance_from_vector(~990):@frozen_cache _vector_priors()= tuple of priors fromprior_tuples_ordered_by_id; length check,arguments = dict(zip(priors, vector))(JAX-tracer safe).autofit/mapper/prior_model/prior_model.py_instance_for_arguments(~483):@frozen_cache _instance_plan()returning attribute_arguments, tuple-prior / child-model / prior lists, deferred flag, class-type flags and statically-filtered post-construction candidates; keep the per-callhasattr(result, key)check. Unfrozen models fall through unchanged.abstract.pyinstance_for_arguments(~1818): testself._assertionsbefore readingconf.instance["general"]["test"]["exception_override"].- Test: new
test_autofit/mapper/test_instance_from_vector_frozen.pyparametrised overModel(Gaussian), nested Collection, shared priors, tuple priors, deferred argument, Constants, assertions (must raiseFitExceptionidentically); 50 random vectors: frozen vs unfrozen results equal attribute-by-attribute incl. types.
Measurement harness (scratch, not shipped) + witness correction
ep_toy_gaussian copy at N=5, max_steps=3, nlive=100: count run_nested calls, per-search wall, ep_history.csv flags, parent moments. The prompt's "moments within 1e-6 of a same-seed control" is unreachable as written — dynesty never receives an rstate (falls back to OS entropy) and Laplace refine draws from global np.random. The harness seeds np.random per factor search keyed on (factor name, counter) and patches dynesty.dynesty.get_random_generator to a PCG64(np.random.randint(2**32)); with that, before/after moments are compared at 1e-6 for PR 1 and PR 3 (output-identical), and for PR 2 the check is flags + moments within 0.1 σ across 3 seeds. run_nested count must be exactly one per converged search after PR 1.
Verification
- After each PR:
python -m pytest test_autofit/ -p no:xdistserially; PR CI legs 3.12/3.13/nojax + docs green; autofit_workspace smoke. - Harness numbers posted here per PR: run_nested calls (15/15), per-search wall (target ≤ 1.5 s after PR 1+2), moments vs control.
Key Files
autofit/non_linear/search/nest/dynesty/search/abstract.py— finished-detectionautofit/messages/truncated_normal.py,autofit/mapper/prior/_erf_helpers.py— ndtr swapautofit/non_linear/fitness.py—manage_quick_updateearly return,ITERATIONS_NEVERautofit/non_linear/search/abstract_search.py,autofit/non_linear/search/updater.py,autofit/config/general.yaml— EP visuals switchautofit/mapper/prior_model/abstract.py,autofit/mapper/prior_model/prior_model.py,autofit/mapper/model.py— mapper fast path
Original Prompt
Click to expand starting prompt
EP: cut the per-factor-search wrapper overhead (redundant second run_nested pass, per-search plots, instance_from_vector fast path)
Type: refactor
Target: PyAutoFit
Repos:
- PyAutoFit
Themes: - graphical-ep
Difficulty: medium
Autonomy: supervised
Priority: high
Status: formalised
Consequence: judge
Witness: on the ep_toy_gaussian N=5, max_steps=3 toy,run_nestedis called once per Dynesty factor search (15 calls for 15 searches, not 30) and per-search wall drops from ~2.45 s to <= 1.5 s at identical parent moments (mean and sigma within 1e-6 of a control run with the same seeds), with the fulltest_autofitsuite green run serially.
Review-minutes: 5
Unattended: ready
Epic: graphical-ep
Filed: 2026-09-24
Why
Every EP factor update is a full autofit non-linear search. On the
ep_toy_gaussian #1405 collapse toy (PyAutoCortex
projects/ep_toy_gaussian.md) a 1-parameter Dynesty factor search spends
about as much time in the autofit wrapper as in the sampler. A 1000-search
N=50 repeat carries ~15-20 min of pure overhead; best case on the toy is ~2x.
Profile (2026-09-24, laptop, PyAutoFit at the RAL mirror a736840, N=5,
max_steps=3, 15 factor searches, cProfile total 109 s; files in
ep_factor_search_wrapper_overhead_assets/):
- Per search 2.45 s = ~1.47 s dynesty
run_nested+ ~0.98 s autofit wrapper
(plots, a redundant secondrun_nestedpass, samples writes). - Redundant second
run_nestedpass (~5.5 s / 13 %). 30run_nested
calls for 15 searches.run_search_internal
(autofit/non_linear/search/nest/dynesty/search/abstract.py:413-455)
returnsfinished = total_iterations == iterations_after_run, which is
never true on a first pass that converges, so every search does a full
perform_update(during_analysis=True)+ checkpoint restore + a no-op second
run_nested. - Per-search visuals.
corner_anesthetic+model_fit.png7.7 s / 18 %;
data.pngredrawn every search 2.3 s / 5 % although the data never changes. instance_from_vector(autofit/mapper/prior_model/abstract.py:990)
is 57 % offitness.call, i.e. ~25-30 % ofrun_nestedfor a 1-parameter
model:autofit/mapper/model.py:30cache486k calls,
autofit/mapper/prior_model/attribute_pair.pywrapper 481k calls,
prior_model.py:483 _instance_for_arguments2.7 s tottime.truncated_normal.log_partition/klcallscipy.stats.norm.cdf
18.6k times / 3.45 s — usescipy.special.ndtr/log_ndtr.manage_quick_update1.8 s while quick-update is disabled (61k calls).gc.collectper search 75 ms (1.78 s over 15).
What (phases)
- Dynesty finished-detection fix so a converged first pass is recognised
and the secondperform_update+ checkpoint restore +run_nestedis
skipped; unit test that countsrun_nestedcalls (mock the sampler) and
asserts one per converged search. - EP factor searches skip per-search visuals — a config switch, default
off under EP (corner/model_fit per search), anddata.pngdrawn once per
analysis rather than per search. - Mapper fast path for fixed-structure models in
instance_from_vector
(precompute the prior-to-attribute map once per model; bypass the
cache/attribute_pairwrappers on the hot path). ndtrswap inautofit/messages/truncated_normal.py(and
mapper/prior/_erf_helpers.pyif it pays) —scipy.special.ndtr/
log_ndtrin place ofscipy.stats.norm.cdf. Also look at the disabled
manage_quick_updateearly-out and the per-searchgc.collect.
Each phase should be measured on the same toy (per-search wall, run_nested
call count, parent moments against a same-seed control).
Side observation (reproducibility)
Three runs of ep_repeat.py --repeat 0 gave parent means 51.86 / 51.33 /
51.61: the repeat seed does not make EP reproducible at a736840. Known cause
— the Laplace refine draws from global np.random and depends on variable-id
ordering (PyAutoFit#1352). The witness's "same seeds" control therefore needs
the global RNG seeded (or the #1352 fix) before the 1e-6 moment comparison is
meaningful; if it cannot be made deterministic, compare moments across
matched repeats within their spread and say so.
Links
- Campaign ledger:
draft/research/graphical_ep/ep_campaign.md(row 1b; phase 6 epic 2, EP profiling) - Sibling:
draft/refactor/autofit/ep_analysis_level_compile_cache.md(the JAX recompile per factor search) - EMFILE fix that preceded this profile: PyAutoFit#1632 (dynesty single-core no pool), fix(ep): release each factor search's internals so JAX executables are collectable #1634 (release factor search internals)
- Evidence:
ep_factor_search_wrapper_overhead_assets/ep_profile_report.txt,ep_pstats_cumulative.txt,ep_pstats_tottime.txt(paths shortened:SP/= site-packages,PyAutoFit/,STDLIB/,SCRATCH/= the profiling scratch dir)
Activity
Jammy2211 commentedon Sep 24, 2026
PR 1 progress (1a Dynesty finished-detection + 1b ndtr / quick-update early return)
Committed on
feature/ep-factor-search-overhead, not pushed yet:0e2c09748fix(dynesty): recognise a converged first pass as finished16789050aperf(ep): ndtr in truncated-normal message maths; skip disabled quick updatesHarness (ep_toy_gaussian copy, N=5, max_steps=3, nlive=100, rwalk, seeded)
The baseline and the modified runs were interleaved (ABAB) on the same laptop at similar load. Baseline source is
git archive a73684012.run_nestedcalls (15 factor searches)perform_update(during_analysis=True)search.fit, mean)ep_historyflagsThe harness gives the same answer on repeat runs: two baseline runs and two modified runs each agree to 0.0. Per-call
(sum(ncall), logz)is identical in every search. The 1e-6 moment check therefore passes exactly, without reseeding aroundperform_update.Harness determinism: what it took. Seeding numpy and patching dynesty's
get_random_generatorwere not enough on their own. The first search still differed between runs, because autofit'sInitializerPriordraws the initial live points with stdlibrandom(random.random/random.uniforminmapper/prior_model/abstract.pyandnon_linear/initializer.py). The harness now does four things:np.randomandrandomat the start of each factor search, keyed on crc32(factor name, optimisation counter), by hookingNonLinearSearch.optimise.LaplaceOptimiser.optimise, keyed on (factor, call index).dynesty.dynesty.get_random_generator(None)(anddynesty.utils) to returnGenerator(PCG64(np.random.randint(2**32))). Seeded calls pass through unchanged.PYTHONHASHSEED=0as a precaution. I did not test whether this is needed.Dynesty 2.1.5 semantics verified (probe script, 1-D Gaussian, nlive=20)
Sampler.sample(), the per-run counterncall = 0resets on everyrun_nested. It stops only whenncall > maxcall(strictly above), and the check runs at the top of each iteration. Budget-stopped runs: counter 325 at maxcall 300, counter 52 at maxcall 50.sum(results.ncall)grows by at least the counter. The first run addsnliveon top (1641 = 1621 + 20, from initial/added live points, nc=1 each). A resumed chunk adds exactly the counter (309).DynamicNestedSampler.run_nestedcomparesmaxcallagainst its running total. A second run after a budget stop uses 0 calls. This PR does not change that: the finite-cadence dynamic path still ends through the legacy criterion, exactly as before.Criterion shipped (
run_search_internal), checked in order:NullPaths→ finished; globalmaxcallset andsum(ncall) >= maxcall→ finished;iterations > 0andsum(ncall)_after - sum(ncall)_before <= iterations→ finished (dynesty stopped itself under budget); otherwise the legacy check (no new calls) decides. One known conservative case: a converged first chunk at a finite cadence whose counter is ≤ cadence but counter + nlive > cadence gets the old extra no-op pass. The result is the same; there is no behaviour regression.Tests
test_dynesty.pyhas 5 new tests (6 cases, since the real-dynesty test is parametrized over static and dynamic): fake converged / chunk-limited / global maxcall; a finite-cadence_fitloop (3 runs, 2 intermediate updates); real dynesty static and dynamic, each with exactly onerun_nestedand noduring_analysis=Trueupdate. All of them fail on the old code, checked by swapping the file.test__ndtr_swap_bit_identical: 72 grid cases, including infinite limits, with exact equality againstscipy.stats.norm.cdffor_norm_cdf,log_partition,_normal_gradient_hessian_fromandkl.test__disabled_cadence_returns_before_any_bookkeeping(1e99 and 1e100) fails on the old code. No existing test assertedquick_update_count == 1under 1e99, so nothing else had to change.pytest test_autofit -p no:xdist -x): 2881 passed, 2 skipped.Jammy2211 commentedon Sep 24, 2026
PR 2 (EP factor searches skip per-search visuals): committed locally
Commit
1cd4a5b85is onfeature/ep-factor-search-overhead-p2, stacked on PR 116789050a. It is not pushed yet.Change. There is a new config key,
general.yaml -> output -> visualize_ep_factor_searches: false. With the default, EP factor searches no longer runanalysis.visualize/visualize_combined/plot_results, and only the first search of each factor draws before-fit visuals. Samples, summaries and the EP optimiser's owngraph.info/graph.png/ep_history.csvare unchanged. The key is read with.get(..., False), so user configs that predate it keep working. Users lose per-factor model-fit and corner images by default under EP. This is intended; setting the key totruerestores them.Harness (
n5_profile, repeat 0, max_steps 3, nlive 100, seeded). The machine was shared with another session's profiling job (load average ~6), so the PR 1 head was re-run interleaved as a load-matched control. Per-search wall time isoptimise_wall_mean:--keep-output):graph.png,graph_factors.pngandmean_field_evolution.pngare at the EP root. Underdataset_*/optimization_*the only images aredataset_*/optimization_0/image/data.png, the first search's before-fit visual, which the plan keeps. There are no PNGs underoptimization_1/optimization_2and no corner or fit images anywhere.Tests
test_autofit/graphical/test_ep_factor_search_visuals.py, with 3 tests:visualizecalls and 0plot_resultscalls, and callsvisualize_before_fitonce per factor.graph.info,graph.pngandep_history.csvare present.true, every factor search draws per-search visuals.Trueafteroptimise.test_updater.py::test__visualize__disabled_skips_allis added.Jammy2211 commentedon Sep 24, 2026
Library PR Created: PR 1 of 3
PR: #1643 (
pending-release, open and awaiting a human/prm; not merged)0e2c09748fix(dynesty): a converged first pass is now recognised as finished, so a converged search runsrun_nestedonce with no intermediateperform_updateor checkpoint restore.16789050aperf(ep):ndtrin the truncated-normal message maths (bit-identical results); disabled quick updates now return before any bookkeeping.API changes: no public signature changes.
ITERATIONS_NEVERmoved toautofit.non_linear.fitnessand is still re-exported fromabstract_search. The behaviour changes are listed in the PR.Workspace impact: (iii) none. The autofit workspace smoke passed (8/8 scripts, 2/2 notebooks), so no workspace follow-up is needed for PR 1.
Next: a human
/prmon #1643 once CI is green. PR 2 (EP visuals) and PR 3 (mapper fast path) follow under this issue.Heart RED override (development only)
This PR is opened under the
PyAutoBrain/AUTONOMY.md"Human override for Heart RED (development only)". It is a development-shipping override only. It does not claim to fix Heart, and Heart remains RED for release purposes. Merge still needs a separate explicit human/prmwith every required check green.pyauto-heart readiness --json, verdict red, score 45, ts 2026-09-24T15:11:12.973142+00:00):release validation FAILED (stage integrate)workspace validation not passing (4 failed, cloud#35579888156: autolens notebooks/cluster/modeling.ipynb, autolens notebooks/weak/a2744.ipynb, autolens scripts/cluster/modeling.py, +1 more)manifest drift: hub organism blurb (organs present) — 7 mismatch(es) vs PyAutoMind/repos.yamltest_autofit2881 passed / 2 skipped on head 1678905; autofit workspace smoke 8/8 scripts + 2/2 notebooks; PyAutoFit main CI green; downstream workspace impact (iii) none.Jammy2211 commentedon Sep 24, 2026
Library PR Created: PR 2 of 3
PR: #1644 (
pending-release, stacked on #1643 with basefeature/ep-factor-search-overhead; retarget tomainafter #1643 merges; open and awaiting a human/prm; not merged)1cd4a5b85perf(ep): EP factor searches skip per-search visuals by default. New keygeneral.yaml -> output -> visualize_ep_factor_searches: false; only the first search of each factor draws before-fit visuals;SearchUpdater(visualization_enabled)gates per-search visuals.API changes: no incompatible signature changes. Behaviour change: EP factor searches no longer write per-search corner/model-fit images or redraw before-fit visuals after the first search (opt back in with the config key). The NSS live-visual path and ordinary
search.fitare unchanged.SearchUpdatergains avisualization_enabled=Truekeyword.Workspace impact: (iii) none. No hits for the new key or attributes in the workspaces, HowToFit or the array/galaxy/lens libraries.
Next: a human
/prmon #1643, then retarget #1644 tomainand/prmit once CI is green. PR 3 (mapper fast path) is in progress onfeature/ep-factor-search-overhead-p3.Heart RED override (development only)
This PR is opened under the
PyAutoBrain/AUTONOMY.md"Human override for Heart RED (development only)". It is a development-shipping override only. It does not claim to fix Heart, and Heart remains RED for release purposes. Merge still needs a separate explicit human/prmwith every required check green.pyauto-heart readiness --json, verdict red, score 45, ts 2026-09-24T15:11:12.973142+00:00):release validation FAILED (stage integrate)workspace validation not passing (4 failed, cloud#35579888156: autolens notebooks/cluster/modeling.ipynb, autolens notebooks/weak/a2744.ipynb, autolens scripts/cluster/modeling.py, +1 more)manifest drift: hub organism blurb (organs present) — 7 mismatch(es) vs PyAutoMind/repos.yamltest_autofit2885 passed / 2 skipped on head 1cd4a5b; the new EP-visuals tests are red on PR 1 source; EP harness moments bit-identical to PR 1 (evidence: refactor(ep): cut per-factor-search wrapper overhead (dynesty single pass, EP visuals off, mapper fast path) #1642 (comment)); downstream workspace impact (iii) none.Jammy2211 commentedon Sep 24, 2026
PR 3 — Mapper fast path: committed (local, not pushed)
Commit
b3deab4a7onfeature/ep-factor-search-overhead-p3(stacked on PR 2 head1cd4a5b85).AbstractPriorModel._vector_priors(): a@frozen_cachetuple of the id-ordered priors, whichinstance_from_vectorzips with the vector.Model._instance_plan(): a@frozen_cacheof the value-independent structure of_instance_for_arguments, replayed by_instance_for_arguments_frozen.instance_for_argumentschecks the model's own_assertionsbefore reading theexception_overrideconfig.Unfrozen models take the unchanged path. The existing
frozen_cacheis reset onunfreeze()/__setstate__and left out of pickles.Micro-benchmark: 20k frozen
instance_from_vectorcalls, ABAB ×3, mediansaf.Model(af.ex.Gaussian)af.CollectionEP harness:
n5_profile,--max-steps 3 --nlive 100instance_from_vectoris called about 62k times per run, and its cumulative time drops from 5.84 s to 1.31 s. Without the profiler that is about 1 s saved per run, roughly 7% of search time, which is smaller than the noise between wall-clock runs.Tests
test_autofit/mapper/test_instance_from_vector_frozen.py(10 tests): frozen and unfrozen models give identical instances across several model shapes. A deliberate mutation to the code was caught by these tests.test_autofit/mapper+test_autofit/non_linear: 1828 passed, 1 skipped.test_autofit: 2895 passed, 2 skipped.jax.jitandjax.gradthroughinstance_from_vectorwork (gradient is non-zero).Jammy2211 commentedon Sep 24, 2026
Library PR Created: PR 3 of 3
PR: #1645 (
pending-release, stacked on #1644 with basefeature/ep-factor-search-overhead-p2; retarget tomainafter #1644 merges; open and awaiting a human/prm; not merged)b3deab4a7perf(mapper): frozen-cached prior tuple and instance plan on theinstance_from_vectorhot path._vector_priors()andModel._instance_plan()are@frozen_cached and used only for frozen models. The model's own assertions are checked before theexception_overrideconfig is read. Frozeninstance_from_vectoris 5.8× faster forModel(Gaussian)and 4.6× for a 3-GaussianCollection. On the toy harness the EP per-search wall change is within noise (about 1 s per run, roughly 7 %).API changes: none public. Behaviour is preserved: the caches exist only for frozen models, the unfrozen path is unchanged, EP moments are bit-identical to PR 2, and pickle,
jax.jitandjax.gradare verified.Workspace impact: (iii) none. No downstream subclass overrides or calls
_instance_for_arguments/instance_for_arguments/_vector_priors/_instance_plan(PyAutoArray, PyAutoGalaxy, PyAutoLens,autofit_workspace*, HowToFit).Smoke (covers the PR 2 + PR 3 stack):
pyauto-heart smoke autofiton a bundle whosePyAutoFitis the PR 3 head (b3deab4, which contains PR 2's 1cd4a5b): 8/8 scripts and 2/2 notebooks PASS.autofitwas imported from the PR 3 worktree. PR 2's ship did not run the smoke, so this also covers #1644.Next: a human
/prmon #1643, then retarget #1644 tomainand/prmit, then retarget #1645 tomainand/prmit, each once CI is green.Heart RED override (development only)
This PR is opened under the
PyAutoBrain/AUTONOMY.md"Human override for Heart RED (development only)". It is a development-shipping override only. It does not claim to fix Heart, and Heart remains RED for release purposes. Merge still needs a separate explicit human/prmwith every required check green.pyauto-heart readiness --json, verdict red, score 45, ts 2026-09-24T15:11:12.973142+00:00):release validation FAILED (stage integrate)workspace validation not passing (4 failed, cloud#35579888156: autolens notebooks/cluster/modeling.ipynb, autolens notebooks/weak/a2744.ipynb, autolens scripts/cluster/modeling.py, +1 more)manifest drift: hub organism blurb (organs present) — 7 mismatch(es) vs PyAutoMind/repos.yamltest_autofit2895 passed / 2 skipped on head b3deab4; the 10 new frozen-path tests pass, and they caught a deliberate mutation; EP harness moments bit-identical to PR 2 (evidence: refactor(ep): cut per-factor-search wrapper overhead (dynesty single pass, EP visuals off, mapper fast path) #1642 (comment)); autofit workspace smoke on the stacked PR 2 + PR 3 head passed (8/8 scripts, 2/2 notebooks); downstream workspace impact (iii) none.Merge pull request #1643 from PyAutoLabs/feature/ep-factor-search-ove…
Merge pull request #1644 from PyAutoLabs/feature/ep-factor-search-ove…
Merge pull request #1645 from PyAutoLabs/feature/ep-factor-search-ove…
Jammy2211 commentedon Sep 24, 2026
Shipped
All three PRs for this issue were merged into
mainon 2026-09-24. CI was green on every leg. They were merged under the human's Heart RED override, which is recorded on each PR.71c096d46run_nestedpass (no intermediateperform_updateor second pass). The truncated-normal EP maths callsscipy.special.ndtrdirectly, andmanage_quick_updatereturns early when quick updates are disabled.aff2f3686output.visualize_ep_factor_searches: trueingeneral.yamlto turn them back on.dd9fbe0aainstance_from_vector.Outcome on the seeded
ep_toy_gaussianharness (N=5, max_steps=3, nlive=100):run_nestedcalls per EP run fell from 30 to 15.ep_historyflags are identical.The witness was corrected during the task: the harness has to be fully seeded, including stdlib
randomforInitializerPrior, before identical moments can be compared at all.Pending release. These changes are merged but not yet published to PyPI.
Follow-up (left as a Mind draft):
draft/bug/autofit/nautilus_converged_run_double_pass.md.