Repository navigation
fix(ep): a fully reverted projection counts as skipped, not updated - #1574
Merged
Merged
Conversation
…1571) MeanField.update_factor_mean_field re-evaluated check_valid() after update_invalid(last_dist) had reverted the invalid parameters, so the flag was True by construction and a projection that reverted every parameter still returned updated=True. EPOptimiser.factor_step trusts that flag, so the factor never reached _stale_factor_warnings and an EP run could return its unchanged starting distribution with no STALE FACTORS line. Compare the reverted message to last_dist per variable instead; nothing changed means skipped. README §3.5 now describes the minimal Laplace EP as the stale-factor state, not a collapse (the phase-1 wording error). Codex review of the phase-2 fixes, finding 2. Per-(factor, variable) tracking for partial reverts is filed separately. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gu4YysuvpQ4k6zkQjiwabd
This was referenced Sep 7, 2026
This was referenced Sep 7, 2026
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.
Closes #1571. Finding 2 (P2) of the Codex review of the phase-2 EP fixes, plus the README wording carry-over (#1562 introduced the tracking; umbrella #1405).
Problem
MeanField.update_factor_mean_fieldre-evaluatedcheck_valid()afterupdate_invalid(last_dist)had reverted the invalid parameters. Reverted parameters come from a valid message, so the flag was true by construction and a projection that reverted every parameter still returnedupdated=True.EPOptimiser.factor_steptrusts that flag, so the factor never reached_stale_factor_warnings: an EP run could return its unchanged starting distribution with no STALE FACTORS line. The two existing stale tests drive a raising optimiser and never reach this branch.Fix
Compare the reverted message to
last_distper variable on natural parameters (MeanField.check_changed, exact equality, since a revert copies parameters bit-for-bit). Nothing changed means the update is skipped, with an explicit"factor update skipped: every parameter reverted"status message. A partial revert still counts as an update.successsemantics are untouched.README §3.5 now describes the minimal hand-rolled Laplace EP as reaching the stale-factor state (every site update rejected, scatter returned at its prior), not a collapse; the STALE FACTORS paragraph notes that a fully reverted projection counts as skipped.
Not in scope
A hierarchical factor whose scatter reverts every sweep while its other variables update is a partial revert and still passes as updated. Per-(factor, variable) staleness is filed as
PyAutoMind/draft/feature/autofit/ep_stale_tracking_per_variable.md.API Changes
None.
MeanField.check_changed(other)is a new public helper.Tests
test_fully_reverted_projection_reports_no_updateandtest_always_reverting_factor_is_counted_as_skipped_and_warned_aboutfail without the fix;test_partially_reverted_projection_still_reports_an_updatepins the unchanged half.test_autofit/graphical: 268 passed (270 with fix(laplace): refresh deterministic-variable covariance on the fd-Hessian path #1573 cherry-picked on top).test_autofit/messages: 93 passed.autofit_workspace_test/scripts/graphical/analytic_gaussian_collapse.pyCOLLAPSE CONFIG: PASS (5/5 seeds), RECOVER 5/5, STALE 0/5, σ/μ identical to the phase-2 record; the per-factorep_history.csvflag tallies shift because the flag now means "moved" (seed 0 HierarchicalFactor BAD_PROJECTION 8 / FAILURE 1 / SUCCESS 1, was 9 / 0 / 5).🤖 Generated with Claude Code
https://claude.ai/code/session_01Gu4YysuvpQ4k6zkQjiwabd