Repository navigation
Description
Overview
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(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. - Reproduce on clean
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. - 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/databasescripts 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 aLogUniform-prior model where a walker exits support (or directlyLogUniformPrior(...).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-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. - Fix
autofit/mapper/prior/uniform.py:167NumPy path: return-infout-of-support instead of unconditional0.0, matching its JAX branch (scalar-safe). - Add tests in
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. - Reproduce all 9 bundled scripts from clean
output/; keep only reproducing ones in this PR; split non-reproducingdatabasescripts to a parked follow-up. - Validate:
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
- The whole Pipeline name for meta data should retain own pipeline name if pipelines are added #27
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.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).
Reference: PyAutoHeart #27 (run 28784914443), health_fixes cluster.
Activity
Jammy2211 commentedon Jul 8, 2026
🔧 Library PR created —
feature/emcee-loguniform-nanPR: #1329 (
pending-release)Root cause (reproduced A/B on clean
main): Emcee's stretch move proposes physical values that can go non-positive for aLogUniform-priored parameter.LogUniformPrior.log_prior_from_valuecomputed-np.log(value)on the NumPy path →NaNforvalue <= 0, which propagated into the summed figure-of-merit (fom = log_likelihood + Σ log_prior,fitness.py) and crashed the search withValueError: Probability function returned NaN.log_prior_from_value(-1.0)→nan; real emcee run → CRASH (ValueError: Probability function returned NaNatlog_uniform.py:140).value <= 0→-inf; real emcee run (same seed) → completes.Fix (minimal scope): NumPy path returns
-infforvalue <= 0via the double-where pattern (nologof a non-positive value → noRuntimeWarning). Positive values are unchanged — the NumPy path stays unnormalised/unbounded (-log(value)), preserving its documented, tested contract.UniformPriorand the JAX path are untouched.Validation:
test_autofit/{mapper,non_linear,messages}→ 918 passed, 13 skipped + 250 prior tests.test__log_prior_from_value__non_positive_returns_neg_inf.autofit_workspace_testprior parity gatespriors_xp_dispatch.py,emcee_gaussian_bias_check.py) exercise only positive/in-bounds values → both pass unchanged.Still open — separate follow-up: the 7
autofit_workspace_test/database+minimal_output.pyscripts from this cluster remain unvalidated; they show the classic stale-output/signature (empty aggregators, mismatched scraped metadata) and are parked for a clean-output/reproduction pass, consistent with PyAutoFit#1327. This PR fixes only the reproducing Emcee-NaN library defect; the twoautofit_workspace/cookbookslegs that failed on that crash should pass once released.Jammy2211 commentedon Jul 8, 2026
✅ Shipped — #1329 merged to
main(0f26ff2d8). The LogUniform NumPylog_prior_from_valueNaN-on-value<=0crash is fixed. Remaining #27autofit_sampler_databasedatabase/minimal_output scripts stay parked for a separate clean-output/reproduction pass (stale-output suspects, per #1327).