Skip to content

fix(ep): never drive a factor search through a multiprocessing pool; fail fast on a dead Nautilus worker (#1608) - #1610

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/ep-no-multiprocessing-pool
Sep 11, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/ep-no-multiprocessing-pool

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Expectation propagation never runs a factor search through a Python multiprocessing pool (human ruling 2026-09-09). RAL job 342351_0, the slope_hierarchy_scale EP arm, hung 27 h on a 10-core allocation after two forked likelihood workers segfaulted: multiprocessing.Pool replaced them but never re-issued their in-flight tasks, so the Pool.map inside nautilus.Sampler.add_samples blocked to the wall clock and nothing reached stderr.

Two fixes, both needed for the issue's witness:

  1. EP refuses a multiprocessing search. AbstractSearch.optimise (the EP factor-optimiser entry, so it covers every search type) raises a SearchException when number_of_cores > 1, naming the search class, the offending value, and the two fixes: build the factor search with number_of_cores=1, or get parallelism from a JAX-vectorised likelihood (Analysis(use_jax=True), which puts Nautilus on fit_x1_cpu with vectorized=True and no pool). A deliberate refusal rather than a silent downgrade: number_of_cores is 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.
  2. Dead-worker watchdog for every multi-core Nautilus fit. fix(nautilus): serial bound training + no per-task Fitness pickling (#1547) #1548 made bound training serial but left likelihood evaluation unguarded. _LikelihoodWorkerPool.map now dispatches via map_async and polls (LIKELIHOOD_POOL_POLL_INTERVAL, 1 s); on each poll it checks the exit code of every worker Process captured at construction. A replaced worker restores the count but the original stays dead, so the fit raises a diagnosable SearchException naming the PID and signal within seconds instead of hanging. Holding the Process objects (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=False conflation) lives in slope_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 > 1 now raises SearchException instead of silently forking a pool; number_of_cores=1 and JAX-vectorised paths are unchanged.
See full details below.

Test Plan

Full API Changes (for automation & release notes)

Changed Behaviour

  • autofit.non_linear.search.abstract_search.NonLinearSearch.optimise — raises exc.SearchException when self.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 via map_async and polls; raises exc.SearchException if 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

  • Before: EP factor searches built with af.Nautilus(number_of_cores=8) forked a pool per factor step.
  • After: build them with number_of_cores=1; for parallelism use Analysis(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

…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
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label Sep 11, 2026 — with Claude
@Jammy2211
Jammy2211 merged commit 915acd5 into main Sep 11, 2026
4 checks passed
@Jammy2211
Jammy2211 deleted the feature/ep-no-multiprocessing-pool branch September 11, 2026 02:22
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(ep): never drive a factor search through a multiprocessing pool; fail fast on a dead Nautilus worker

2 participants