Repository navigation
fix: parallel fits ignoring updated priors, and multi-start comparison - #104
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes three bugs found while working on #103.
Changes
parallel=Trueandprior=True, every worker went back to the priors the model was created with after its first evaluation. Priors changed withupdate_priorwere ignored, so parallel fits came out worse than serial ones. This includes the population priors ofEmpiricalBayesandVariationalBayes.cpm/generators/__init__.pydeleted its submodules (del simulator, wrapper, session, parameters). dill then couldn't findValue,Parameters,Wrapperand the other generator classes by name, so it shipped copies of the classes to the workers. There,isinstance(x, Value)was false, andWrapper.reset(throughrestore_parameters) fell back to the initial priors.delline is removed. Parallel fits now equal serial ones exactly. Parallel results with updated priors change.Fmin,FminBound,MinimizeandBadscompared 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 thehessian="finite_differences"path. Results with 3 or more starts can change.VariationalBayesdocstring gave 1000 as the default ofiteration; the code uses 50.Testing
test/optimisation/test_parallel.py: dill pickles all six generator classes by reference; an unpickled model keeps its updated priors across runs; parallelFminBoundfits 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 bothhessianoptions.🤖 Generated with Claude Code