Skip to content

fix(ep): a fully reverted projection counts as skipped, not updated - #1574

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/ep-full-revert-not-updated
Sep 7, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/ep-full-revert-not-updated

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

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_field re-evaluated check_valid() after update_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 returned updated=True. EPOptimiser.factor_step trusts 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_dist per 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. success semantics 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_update and test_always_reverting_factor_is_counted_as_skipped_and_warned_about fail without the fix; test_partially_reverted_projection_still_reports_an_update pins 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.
  • Workspace: autofit_workspace_test/scripts/graphical/analytic_gaussian_collapse.py COLLAPSE CONFIG: PASS (5/5 seeds), RECOVER 5/5, STALE 0/5, σ/μ identical to the phase-2 record; the per-factor ep_history.csv flag 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

…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(ep): a fully reverted projection counts as skipped, not updated

1 participant