fix: skip corner_cornerpy on a weight-degenerate sample (ESS guard) - #1542
Merged
Conversation
…r guard Nautilus.apply_test_mode set n_like_max = 1, so under PYAUTO_TEST_MODE=1 the search stopped after its initial batch with exactly one non-zero weight (ESS = 1). Since 8cdcff3 correctly forwards weights= and caller kwargs to corner, a caller range=0.999 became a weighted quantile over that single point and collapsed to a sliver excluding every row, so corner raised "'range' is not valid or the sample is empty" (autofit_workspace scripts/plot/nautilus_plotter.py under the release profile). The data was fine (100 unique rows); the weights were degenerate, and the corner guard counted rows, not effective samples. - Nautilus.apply_test_mode: n_live=25, n_batch=25, n_networks=0, f_live=0.5, n_eff=25, n_like_max=1000 — a coarse but real posterior (measured 825-1000 calls, ESS 29-104, 11 s on nautilus_plotter.py; autolens imaging/modeling.py runtime unchanged, 60.5 s vs 60.5 s interleaved). _fit clamps n_live >= prior_count + 5 in test mode, since nautilus rejects n_live <= n_dim and apply_test_mode runs before the model is known. - Dynesty.apply_test_mode: maxcall=150, nlive/nlive_init=25 instead of maxcall=1. Dynesty's ESS only lifts at ~4000 calls, so this is a real reduced run but not a real posterior; documented, the corner guard covers it. - corner_cornerpy: skip via the existing logged path when the Kish ESS (sum(w)^2 / sum(w^2)) <= parameter count, alongside the row-count check. No try/except, kwargs forwarding unchanged. Closes #1541 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KeLmyZD5aG6BrTTdJzSmDv
The human decided against raising the global PYAUTO_TEST_MODE=1 sampler budget: apply_test_mode runs for every Nautilus/Dynesty search under the release profile, so ~900 extra likelihood evaluations per search would slow every release-wave script, not just the plotter. Nautilus n_like_max=1 and Dynesty maxcall=1 are restored. The workspace script instead opts out of test mode (ENV: real_search) and caps the search with an explicit n_like_max, like other workspace examples. The corner_cornerpy effective-sample-size guard stays: a weight-degenerate sample now takes the logged skip path instead of crashing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KeLmyZD5aG6BrTTdJzSmDv
5 tasks
Collaborator
Author
|
Workspace PR: PyAutoLabs/autofit_workspace#150 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
autofit_workspace/scripts/plot/nautilus_plotter.pyfailed under PyAutoHeart's release profile (PYAUTO_TEST_MODE=1) with corner'sValueError: ... 'range' is not valid or the sample is empty. Under test modeNautilusstops after its initial batch with exactly one non-zero weight (ESS = 1); since8cdcff3a0correctly forwardsweights=and caller kwargs to corner, the script'srange=0.999became a weighted quantile over that single point and collapsed to a sliver excluding every row. The samples were fine (100 unique rows); the weights were degenerate, andcorner_cornerpy's guard counted rows, not effective samples.This PR adds the missing protection:
corner_cornerpyskips through the existinglogger.infopath when the Kish effective sample sizesum(w)²/sum(w²)is ≤ the parameter count, alongside the row-count check. No try/except; kwargs forwarding unchanged.A first revision also raised the global test-mode sampler budget; that was reverted on the human's decision (it would slow every release-wave search). The workspace script instead opts out of test mode via
ENV: real_searchand caps the search with an explicitn_like_max— companion PR on autofit_workspace (see comment).Corrective PR for the Heart RED reason
release validation FAILED (stage integrate)— jobintegrate / run_scripts (3.12, autofit, plot), run 33177898708.Side-finding for a separate prompt: the Mind prompt's premise that this "passed under smoke" was wrong —
plot/scripts are not inautofit_workspace/smoke_tests.txt, so smoke never runs them.API Changes
corner_cornerpynow skips (logged, returns None) on a weight-degenerate sample instead of raising. No signatures change; test-mode sampler behaviour unchanged.See full details below.
Test Plan
pytest test_autofitgreentest_samples_plotters.py: ESS helper; weight-degenerate 100×3 with callerrange=np.ones(3)*0.999→ logged skip,corner.cornernot called; uniform weights → calledautofit / plotjob green with the companion workspace PRFull API Changes (for automation & release notes)
Changed Behaviour
autofit.plot.corner_cornerpy— additionally skips (logged, returns None) when effective sample size ≤ number of parameters.Added
autofit.non_linear.plot.samples_plotters._effective_sample_size(weight_list, sample_count)— private Kish ESS helper.Generated by the PyAutoLabs agent workflow.
🤖 Generated with Claude Code
https://claude.ai/code/session_01KeLmyZD5aG6BrTTdJzSmDv