From 5d8ba3719e734b8b55d6ef55386400eb865ea7f5 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Thu, 26 Nov 2026 13:32:24 +0000 Subject: [PATCH] fix: Emcee and Zeus default to one core until their pooled path is fixed R6 (#1800) made number_of_cores="auto" the default, so default Emcee and Zeus fits ran through their multiprocessing pool, which is broken (Emcee returns log_likelihood=inf and leaves SneakyPool workers running at exit; pooled Zeus gets wrong log probabilities). The default goes back to 1 for these two searches, as for GridSearch; "auto" stays an explicit opt-in. Closes #1802 Co-Authored-By: Claude Opus 5.5 --- autofit/non_linear/search/mcmc/emcee/search.py | 7 ++++--- autofit/non_linear/search/mcmc/zeus/search.py | 7 ++++--- test_autofit/non_linear/search/mcmc/test_emcee.py | 2 +- test_autofit/non_linear/search/mcmc/test_zeus.py | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/autofit/non_linear/search/mcmc/emcee/search.py b/autofit/non_linear/search/mcmc/emcee/search.py index ab4118e33..70dfff8a7 100644 --- a/autofit/non_linear/search/mcmc/emcee/search.py +++ b/autofit/non_linear/search/mcmc/emcee/search.py @@ -75,7 +75,7 @@ def __init__( auto_correlation_settings: Optional[AutoCorrelationsSettings] = None, iterations_per_quick_update: int = None, iterations_per_full_update: int = None, - number_of_cores: Union[int, str] = "auto", + number_of_cores: Union[int, str] = 1, silence: bool = False, session: Optional[sa.orm.Session] = None, **kwargs, @@ -111,8 +111,9 @@ def __init__( Customizes and performs auto correlation calculations performed during and after the search. number_of_cores The number of cores sampling is performed using a Python multiprocessing Pool instance: a whole - number >= 1, or `"auto"` (the default), every core this process may use, resolved when the fit starts - (1 for a JAX analysis). + number >= 1 (default 1), or `"auto"`, every core this process may use, resolved when the fit starts + (1 for a JAX analysis). Emcee stays on one core by default: its pooled path currently returns wrong + log likelihoods and leaves worker processes running at exit, so `"auto"` is opt-in until that is fixed. silence If True, the default print output of the non-linear search is silenced. session diff --git a/autofit/non_linear/search/mcmc/zeus/search.py b/autofit/non_linear/search/mcmc/zeus/search.py index 6dd322e5f..324dc13ba 100644 --- a/autofit/non_linear/search/mcmc/zeus/search.py +++ b/autofit/non_linear/search/mcmc/zeus/search.py @@ -81,7 +81,7 @@ def __init__( auto_correlation_settings: Optional[AutoCorrelationsSettings] = None, iterations_per_quick_update: int = None, iterations_per_full_update: int = None, - number_of_cores: Union[int, str] = "auto", + number_of_cores: Union[int, str] = 1, silence: bool = False, session: Optional[sa.orm.Session] = None, **kwargs @@ -117,8 +117,9 @@ def __init__( Customizes and performs auto correlation calculations performed during and after the search. number_of_cores The number of cores Zeus sampling is performed using a Python multiprocessing Pool instance: a whole - number >= 1, or `"auto"` (the default), every core this process may use, resolved when the fit starts - (1 for a JAX analysis). + number >= 1 (default 1), or `"auto"`, every core this process may use, resolved when the fit starts + (1 for a JAX analysis). Zeus stays on one core by default: its pooled path currently returns wrong + log probabilities (slice-sampler contraction failures), so `"auto"` is opt-in until that is fixed. silence If True, the default print output of the non-linear search is silenced. session diff --git a/test_autofit/non_linear/search/mcmc/test_emcee.py b/test_autofit/non_linear/search/mcmc/test_emcee.py index 93c22f872..e74683a81 100644 --- a/test_autofit/non_linear/search/mcmc/test_emcee.py +++ b/test_autofit/non_linear/search/mcmc/test_emcee.py @@ -41,7 +41,7 @@ def test__explicit_params(): assert search.auto_correlation_settings.check_size == 100 assert search.auto_correlation_settings.required_length == 50 assert search.auto_correlation_settings.change_threshold == 0.01 - assert search.number_of_cores == "auto" + assert search.number_of_cores == 1 def test__log_posteriors_are_aligned_with_the_thinned_chain(monkeypatch): diff --git a/test_autofit/non_linear/search/mcmc/test_zeus.py b/test_autofit/non_linear/search/mcmc/test_zeus.py index f45ef4d69..8b4dac8dd 100644 --- a/test_autofit/non_linear/search/mcmc/test_zeus.py +++ b/test_autofit/non_linear/search/mcmc/test_zeus.py @@ -46,7 +46,7 @@ def test__explicit_params(): assert search.auto_correlation_settings.check_size == 100 assert search.auto_correlation_settings.required_length == 50 assert search.auto_correlation_settings.change_threshold == 0.01 - assert search.number_of_cores == "auto" + assert search.number_of_cores == 1 requires_zeus = pytest.mark.skipif(