Skip to content

fix: parallel fits ignoring updated priors, and multi-start comparison - #104

Merged
lenarddome merged 4 commits into
mainfrom
fix/optimiser-starts-parallel
Oct 14, 2026
Merged

lenarddome merged 4 commits into
mainfrom
fix/optimiser-starts-parallel

Conversation

@lenarddome

Copy link
Copy Markdown
Collaborator

Fixes three bugs found while working on #103.

Changes

  • Parallel fits ignored updated priors. With parallel=True and prior=True, every worker went back to the priors the model was created with after its first evaluation. Priors changed with update_prior were ignored, so parallel fits came out worse than serial ones. This includes the population priors of EmpiricalBayes and VariationalBayes.
    • Cause: cpm/generators/__init__.py deleted its submodules (del simulator, wrapper, session, parameters). dill then couldn't find Value, Parameters, Wrapper and the other generator classes by name, so it shipped copies of the classes to the workers. There, isinstance(x, Value) was false, and Wrapper.reset (through restore_parameters) fell back to the initial priors.
    • Fix: the del line is removed. Parallel fits now equal serial ones exactly. Parallel results with updated priors change.
  • Multiple starts were compared with the first only. Fmin, FminBound, Minimize and Bads compared every later start with the first start instead of the best so far. With 3 or more starts, a participant's best fit could be replaced by a worse one. Fixed in both the default path and the hessian="finite_differences" path. Results with 3 or more starts can change.
  • Wrong default in a docstring. The VariationalBayes docstring gave 1000 as the default of iteration; the code uses 50.
  • Changelog entries are under 0.26.0.dev3.

Testing

  • test/optimisation/test_parallel.py: dill pickles all six generator classes by reference; an unpickled model keeps its updated priors across runs; parallel FminBound fits with updated priors equal serial ones.
  • test/optimisation/test_starts.py: an objective with three wells and one start at the bottom of each, ordered so that the old comparison keeps the second-best well. It runs for all four optimisers, with both hessian options.
  • All 16 new tests fail on the old code and pass with the fixes. The full suite passes locally on Windows (771 tests).

🤖 Generated with Claude Code

lenarddome and others added 4 commits October 14, 2026 13:43
Deleting the submodules made dill copy the classes into the workers, so isinstance failed there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lenarddome
lenarddome merged commit 948f605 into main Oct 14, 2026
16 checks passed
@lenarddome
lenarddome deleted the fix/optimiser-starts-parallel branch October 14, 2026 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant