Skip to content

feat(graphical): EP diagnostics and monitoring tooling#1349

Merged
Jammy2211 merged 2 commits into
mainfrom
feature/ep-diagnostics
Jul 10, 2026
Merged

feat(graphical): EP diagnostics and monitoring tooling#1349
Jammy2211 merged 2 commits into
mainfrom
feature/ep-diagnostics

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

EP framework review Phase 4 (tracker #1335; ship approved by human 2026-07-10). Built-in tools for analysing a finished EP fit and monitoring a running one: an EPDiagnostics collector snapshotting every factor update (status, global log-evidence, KL step, per-variable mean/std), live-overwritten ep_history.csv / mean_field_history.csv so a running fit can be watched, mean_field_evolution.png, a post-fit mean_field_summary() table, a per-factor graph_factors.png (replacing dead commented-out code, so one misbehaving factor is visible instead of averaged away), and check_sigma_collapse() — the runtime guard for audit finding F10 (undamped Laplace-only EP collapses sigmas to ~1e-15 with no guardrail). Also fixes F3 from #1332: the parallel optimiser's end-of-run visualiser()/_output_results crash when paths=None.

All additive; no behaviour change to fitting. Branch merged with current main (post #1345/#1348/#1334) before validation.

API Changes

Additive only. Three new public exports from autofit.graphical: EPDiagnostics, mean_field_summary, check_sigma_collapse. EPOptimiser/ParallelEPOptimiser now emit diagnostics artifacts at output_interval and run end (F3 crash fixed on the parallel path).
See full details below.

Test Plan

  • Full test_autofit/ suite on the merged branch: 1457 passed / 14 skipped (current-main baseline 1447 + 7 new diagnostics tests + 3 docs seam tests)
  • New test_diagnostics.py — 7 tests: snapshot schema, CSV/plot/results artifacts, summary content, collapse detector (floor + monotone + healthy-negative), F3 guards
  • Live smoke (at implementation): exact-conjugate graph — posterior matches analytic to machine precision, all 5 artifacts written, collapse detector silent on a healthy run
  • Post-merge follow-up (option i): wire mean_field_summary() calls into the Phase-3 EP walkthrough example (autofit_workspace#82)

Validation checklist (--auto run — plan on the issue)

  • Effective level: supervised (--auto chain 2026-07-08; ship approved live by human 2026-07-10)
  • Plan: on the issue (feat: EP review phase 4 — diagnostics & monitoring for EP fits #1335), sign-off summary posted 2026-07-08, unmodified
  • Gate: tests 1457 pass / 14 skip · smoke exact-conjugate live run · review human ship-approval of the posted diff · Heart YELLOW within the live 6-reason ack recorded this chain
  • Human: merge, amend, or reject — then log the outcome
Full API Changes (for automation & release notes)

Added

  • autofit.graphical.EPDiagnostics — per-factor-update snapshot collector; writes ep_history.csv, mean_field_history.csv (live-overwritten), mean_field_evolution.png, ep_diagnostics.results
  • autofit.graphical.mean_field_summary(...) — post-fit per-variable summary table
  • autofit.graphical.check_sigma_collapse(...) — F10 guard: absolute-floor + monotone-shrink detection over the update history; warnings logged and written to the results file
  • graph_factors.png — per-factor evidence/KL curves emitted by the EP visualiser

Changed Behaviour

Migration

  • None. All additions; existing EP scripts gain the artifacts automatically.

🤖 Generated with Claude Code

Jammy2211 and others added 2 commits July 10, 2026 10:06
EP framework review Phase 4 — built-in tools for analysing a finished
EP fit and monitoring a running one:

- expectation_propagation/diagnostics.py (new): EPDiagnostics collector
  (per-factor-update snapshot: status, global log-evidence, KL step,
  every variable's mean/std); live-overwritten ep_history.csv +
  mean_field_history.csv; mean_field_evolution.png; post-fit
  mean_field_summary() table; check_sigma_collapse() F10 guard
  (floor + monotone-shrink detection)
- optimiser.py: EPOptimiser/ParallelEPOptimiser snapshot each update,
  emit artifacts at output_interval + run end; F3 fixed (parallel
  end-of-run visualiser()/_output_results guarded for paths=None)
- visualise.py: graph_factors.png per-factor evidence/KL curves
  (replaces dead commented-out code)
- exports: EPDiagnostics, mean_field_summary, check_sigma_collapse
  from autofit.graphical (additive)
- test_diagnostics.py: 7 tests (snapshot schema, artifacts, summary,
  collapse detector, F3 guards)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release PR queued for the next release build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant