Repository navigation
Description
Overview
PR #1545 shipped the general.test.log_likelihood_ceiling guard enabled at 1.0e+20: a finite log likelihood whose magnitude exceeds the ceiling is mapped to the resample figure of merit, closing the hole where an fp64 Cholesky on a non-positive-definite matrix returns finite garbage (~3e+303) that a nested sampler accepts as its best point and never terminates on.
The threshold is not unit-safe. A log likelihood is -0.5 * chi_squared - 0.5 * noise_normalization, and both terms scale with the noise-map units — chi_squared as noise**-2, noise_normalization linearly in the pixel count. A badly-scaled dataset can therefore produce a legitimate log likelihood above 1e20, and every model would be silently rejected as garbage, leaving the search with nothing but the resample sentinel. The guard reads a bare magnitude in unspecified units, so it cannot tell that case from the one it was built for.
Human decision (2026-08-29): keep the code path, flip the packaged default off. The guard becomes opt-in for the surface that actually needed it — autolens_profiling, where run 341908_5 was diagnosed as a likelihood-overflow flood. Whether real PyAutoLens analyses should run with it on is deferred until the Wave-B harvest produces more results.
Plan
- Flip the packaged default to disabled (
log_likelihood_ceiling: null) in bothautofit/config/general.yamlandtest_autofit/config/general.yaml, with a comment stating the unit argument and that profiling opts in. - Make a missing config key mean disabled, not
1.0e20— a workspace whosegeneral.yamlpre-dates the key must inherit the new default rather than the old one. - Warn once per process, the first time the guard actually fires, on the numpy path; document that the
jax.jit/vmappaths stay silent by construction (a Pythonloggercall cannot run on a traced value) and expose a counter only if it is trivially possible without perturbing the traced code. - Update the docstrings in
fitness.pyandnss/search.pyso they describe an opt-in guard, and update the existing tests: the "default 1e20" expectations become "default disabled", while the enabled-path coverage is kept by setting the ceiling explicitly. - Enable the guard in
autolens_profiling/config/general.yaml(separate PR, config-only) and record the decision in that repo'sresults/notes/inference/DECISIONS.md.
Detailed implementation plan
Affected Repositories
- PyAutoFit (primary)
- autolens_profiling (config + decision note; separate, independent PR)
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| ./PyAutoFit | main | clean |
| ./autolens_profiling | main | clean |
worktree_check_conflict reports PyAutoFit claimed by nautilus-serial-bound-training (awaiting-merge, PR #1548). That branch touches only autofit/non_linear/search/nest/nautilus/search.py and test_autofit/non_linear/search/nest/test_nautilus.py — disjoint from this task's file set — so this task takes its own parallel worktree, recorded as a parallel-claim: on the active.md entry.
Suggested branch: feature/log-likelihood-ceiling-default-off
Implementation Steps
autofit/config/general.yaml—test.log_likelihood_ceiling:becomes blank (null), comment rewritten: disabled by default because the magnitude is unit-dependent; set a float to opt in.test_autofit/config/general.yaml— the same flip, so the unit suite exercises the shipped default.autofit/non_linear/fitness.py- Replace
LOG_LIKELIHOOD_CEILING_DEFAULT = 1.0e20with a disabled default (inf), so theexcept KeyErrorbranch ofget_log_likelihood_ceilingreturns "disabled". - Rewrite
get_log_likelihood_ceiling's docstring: the guard is opt-in, the units argument is the reason, profiling is the surface that enables it. - Add a module-level "already warned" flag and emit a single
logger.warningthe first time the numpy path substitutes the resample value for an over-ceiling likelihood; state in the docstring that the JAX paths cannot warn. Fitness.calldocstring: describe the guard as off unless configured.
- Replace
autofit/non_linear/search/nest/nss/search.py—nss_log_likelihood_fromdocstring updated to match (default now disabled; the ceiling arg is how a caller opts in).- Tests
test_autofit/non_linear/test_fitness_assertions.py—test_fitness_ceiling_defaults_to_the_configured_valueassertsinf; the enabled-path tests setfitness.log_likelihood_ceiling = 1.0e20explicitly; theget_log_likelihood_ceilingparametrisation and the absent-key test assert the disabled default; add coverage for the first-fire warning.test_autofit/non_linear/test_fitness_ceiling_jax.py— set the ceiling explicitly on the enabled-path JAX tests.test_autofit/non_linear/search/nest/nss/test_log_likelihood_ceiling.py—test_nss_closure_defaults_to_the_configured_ceilingbecomes "defaults to disabled".
Key Files
autofit/non_linear/fitness.py—get_log_likelihood_ceiling,Fitness.call,Fitness.__setstate__autofit/non_linear/search/nest/nss/search.py—nss_log_likelihood_fromautofit/config/general.yaml,test_autofit/config/general.yamltest_autofit/non_linear/test_fitness_assertions.py,test_autofit/non_linear/test_fitness_ceiling_jax.py,test_autofit/non_linear/search/nest/nss/test_log_likelihood_ceiling.py
Original Prompt
Click to expand starting prompt
sounds good let me know if you think we need it in actual autolsns analysis once we have more results
Follow-up to PR #1545: the ceiling is not unit-safe (chi-squared and the noise-normalisation term both scale with the noise-map units), so a badly-scaled dataset could legitimately exceed 1e20 and be rejected as invalid. Decision: PyAutoFit ships the guard OFF (log_likelihood_ceiling: null, missing key = disabled), keeps the code path, warns once on first fire on the numpy path; autolens_profiling enables it in its own config citing 341908_5, and records in results/notes/inference/DECISIONS.md that the ceiling is profiling-only by human decision with a reassessment owed for real PyAutoLens analyses after the Wave-B harvest.
Activity
Jammy2211 commentedon Aug 29, 2026
Library PR Created
Both PRs are open. They are independent — the profiling PR only sets a config key, which is inert until PyAutoFit reads it, so neither blocks the other.
f661b75c9dfeafbf1config/general.yamlopt-in at1.0e+20, datedDECISIONS.mdentryAPI-change summary
The guard's default behaviour changes.
general.test.log_likelihood_ceilingnow ships blank, and a config that omits the key is treated as disabled rather than1.0e20(LOG_LIKELIHOOD_CEILING_DEFAULTgoes1.0e20→inf). Fits that were silently rejecting finite log likelihoods above1e20accept them again — pre-#1545 behaviour, unless a config opts in. No symbol removed or renamed, no signature changed.Why the default could not stay on
A log likelihood is
-0.5 * chi_squared - 0.5 * noise_normalization, and both terms scale with the noise-map units (chi_squaredasnoise ** -2,noise_normalizationlinearly in the pixel count). A badly-scaled dataset can exceed any fixed magnitude legitimately, and every model would then be mapped to the resample sentinel — the search would see nothing but rejections and could not fit at all. The guard reads only a magnitude, so it cannot tell that from the fp64-Cholesky garbage it was built for.The warning, and what was deliberately not built
The numpy path warns once per process the first time the guard actually rejects a value, naming the value, the ceiling and the units caveat — a rejection is otherwise indistinguishable from "the model is bad" from inside the search.
The
jax.jit/vmappaths reject silently by construction: the mask is a tracer, so there is no Python-visible moment at which the guard fires. A fire counter for those paths was considered and skipped — incrementing one from traced code needs a host callback or a donated buffer, which perturbs the code being profiled and does not survivevmap/grad, and a counter blind to the traced paths would read0on a jitted run that rejected every sample. Both facts are documented at the call site rather than left for a future reader to rediscover.Downstream impact
No workspace repo carries the key —
grep -rl log_likelihood_ceiling --include=*.yamlacross the workspace matches only PyAutoFit's own two config files. Every workspace therefore inherits the new "missing key = disabled" default, which is the intended outcome. Verified directly: fromautolens_workspace,get_log_likelihood_ceiling()returnsinf; fromautolens_profiling,1e+20, with its siblingtest:keys still merging from PyAutoFit's packaged defaults (the layered override adds a key, it does not replace the block).Verification
pytest test_autofit/— 2375 passed, 3 skippedruff check,ruff format --check(186 files),build_readme.py --check(all dashboards unchanged),check_submits.py --check(55 submits, 0 failing, 89 scanned)Open for the human
workspace validation not passing (0 failed, 1 timeout, cloud#33229145647: autolens_test scripts/multi_dataset/delaunay_mge.py), plus the stalerelease validation incomplete: no rehearsal for current source. Both are unrelated to this change. This run stopped at PR-open; nothing was merged.autolens_profiling/results/notes/inference/DECISIONS.md. The profiling opt-in should not be extended by analogy before then.Jammy2211 commentedon Aug 30, 2026
Shipped
Merged as PR #1550 (dc53a25).
general.test.log_likelihood_ceilingnow defaults to off (blank / missing key = disabled) because χ² and the noise-normalisation term scale with the noise-map units, so an absolute ceiling is not unit-safe; a once-per-process warning fires on the numpy path when the guard rejects a value. autolens_profiling opts in at 1e20 (PR #198, 6fe8f72b8). Reassessment for real PyAutoLens analyses is owed after the Wave-B harvest.