Overview
Phase 1 of the EP framework review (umbrella: PyAutoMind/research/graphical_ep/ep_framework_review.md; Phase 0 verdicts: #1330; fix decisions: #1331). A full statistical audit of the expectation-propagation machinery in autofit/graphical/, in the same style as the priors/messages audit: re-derive the math each component claims to implement, verify the code against it, and record findings with minimal reproductions.
Phase 0's key lesson sets the priority: bugs hide on the generic exponential-family path while direct paths stay correct (e.g. the TruncatedNormal log-partition bug) — and that generic path is exactly what EP consumes.
Plan
- Audit the core EP statistics in
autofit/graphical/: message algebra (natural parameters, sufficient statistics, log-normalisers, products/quotients), cavity distribution computation, tilted-distribution moment matching / KL projection direction, damping, the mean-field approximation, EPHistory convergence criteria (KL evaluation), and the Laplace optimiser step.
- Ground the audit in the three real use cases:
HowToFit/scripts/chapter_3_graphical_models, the IC50 cancer workspace, and the cosmology scripts — confirming the code paths they actually exercise.
- Output: a findings census (confirmed bugs / suspect math / verified-correct inventory), each finding with a minimal reproduction, posted here.
- Write the formal statistical description (equations as implemented, not textbook ideals) — this seeds the Phase 2 package documentation.
Detailed implementation plan
Affected Repositories
- PyAutoFit (primary — read-only: audit against clean
main)
- PyAutoMind (findings census + verdicts)
Suggested branch
None — research task; fixes graduate to their own tasks (coordinating with #1331's batch).
Audit order (generic-path-first, per the Phase 0 lesson)
autofit/messages/abstract.py message interface algebra: __mul__/__truediv__ natural-parameter arithmetic, sum_natural_parameters, log_normalisation, project, from_mode — the operations every EP update composes.
- Factor approximation / cavity: how
q^{\i} is formed and how the tilted distribution is projected back (autofit/graphical/expectation_propagation/, mean_field.py).
- KL machinery: which direction KL(p||q) vs KL(q||p) is computed where; moment-matching equivalence assumptions;
EPHistory convergence checks.
- Damping / step control and the
LaplaceOptimiser (autofit/graphical/laplace/) — gradients, Hessians, line search.
- Deterministic variables plumbing (
factor_graphs/), as groundwork for Phase 5.
- Cross-check against the three use cases; note which components each exercises.
Key Files
Overview
Phase 1 of the EP framework review (umbrella:
PyAutoMind/research/graphical_ep/ep_framework_review.md; Phase 0 verdicts: #1330; fix decisions: #1331). A full statistical audit of the expectation-propagation machinery inautofit/graphical/, in the same style as the priors/messages audit: re-derive the math each component claims to implement, verify the code against it, and record findings with minimal reproductions.Phase 0's key lesson sets the priority: bugs hide on the generic exponential-family path while direct paths stay correct (e.g. the TruncatedNormal log-partition bug) — and that generic path is exactly what EP consumes.
Plan
autofit/graphical/: message algebra (natural parameters, sufficient statistics, log-normalisers, products/quotients), cavity distribution computation, tilted-distribution moment matching / KL projection direction, damping, the mean-field approximation,EPHistoryconvergence criteria (KL evaluation), and the Laplace optimiser step.HowToFit/scripts/chapter_3_graphical_models, the IC50 cancer workspace, and the cosmology scripts — confirming the code paths they actually exercise.Detailed implementation plan
Affected Repositories
main)Suggested branch
None — research task; fixes graduate to their own tasks (coordinating with #1331's batch).
Audit order (generic-path-first, per the Phase 0 lesson)
autofit/messages/abstract.pymessage interface algebra:__mul__/__truediv__natural-parameter arithmetic,sum_natural_parameters,log_normalisation,project,from_mode— the operations every EP update composes.q^{\i}is formed and how the tilted distribution is projected back (autofit/graphical/expectation_propagation/,mean_field.py).EPHistoryconvergence checks.LaplaceOptimiser(autofit/graphical/laplace/) — gradients, Hessians, line search.factor_graphs/), as groundwork for Phase 5.Key Files
autofit/graphical/expectation_propagation/— EP optimiser, history, factor optimiserautofit/graphical/mean_field.py,factor_graphs/— approximation structureautofit/graphical/laplace/— Laplace/Newton machineryautofit/messages/— the algebra underneath (post-Priors & messages: 9 confirmed bugs — guidance wanted on 5 decisions #1331 fixes where relevant)