Skip to content

refactor(ep): remove ParallelEPOptimiser and its tests #1611

Closed

Description

@Jammy2211

Overview

ParallelEPOptimiser has never been used, adds complexity, and if it is ever wanted it can be restored from git history (human decision 2026-09-11, after #1608 / #1610). It is dead code already: not exported from autofit, autofit.graphical or the EP package (reachable only by deep import); its only test helper, _test_parallel_laplace in test_autofit/graphical/regression/test_linear_regression.py, is underscore-prefixed and never collected; and it is recorded as crashing at completion when paths=None (#1332 F3). It is EP's own opt-in process pool across factors (fork_context().Pool(n_cores - 1) + starmap(factor_step, …)), which shares the dead-worker hang fixed for Nautilus in #1610 and the JAX-in-a-forked-child deadlock of #1442. The ruling of 2026-09-09 is that EP never combines with Python multiprocessing, so the class contradicts the ruling by existing.

Plan

  • Delete the ParallelEPOptimiser class and the now-unused fork_context import from the EP optimiser module.
  • Delete the never-collected _test_parallel_laplace helper and its import.
  • Rewrite the F3 comments in the diagnostics tests so they describe EPOptimiser.run only.
  • Remove README section 7 (Parallel EP), renumber the lowering contract from §8 to §7, and fix every cross-reference to those section numbers (README, tests, AGENTS.md's EP seam rule).
  • Record the removal in the PR's API Changes as Removed (internal, never exported).
  • Separately, update the PyAutoMemory concept page line that describes the class (research: EP review phase 1 — statistics audit of autofit/graphical #1332 F3) to say it was removed here.
Detailed implementation plan

Affected Repositories

  • PyAutoFit (primary)
  • PyAutoMemory (one wiki line; separate ledger commit, not a PR of this issue)

Work Classification

Library

Branch Survey

Repository Current Branch Dirty?
./PyAutoFit main (915acd5f, #1610 merged) clean

Suggested branch: feature/remove-parallel-ep-optimiser

Implementation Steps

  1. autofit/graphical/expectation_propagation/optimiser.py — delete class ParallelEPOptimiser(EPOptimiser) (from its class line to the end of its run method, including the docstring note fix(ep): never drive a factor search through a multiprocessing pool; fail fast on a dead Nautilus worker (#1608) #1610 added). Remove from autofit.non_linear.parallel import fork_context if nothing else in the module uses it (grep first).
  2. test_autofit/graphical/regression/test_linear_regression.py — delete _test_parallel_laplace and the ParallelEPOptimiser import.
  3. test_autofit/graphical/functionality/test_diagnostics.py (~lines 178–202) — rewrite the comments that reference ParallelEPOptimiser / F3 so they describe the EPOptimiser.run guards they actually exercise; keep the test behaviour identical.
  4. autofit/graphical/README.md — delete "## 7. Parallel EP — ParallelEPOptimiser"; renumber "## 8. The lowering contract" to 7 and fix every §7 / §8 / "§1–§7" cross-reference in the README, in test_autofit/graphical/ and in AGENTS.md (the EP seam rule names "§8").
  5. grep -rn ParallelEPOptimiser autofit test_autofit docs must return nothing.
  6. Tests: python -m pytest test_autofit/graphical -q serially (baseline 281 passed after fix(ep): never drive a factor search through a multiprocessing pool; fail fast on a dead Nautilus worker (#1608) #1610; expect the same count, since the deleted helper was never collected), then the full suite.
  7. PR: API Changes → Removed: autofit.graphical.expectation_propagation.optimiser.ParallelEPOptimiser (internal, never exported).

Key Files

  • autofit/graphical/expectation_propagation/optimiser.py — the class.
  • autofit/graphical/README.md — §7 / §8.
  • test_autofit/graphical/regression/test_linear_regression.py, test_autofit/graphical/functionality/test_diagnostics.py — references.
  • AGENTS.md — the EP seam rule's §8 pointer.
  • PyAutoMemory/wiki/methods/concepts/expectation-propagation.md — the F3 line.

Original Prompt

Click to expand starting prompt

PyAutoMind draft/refactor/autofit/remove_parallelepoptimiser_and_its_tests.md, filed 2026-09-11 by /intake from the human's request: "removing ParallelEPOptimiser does not seem crazy — we've never used it and it adds complexity … even if it had use we could add it back in".

Activity

  1. added a commit that references this issue on Sep 12, 2026
  2. Jammy2211 commented on Sep 12, 2026

    @Jammy2211
    CollaboratorAuthor

    Shipped

    • Library PR: refactor(ep): remove ParallelEPOptimiser and its tests (#1611) #1612 — merged 2026-09-12 (merge commit 54f464d9), CI green on every leg (unittest 3.12 / 3.13 / nojax, docs-build).
    • ParallelEPOptimiser deleted from autofit/graphical/expectation_propagation/optimiser.py along with its never-collected _test_parallel_laplace helper; README §7 (Parallel EP) removed and the lowering contract renumbered §8 → §7 with every cross-reference updated; the diagnostics end-of-run-guards test reworded; unused multiprocessing import dropped. Net −211 lines, no public API change.
    • PyAutoMemory concept page updated separately (wiki/methods/concepts/expectation-propagation.md, commit 0cdede9 on main).
    • Pending release: PyAutoFit@refactor(ep): remove ParallelEPOptimiser and its tests (#1611) #1612 (label pending-release stays until a release publishes it).

    Mind record: PyAutoMind/complete/2026/09/remove-parallel-ep-optimiser.md.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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