Repository navigation
fix: warm the likelihood up in the parent before forking workers - #1715
Merged
Merged
Conversation
…utoArray#654) numba is imported lazily since autoarray 2026.8.20.1; when nothing in the parent ran numba, every forked Nautilus worker imported/initialised it at once and >=16 workers segfaulted. Fitness.prepare_for_fork runs the likelihood once on the NumPy path (and imports numba) before any likelihood pool forks: Nautilus, PoolFactory and SneakyPool. The watchdog gets a specific SIGSEGV message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013C7Zd6ibK9J4V8CFEUzrJU
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
Before forking likelihood workers, a search now runs the likelihood once in the parent (
Fitness.prepare_for_fork, NumPy path only). This fixes multi-core Nautilus fits segfaulting with ≥16 workers when nothing in the parent had used numba yet.Root cause (confirmed on RAL): since PyAutoArray 2026.8.20.1,
numba_utildefersimport numbato the first numba call. Imaging parents always run numba before the search (the Overlay/Hilbert source mesh), so workers inherit it. An interferometer setup whose preprocessing and mesh are NumPy-only never touches numba in the parent, so numba's first import and LLVM initialisation happen inside every forked worker at once and they segfault (about 8 survive, 16+ crash).import numbaonlyIt also moves the first numba compile from N workers into one parent call.
Part of PyAutoLabs/PyAutoArray#654 (companion PR there: finufft CPU NUFFT).
API Changes
Fitness.prepare_for_fork()— runs the likelihood once at the prior medians on the NumPy path (no-op for JAX, once per Fitness, non-fatal on failure, not recorded in history / quick-update state), then imports numba as a backstop.fit_multiprocessing,PoolFactory.__call__(Zeus, Dynesty),SneakyPool(Emcee, initializer).See full details below.
Test Plan
pytest test_autofit: full suite green (see ship log)test_prepare_for_fork.py(7 tests) + 3 Nautilus testsFull API Changes (for automation & release notes)
Added
Fitness.prepare_for_fork().PoolFactory.fitnessattribute andPoolFactory.prepare_for_fork(fitness=None).Changed
PoolFactory.__call__andSneakyPool.__init__(processes > 1) warm the fitness up before forking.search/execution.pysetspools.fitnessaftermake_fitness.fit_multiprocessingwarms up before building its pool; watchdog SIGSEGV message.Not covered (follow-up)
analysis/multiprocessing.py(AnalysisPool/AnalysisProcess, summed analyses) forks without a Fitness; could hit the same failure with many numba-backed analyses and no numba in the parent.Migration
Generated by the PyAutoLabs agent workflow.
🤖 Generated with Claude Code
https://claude.ai/code/session_013C7Zd6ibK9J4V8CFEUzrJU