Skip to content

fix(nautilus): serial bound training + no per-task Fitness pickling (#1547) - #1548

Merged
Jammy2211 merged 2 commits into
mainfrom
feature/nautilus-serial-bound-training
Aug 30, 2026
Merged

Jammy2211 merged 2 commits into
mainfrom
feature/nautilus-serial-bound-training

Conversation

@Jammy2211

@Jammy2211 Jammy2211 commented Aug 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Nautilus bound training now runs serially in the parent (pool=(pool, None)); likelihood evaluation stays on the fork pool. Prevents the permanent Pool.map hang when a worker dies mid-fit (observed on RAL 2026-08-29, three 8-core runs idle for hours; py-spy: main in nautilus/neural.py:96 train → pool.map, workers idle, _repopulate_pool replacement worker).

Second fix: per-task pickling of the Fitness

Since #1439 (e6279c5) replaced pool=<int> with a Pool object for the Py3.14 fork pin, nautilus no longer installs its initialize_worker/likelihood_worker pair and instead maps the bound Fitness.call_wrap directly (sampler.py → pool_l.map(self.likelihood, args)), so multiprocessing pickles the whole analysis — dataset, PSF convolver, sparse operator, adapt images — into every task chunk and each worker unpickles a fresh copy for every likelihood call. Symptoms: worker RSS grows a few MB per call until 8-core RAL jobs hit the 96 GB cgroup limit, and the parent starves the pool serialising it (only ~2.5 of 8 cores busy). The fork pool is now built with nautilus's own initialize_worker(fitness.call_wrap) — inherited by fork, never pickled — and handed over as _LikelihoodWorkerPool, whose map ignores the mapped function and dispatches likelihood_worker, exactly as the int-pool path did before #1439.

API Changes

None (internal pool plumbing; number_of_cores<=1 path unchanged).

Tests

  • test__multi_core_passes_serial_sampler_pool — asserts (pool, None) reaches nautilus.
  • test__single_core_builds_no_pool — unchanged, still passes.
  • test__likelihood_pool_does_not_pickle_fitness — maps a likelihood whose __getstate__ raises through _LikelihoodWorkerPool on a real fork Pool(2) and asserts the results come back, proving the mapped function is ignored and nothing is pickled per task.

Closes #1547

🤖 Generated with Claude Code

https://claude.ai/code/session_01M6Bmv35TPD1rGQ4bzrbZ15

…not hang the fit

nautilus was given the fork pool as `pool=pool`, so it used it for both
likelihood calls and sampler calculations (neural bound training via
`pool.map`). A worker that dies — e.g. a per-job OOM kill on a cluster —
is replaced by multiprocessing.Pool but its task is never re-issued, so
`map` blocks forever. Pass `pool=(pool, None)`: likelihoods stay parallel,
bound training (4 small MLPs) runs in the parent.

Closes #1547

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M6Bmv35TPD1rGQ4bzrbZ15
…ed per task

With a Pool object, nautilus maps the bound Fitness.call_wrap directly, so
multiprocessing pickles the whole analysis (dataset, PSF, sparse operator,
adapt images) into every task chunk and each worker unpickles it per
likelihood call: worker memory grows a few MB per call (8-core RAL runs hit
96 GB) and the parent starves the pool serialising it. Build the fork pool
with nautilus's initialize_worker and hand nautilus a wrapper whose map
dispatches likelihood_worker, as the int-pool path did before #1439.

Refs #1547

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M6Bmv35TPD1rGQ4bzrbZ15
@Jammy2211 Jammy2211 changed the title fix(nautilus): train neural bounds serially so a dead pool worker cannot hang the fit fix(nautilus): serial bound training + no per-task Fitness pickling (#1547) Aug 30, 2026
@Jammy2211
Jammy2211 merged commit e6ff1e6 into main Aug 30, 2026
4 checks passed
@Jammy2211
Jammy2211 deleted the feature/nautilus-serial-bound-training branch August 30, 2026 02:50
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Sep 4, 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(nautilus): train neural bounds serially so a dead pool worker cannot hang the fit

1 participant