You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Under release-fidelity validation (PyAutoHeart #27, run 28784914443), Emcee legs crash with ValueError: Probability function returned NaN. Root cause: LogUniformPrior's NumPy log-prior path returns -np.log(value) with no bounds-check, so when Emcee's stretch move proposes an out-of-support value (value <= 0) the log-prior is NaN, which propagates into the summed figure-of-merit and crashes Emcee. UniformPrior has the sibling gap (returns 0.0 unconditionally, not -inf, out-of-support). Both NumPy paths already have a correct JAX counterpart that returns -inf out-of-support — this fixes the NumPy paths to match.
Plan
Fix the producer.LogUniformPrior.log_prior_from_value (and UniformPrior for parity) NumPy path returns -inf outside [lower_limit, upper_limit], mirroring the already-correct JAX branch. Out-of-support log-prior is legitimately -inf (zero probability → Emcee rejects the move) — a correctness fix, not a masking guard.
Do NOT add a defensive NaN-guard on the FoM in fitness.py — that would mask other producers; a NaN FoM from anything else should still fail loudly.
Split/park the non-reproducing autofit_workspace_test/database scripts to a follow-up (per PyAutoFit#1327 precedent).
Detailed implementation plan
Affected Repositories
PyAutoFit (primary)
Branch Survey
Repository
Current Branch
Dirty?
./PyAutoFit
main
clean
Suggested branch:bug/emcee-loguniform-nan
Implementation Steps
Reproduce the NaN crash on clean main: a small Emcee run over a LogUniform-prior model where a walker exits support (or directly LogUniformPrior(...).log_prior_from_value(-1.0) → NaN).
Fix autofit/mapper/prior/log_uniform.py:139-140: replace the unconditional -np.log(value) NumPy branch with a bounds-checked np.where-based form returning -inf outside [lower_limit, upper_limit], matching the JAX branch at lines 141-142; correct the docstring at lines 126-129.
Fix autofit/mapper/prior/uniform.py:167 NumPy path: return -inf out-of-support instead of unconditional 0.0, matching its JAX branch (scalar-safe).
Add tests in test_autofit/mapper/prior/ (+ Emcee integration in test_autofit/non_linear/search/mcmc/test_emcee.py): assert out-of-bounds LogUniformPrior/UniformPrior log-prior is -inf (not NaN/0.0), and a small Emcee run over a LogUniform model with out-of-support proposals completes without ValueError.
Reproduce all 9 bundled scripts from clean output/; keep only reproducing ones in this PR; split non-reproducing database scripts to a parked follow-up.
autofit/non_linear/fitness.py:239-248 — FoM = log_likelihood + Σ log_prior; NaN guard only covers likelihood, not the summed prior (context; deliberately not changed).
Scoped from PyAutoMind/bug/health_fixes/autofit_sampler_database.md to the reproducing Emcee bounded-prior NaN defect. Full prompt:
# Fix Autofit release sampler and database regressions
## Context
Release run `28784914443` failed two @autofit_workspace cookbooks and seven
@autofit_workspace_test scripts. The cookbook failures reproduce on current `main`:
Emcee proposes invalid LogUniform values and raises `ValueError: Probability function
returned NaN`. Database failures include empty aggregators, stale/mismatched scraped
search metadata, and changed likelihood assertions.
Primary library: @PyAutoFit.
## Scripts
- autofit_workspace/scripts/cookbooks/result.py
- autofit_workspace/scripts/cookbooks/samples.py
- autofit_workspace_test/scripts/database/directory/general.py
- autofit_workspace_test/scripts/database/directory/multi_analysis.py
- autofit_workspace_test/scripts/database/scrape/general.py
- autofit_workspace_test/scripts/database/scrape/grid_search.py
- autofit_workspace_test/scripts/database/scrape/multi_analysis.py
- autofit_workspace_test/scripts/database/scrape/sensitivity.py
- autofit_workspace_test/scripts/features/minimal_output.py
Scope note: this issue tracks only the reproducing Emcee bounded-prior NaN library defect. The database/minimal_output scripts are validated from clean output/; any that do not reproduce are split to a parked follow-up (stale-output false positives, per PyAutoFit#1327).
Overview
Under release-fidelity validation (PyAutoHeart #27, run
28784914443), Emcee legs crash withValueError: Probability function returned NaN. Root cause:LogUniformPrior's NumPy log-prior path returns-np.log(value)with no bounds-check, so when Emcee's stretch move proposes an out-of-support value (value <= 0) the log-prior is NaN, which propagates into the summed figure-of-merit and crashes Emcee.UniformPriorhas the sibling gap (returns0.0unconditionally, not-inf, out-of-support). Both NumPy paths already have a correct JAX counterpart that returns-infout-of-support — this fixes the NumPy paths to match.Plan
LogUniformPrior.log_prior_from_value(andUniformPriorfor parity) NumPy path returns-infoutside[lower_limit, upper_limit], mirroring the already-correct JAX branch. Out-of-support log-prior is legitimately-inf(zero probability → Emcee rejects the move) — a correctness fix, not a masking guard.mainfirst, honouring the Pipeline name for meta data should retain own pipeline name if pipelines are added #27 clean-repro discipline; scope only reproducing scripts.fitness.py— that would mask other producers; a NaN FoM from anything else should still fail loudly.autofit_workspace_test/databasescripts to a follow-up (per PyAutoFit#1327 precedent).Detailed implementation plan
Affected Repositories
Branch Survey
Suggested branch:
bug/emcee-loguniform-nanImplementation Steps
main: a small Emcee run over aLogUniform-prior model where a walker exits support (or directlyLogUniformPrior(...).log_prior_from_value(-1.0)→ NaN).autofit/mapper/prior/log_uniform.py:139-140: replace the unconditional-np.log(value)NumPy branch with a bounds-checkednp.where-based form returning-infoutside[lower_limit, upper_limit], matching the JAX branch at lines 141-142; correct the docstring at lines 126-129.autofit/mapper/prior/uniform.py:167NumPy path: return-infout-of-support instead of unconditional0.0, matching its JAX branch (scalar-safe).test_autofit/mapper/prior/(+ Emcee integration intest_autofit/non_linear/search/mcmc/test_emcee.py): assert out-of-boundsLogUniformPrior/UniformPriorlog-prior is-inf(not NaN/0.0), and a small Emcee run over aLogUniformmodel with out-of-support proposals completes withoutValueError.output/; keep only reproducing ones in this PR; split non-reproducingdatabasescripts to a parked follow-up.python -m pytest test_autofit/green; rerun reproducing scripts from clean state.Key Files
autofit/mapper/prior/log_uniform.py— NumPy log-prior missing bounds-check (primary defect, causes the NaN crash).autofit/mapper/prior/uniform.py— sibling NumPy path returns0.0out-of-support (parity fix).autofit/non_linear/fitness.py:239-248— FoM = log_likelihood + Σ log_prior; NaN guard only covers likelihood, not the summed prior (context; deliberately not changed).autofit/non_linear/search/mcmc/emcee/search.py:137-138—fom_is_log_likelihood=False(context).Context / Discipline
health_fixescluster is suspect for stale-cached-output/false positives; the first parked bug (PyAutoFit#1327) did not reproduce. Every script here gets a clean-output/reproduction before it stays in scope.Original Prompt
Click to expand starting prompt
Scoped from
PyAutoMind/bug/health_fixes/autofit_sampler_database.mdto the reproducing Emcee bounded-prior NaN defect. Full prompt:Scope note: this issue tracks only the reproducing Emcee bounded-prior NaN library defect. The
database/minimal_outputscripts are validated from cleanoutput/; any that do not reproduce are split to a parked follow-up (stale-output false positives, per PyAutoFit#1327).Reference: PyAutoHeart #27 (run 28784914443),
health_fixescluster.