Repository navigation
Description
Overview
Fitness.call guards NaN and inf log-likelihoods but passes any finite
value straight through, however physically impossible its magnitude. RAL pilot
341908_5 (slam_source_pix_nn, free AdaptSplit on DelaunayNN) was killed by
exactly that hole: a non-positive-definite regularization matrix made the fp64
Cholesky return finite garbage (log_l up to 3e+303), Nautilus accepted it as
the best point, shell_log_l reached ~1e56 and f_live never terminated — the
run was ledgered as "0 calls / thrashes" when it had in fact made 90,000 calls.
This adds a magnitude ceiling to Fitness.call, so any |log_likelihood|
above the ceiling is mapped to resample_figure_of_merit exactly as NaN/inf
already are. Because the guard lives inside call, every consumer inherits it —
numpy, _jit, _vmap, Nautilus n_batch, BlackJAXNUTS. af.NSS bypasses
Fitness.call with its own inline JAX closure, so the same ceiling is applied
there too.
Plan
- Read a static Python float ceiling once in
Fitness.__init__from
conf.instance["general"]["test"]["log_likelihood_ceiling"](default1e20;
null/infdisables the guard). - Add a third
xp.whereafter the existing isnan/isinf wheres inFitness.call
mapping|log_likelihood| > ceilingtoresample_figure_of_merit. Static
float,xp.where, no Pythonif— safe underjax.jit/jax.vmap. - Apply the same ceiling in the
af.NSSinline log-likelihood closure, which
does not route throughFitness.call. - Mirror the new key into the packaged
autofit/config/general.yamltest:
block (and the test config) so downstream workspaces inherit it. - Note in the existing gradient-caveat docstring that the guard is value-only,
like the NaN/inf wheres it sits beside. - Tests over the numpy,
jax.jitandjax.vmappaths plus the NSS closure.
Detailed implementation plan
Work Classification
Library
Affected Repositories
- PyAutoFit (primary)
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| ./PyAutoFit | main | clean |
Suggested branch: feature/fitness-log-likelihood-ceiling
Worktree root: ~/Code/PyAutoLabs-wt/fitness-log-likelihood-ceiling/
Implementation Steps
autofit/non_linear/fitness.py: addget_log_likelihood_ceiling()beside
get_timeout_seconds(), reading
conf.instance["general"]["test"]["log_likelihood_ceiling"]and coercing with
float(...)(PyYAML parses a bare1e20as a string). Missing key →1e20;
null/inf/none→inf(guard disabled, sinceabs(x) > infis never
true).Fitness.__init__:self.log_likelihood_ceiling = get_log_likelihood_ceiling()
— read once, so it is a static Python float by the time any traced code sees it.Fitness.call: after the isinfwhere, add
log_likelihood = self._xp.where(self._xp.abs(log_likelihood) > self.log_likelihood_ceiling, self.resample_figure_of_merit, log_likelihood).
Idempotent against the-inf/-1e99/-1e30sentinels (they re-map to
themselves).autofit/non_linear/search/nest/nss/search.py: hoist
ceiling = get_log_likelihood_ceiling()above the inlinelog_likelihood
closure and add the matchingjnp.whereafter the existing
jnp.where(jnp.isfinite(raw), raw, -1e30).- Config: add
log_likelihood_ceiling: 1.0e+20to thetest:block of
autofit/config/general.yamlandtest_autofit/config/general.yaml. - Docs: extend the value-only caveat paragraph in
Fitness.call's docstring to
cover the ceiling.
Key Files
autofit/non_linear/fitness.py— the guard, the config read, the docstring.autofit/non_linear/search/nest/nss/search.py— the NSS inline closure.autofit/config/general.yaml,test_autofit/config/general.yaml— the key.test_autofit/non_linear/test_fitness_assertions.py— numpy / jit / vmap tests.test_autofit/non_linear/search/nest/test_nss.py(or a new module) — NSS closure test.
Testing
+1e266→resample_figure_of_merit;1e19passes unchanged; ceiling
disabled (inf) lets1e266through.- Same three assertions through
use_jax_jit=Trueanduse_jax_vmap=True. - One NSS test that the inline closure maps an over-ceiling likelihood to the
-1e30sentinel. - Full
pytest test_autofit/.
Original Prompt
Click to expand starting prompt
do the 5 things above listed and make sure we have some SMC runs going soon
Rung 1 of a five-rung overflow-flood wave. Diagnosis (2026-08-29, checkpoint.hdf5
of RAL pilot 341908_5): Adapt* regularization squares the coefficient twice
(λ⁴), the regularization matrix goes non-PD from c≈1e4 under
LogUniform(1e-6, 1e6), fp64 Cholesky returns finite garbage (log_l up to
3e+303), PyAutoFit's Fitness passes any finite value through, and Nautilus
accepts it as the best point → shell_log_l ≈ 1e56, f_live never terminates.
The same pathology explains the knn reference's −480-nat deficit.
Activity
Jammy2211 commentedon Aug 29, 2026
Library PR Created
PR: #1545 (
feature/fitness-log-likelihood-ceiling, labelledpending-release)What landed
Fitness.callgains a thirdxp.whereafter the isnan/isinf pair: a finite|log_likelihood|above the ceiling maps toresample_figure_of_merit. Insidecall, so numpy,_jit,_vmap, Nautilusn_batchand BlackJAXNUTS all inherit it.__init__via the newget_log_likelihood_ceiling(), fromgeneral.test.log_likelihood_ceiling. Default 1e20; blank (null) orinfdisables. Coerced withfloat— PyYAML parses a bare1e20as a string.autofit/config/general.yamland the test config; a workspace config that pre-dates the key inherits the default rather than losing the guard.af.NSS's inline closure (which bypassesFitness.call) moved into a module-levelnss_log_likelihood_fromfactory carrying the same ceiling, with-1e30namedNSS_INVALID_LOG_LIKELIHOOD. One implementation, tested directly rather than via a lookalike.calldocstring's gradient caveat extended: the ceiling is value-only, exactly like the guards beside it.Tests — full suite
2337 passed, 3 skipped. Numpy-path cases intest_fitness_assertions.py(both signs rejected, ~3e4 passes untouched, disabled-by-inf, idempotent against a-1e99resample sentinel, config-reader coercion);jax.jit+jax.vmapcases in the newtest_fitness_ceiling_jax.py(importorskip-gated, values inside float32 range so the magnitude guard is what fires, not an overflow toinf); NSS closure cases in the newtest_log_likelihood_ceiling.py.Workspace impact: none — behavioural backstop, default ~15 orders of magnitude above any real fit, no API migration.
Not merged. Merge and close-out stay with the human (
/prm).Jammy2211 commentedon Aug 29, 2026
Shipped
Merged as PR #1545 (f71b91e).
Fitness.callnow maps finite |log_likelihood| abovegeneral.test.log_likelihood_ceiling(default 1e20; null/inf disables) toresample_figure_of_merit, inside the jit/vmap region so Nautilus n_batch and BlackJAXNUTS inherit it; NSS's closure shares the ceiling vianss_log_likelihood_from. Motivated by RAL 341908_5 (finite log_l up to 3e+303 accepted as best point). Full suite 2337 passed.