Repository navigation
fix(ep): never drive a factor search through a multiprocessing pool; fail fast on a dead Nautilus worker (#1608) - #1610
Merged
Conversation
…fail fast on a dead Nautilus worker EP factor searches refuse number_of_cores>1 with a clear SearchException (ruling 2026-09-09; RAL 342351_0 hung 27 h after two forked likelihood workers segfaulted and Pool.map never returned). Parallelism for EP comes from a JAX-vectorised likelihood, never a process pool. _LikelihoodWorkerPool.map now dispatches via map_async and polls; on each poll it compares the pool's live worker PIDs against the construction-time set, so a worker that multiprocessing silently replaced (its in-flight task never re-issued) raises a diagnosable SearchException within seconds instead of hanging every multi-core Nautilus fit to the wall clock. Closes #1608 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FU8EkdahFWmrL6pewkHZR3
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
Expectation propagation never runs a factor search through a Python
multiprocessingpool (human ruling 2026-09-09). RAL job 342351_0, theslope_hierarchy_scaleEP arm, hung 27 h on a 10-core allocation after two forked likelihood workers segfaulted:multiprocessing.Poolreplaced them but never re-issued their in-flight tasks, so thePool.mapinsidenautilus.Sampler.add_samplesblocked to the wall clock and nothing reached stderr.Two fixes, both needed for the issue's witness:
AbstractSearch.optimise(the EP factor-optimiser entry, so it covers every search type) raises aSearchExceptionwhennumber_of_cores > 1, naming the search class, the offending value, and the two fixes: build the factor search withnumber_of_cores=1, or get parallelism from a JAX-vectorised likelihood (Analysis(use_jax=True), which puts Nautilus onfit_x1_cpuwithvectorized=Trueand no pool). A deliberate refusal rather than a silent downgrade:number_of_coresis user intent, and the same search instance is re-entered per factor. One log line per factor step says where parallelism comes from.ParallelEPOptimiser(EP's own opt-in pool across factors) is unchanged apart from a docstring warning._LikelihoodWorkerPool.mapnow dispatches viamap_asyncand polls (LIKELIHOOD_POOL_POLL_INTERVAL, 1 s); on each poll it checks the exit code of every workerProcesscaptured at construction. A replaced worker restores the count but the original stays dead, so the fit raises a diagnosableSearchExceptionnaming the PID and signal within seconds instead of hanging. Holding theProcessobjects (not just PIDs) keeps the exit code readable after the pool's maintenance thread prunes the dead worker from its own list.Phase 2 of #1608 (the science script's
--use_cpu=>use_jax=Falseconflation) lives inslope_hierarchy_scale, not here, and is filed separately in PyAutoMind.API Changes
None — internal changes only. The only user-visible behaviour change is that an EP factor search built with
number_of_cores > 1now raisesSearchExceptioninstead of silently forking a pool;number_of_cores=1and JAX-vectorised paths are unchanged.See full details below.
Test Plan
test_autofit/graphical/test_ep_no_multiprocessing.py(new): EP withDynestyStatic(number_of_cores=2)raisesSearchExceptionwith everyfork_contextname monkeypatched to fail (nothing forks before the guard);number_of_cores=1runs to a result unchanged.test_autofit/non_linear/search/nest/test_nautilus.py(extended): a real forkPool(2)whose worker isSIGKILLed mid-map raises within 5 s with the dead PID and-9in the message (passed 18/18 repeats); a healthy 40-task map returns complete and in order; the Nautilus 1-core fits deadlock under JAX: fork Pool(1) bypasses nautilus's serial-pool guard (release-integrate RED) #1442 / fix(nautilus): serial bound training + no per-task Fitness pickling (#1547) #1548 tests still pass.test_autofit/graphicalserial: 281 passed (279 baseline + 2 new). Run serially: under-n auto17 of these tests fail on untouchedmainfrom a shared on-disk output directory (filed separately in PyAutoMind).test_autofitserial: 2342 passed, 2 skipped.Full API Changes (for automation & release notes)
Changed Behaviour
autofit.non_linear.search.abstract_search.NonLinearSearch.optimise— raisesexc.SearchExceptionwhenself.number_of_cores > 1(EP factor searches never fork a pool). Previously the search's ordinary multiprocessing path ran.autofit.non_linear.search.nest.nautilus.search._LikelihoodWorkerPool.map(private) — dispatches viamap_asyncand polls; raisesexc.SearchExceptionif a construction-time worker has exited, instead of blocking forever.Added
autofit.non_linear.search.nest.nautilus.search.LIKELIHOOD_POOL_POLL_INTERVAL(module constant, 1.0 s) — the watchdog poll interval, read at call time.Migration
af.Nautilus(number_of_cores=8)forked a pool per factor step.number_of_cores=1; for parallelism useAnalysis(use_jax=True).Generated by the PyAutoLabs agent workflow.
Closes #1608
🤖 Generated with Claude Code
https://claude.ai/code/session_01FU8EkdahFWmrL6pewkHZR3
Generated by Claude Code