Skip to content

research: EP review phase 0 — Fable reassessment of priors/messages findings #1330

Description

@Jammy2211

Overview

Phase 0 of the EP framework review (umbrella prompt: PyAutoMind/research/graphical_ep/ep_framework_review.md). An earlier Opus-era audit of priors and messages produced 14 parked findings (PyAutoMind/bug/priors/01–14) plus a confirmed-bug census (PyAutoMind/research/autofit/priors_and_messages_math_audit.md). Those findings predate fixes such as e95295b83 (log_prior density-form sign convention) and #1329 (LogUniform -inf for value<=0), so before anything is fixed, every finding is re-verified with Fable against clean main and given a verdict. No PyAutoFit source is edited in this phase — confirmed bugs graduate to their own fix tasks.

Baseline for reassessment: main @ 0f26ff2d8 ("fix: LogUniform NumPy log-prior returns -inf for value<=0 (emcee NaN crash) (#1329)").

Plan

  • Re-verify all 14 bug/priors findings and the audit census's confirmed-bug list against main @ 0f26ff2d8: reproduce crash-class findings, re-derive math-class findings analytically and cross-check numerically against scipy.stats.
  • Issue a verdict per finding — fix now / park / close stale — with re-ranked severity and a minimal reproduction where confirmed.
  • Write verdicts back into each bug/priors/*.md prompt; update or retire the parked audit census.
  • Post the verdict table here and recommend which bugs graduate to immediate fix tasks and what Phase 1 (the wider EP statistics review of autofit/graphical) should scrutinise first.
Detailed implementation plan

Affected Repositories

  • PyAutoFit (primary — read-only: reproductions against clean main)
  • PyAutoMind (verdict writes into bug/priors/*.md + audit census)

Branch Survey

Repository Current Branch Dirty?
./PyAutoFit main clean (claimed by aggregator-output-contracts worktree — not a blocker for read-only work)
./PyAutoMind main clean

Suggested branch: none — research task, no source edits; fixes become separate feature/<bug> tasks.

Implementation Steps

  1. Crash-class findings — scratchpad reproduction scripts against the installed stack (numpy/scipy only, no JAX):
    • 01 LogGaussianPrior.with_limits / _new_for_base_message ctor crash (autofit/mapper/prior/log_gaussian.py)
    • 02 UniformPrior logpdf array handling
    • 05 inv-beta suffstats clamp no-op
    • 06 NormalMessage negative sigma unchecked
    • 10 fixed-message cache growth (small-loop memory profile)
  2. Math-class findings — re-derive analytically, numerically cross-check vs scipy.stats:
    • 03 GammaPrior.from_mode formula
    • 04 truncated-normal log-partition completeness
    • 07 log_prior normalisation convention (check interaction with e95295b83 density-form change)
    • 08 relative-width modifier safety
  3. Design/meta prompts — reassess relevance/priority, no reproduction:
    • 09 prior property tests; 11 transformed-message semantics doc; 12 single-source density refactor; 13 collapse prior+message; 14 bijector transform stack
    • several may be absorbed by Phases 1–2 of the umbrella review (formal-equations documentation).
  4. Write a ## Fable verdict (2026-07-08) block into each PyAutoMind/bug/priors/*.md with verdict, severity, and reproduction status.
  5. Update or retire PyAutoMind/research/autofit/priors_and_messages_math_audit.md.
  6. Post the verdict table to this issue with the Phase 1 hand-off recommendation.

Key Files

  • autofit/mapper/prior/ — prior classes under reassessment
  • autofit/messages/ — message algebra under reassessment
  • PyAutoMind/bug/priors/01–14.md — the findings receiving verdicts
  • PyAutoMind/research/graphical_ep/ep_framework_review.md — umbrella prompt (Phases 0–7)

Original Prompt

Click to expand starting prompt

So, we used Opus to do a review of messages and priors in autofit, which led to all the issues in bug/priors. I want us reassess this using Fable, and for us to go on to do a wider review of the Expectation propagation framework (source code PyAutoFit/autofit/graphical, with examples giving a run through of the graphical / EP modeling in HowToFit/scripts/chapter_3_graphical_models, and the cancer use case in /mnt/c/Users/Jammy/Science/ic50_workspace, and cosmology in /mnt/c/Users/Jammy/Science/concr/scripts/cosmology . Tasks include: (i) assessing if priors, messages and the underlying statistics of EP in autofit has bugs we should fix; (ii) documentation of the graphical package (including formal bayesian equations which ensure an AI agent knows exactly what bayes statistics are being used) and more thorough integration tests in autofit_workspace_test (see autofit_workspace_test/scripts/graphical) and more thorough end-to-end example scripts, written in the style of eamples in autofit_workspace/scripts, which explain the EP framework, its stats and allow for step-by-step run trhoughs of th eEP framework, e.g. something written in the style of something like autolens_workspace/scripts/imaging/likelihood_function.py which allows a user to run EP at the lower level API step-by-step and follow what is happening; (iii) currently there are not many built in tools for analysing the results of an EP fit or monitoring how the fit is progress, can we add more of these (could be funciton calls at end of examples, visuals output during EP and text file metadata in the output folder; (iv) deterministic variables in the cancer use case use inbuilt aspects of the EP composition (find an old PR by rhayes777 on this) but do not use the determinitic_variable API in the low level EP code, should we do anything about that?; (v) scope out analytic likelihood updates in the EP source code; (vi) What other features can we plan? This is obviously a huge prompt, so use your fable magic to plan everything out thoroughly

(Umbrella prompt covers Phases 0–7; this issue is Phase 0 only. Later phases are issued separately as each predecessor nears shipping.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions