Skip to content

research: EP review phase 1 — statistics audit of autofit/graphical #1332

Description

@Jammy2211

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)

  1. 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.
  2. Factor approximation / cavity: how q^{\i} is formed and how the tilted distribution is projected back (autofit/graphical/expectation_propagation/, mean_field.py).
  3. KL machinery: which direction KL(p||q) vs KL(q||p) is computed where; moment-matching equivalence assumptions; EPHistory convergence checks.
  4. Damping / step control and the LaplaceOptimiser (autofit/graphical/laplace/) — gradients, Hessians, line search.
  5. Deterministic variables plumbing (factor_graphs/), as groundwork for Phase 5.
  6. Cross-check against the three use cases; note which components each exercises.

Key Files

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions