Repository navigation
Report a non-finite EP evidence term by name instead of warn-and-sum (#1713) - #1714
Merged
Merged
Conversation
…1713) On analytic_gaussian seeds 25 and 172 a HierarchicalFactor member sends the scatter sigma an accepted TruncatedNormalMessage whose support lies ~19 sigma into its tail; its log_partition underflows to -inf, the variable's evidence goes +inf, every adjacent factor term -inf, and log_evidence summed them to NaN with a numpy RuntimeWarning on every EP update. The posterior is unaffected (bit-identical sidecars); only the evidence readout was. log_evidence now detects a non-finite term before summing, names it once per fit (weakly keyed on the factor graph) in a logger warning and in ep_diagnostics.results, and returns an explicit NaN; evidence_divergence returns inf on a NaN so no evidence stopping rule can claim convergence. No message arithmetic, projection or optimiser changes; the tail-stable log_partition cure is filed separately. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Collaborator
Author
|
Workspace regression: PyAutoLabs/autofit_workspace_test#116 · new-scope prompt (message maths, human decision): PyAutoMind |
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
Closes #1713. On analytic_gaussian ensemble seeds 25 and 172 (ruling R-20260910-04),
EPMeanField.log_evidenceemittedRuntimeWarning: invalid value encountered in addrepeatedly and wrote NaN intoep_history.csvfrom sweep 4 onwards. Diagnosis (reproduced on main, mode projection only): oneHierarchicalFactormember sends the scattersigmaan acceptedTruncatedNormalMessagewith mean −7374 and sigma 384 on [0, 100], so its support sits ~19 sigma into the tail;TruncatedNormalMessage.log_partitioncomputeslog(Φ(b) − Φ(a))directly, which underflows to −inf (true value ≈ −187.9), the variable's evidence becomes +inf, every adjacent factor term −inf, and the sum NaN. The posterior is bit-identical to the committed sidecars;evidence_tolis None by default so stopping is KL-only; only the evidence readout, its plot and the factor log line were affected.This PR is reporting only: the non-finite term is detected before summing, named once per fit in a
logger.warningand inep_diagnostics.results, and the evidence is returned as an explicit NaN with no numpy warnings;evidence_divergencereturns inf on a NaN so an evidence-based stopping rule can never claim convergence on it. No message arithmetic, projection or optimiser changes. The cure of the term itself (a tail-stablelog_partition) is message maths and is filed separately asPyAutoMind/draft/bug/autofit/truncated_normal_log_partition_tail_underflow.mdfor the human's decision.Workspace regression: autofit_workspace_test (seed-0 legs assert no
ep_mean_fieldRuntimeWarning and finite evidence; new seed-25 mode-projection leg asserts the term is named).API Changes
No public API change.
EPMeanField.log_evidencenow returnsfloat("nan")(instead of a NaN produced with numpy warnings) when any term is non-finite and logs the offending variables/factors once per fit; new read-only propertyEPMeanField.nonfinite_evidence_terms({label: kind});EPHistory.evidence_divergencereturnsinfinstead of NaN when an evidence is NaN;ep_diagnostics.resultsgains anevidence_nonfinite:line when it happens.See full details below.
Test Plan
test_autofit/graphical/functionality/test_evidence_nonfinite.py(7 tests; 6 fail on the previous code, 7 pass now): no RuntimeWarning, one named warning, NaN evidence, healthy evidence unchanged from the old formula, divergence inf on NaN / 0 when healthy, diagnostics linepytest test_autofit/graphical -q -x: 329 passedpytest test_autofitserially: 3890 passed, 1 skipped, 1 xfailed (under-n 4the suite shows pre-existing xdist races on the sharedtest_autofit/output/— unrelated to this change)analytic_gaussianscripts): seeds 25 and 172 under-W error::RuntimeWarningexit 0;ep_diagnostics.resultsnamesvariable 'truncatedgaussianprior_387' (+inf, first at step 39)(step 40 on seed 172); posteriors bit-identical to the committed sidecarsFull API Changes (for automation & release notes)
Removed
Added
autofit.graphical.expectation_propagation.ep_mean_field.EPMeanField.nonfinite_evidence_terms— property,{label: kind}of non-finite evidence terms (empty when finite)autofit.graphical.expectation_propagation.diagnostics.check_evidence_nonfinite()— theevidence_nonfinite:results line;EPDiagnostics.evidence_nonfiniterecords first step and kind per termChanged
EPMeanField.log_evidence— explicitfloat("nan")on any non-finite term, onelogger.warningper fit naming it, no numpy RuntimeWarnings; finite path unchangedEPHistory.evidence_divergence—infwhen the difference is NaNEPOptimiser— appendscheck_evidence_nonfiniteto theep_diagnostics.resultswarningsMigration
Generated by the PyAutoLabs agent workflow.
🤖 Generated with Claude Code