Fix callable evaluator failing in subprocess workers#423
Open
powerpratik wants to merge 1 commit intoalgorithmicsuperintelligence:mainfrom
Open
Fix callable evaluator failing in subprocess workers#423powerpratik wants to merge 1 commit intoalgorithmicsuperintelligence:mainfrom
powerpratik wants to merge 1 commit intoalgorithmicsuperintelligence:mainfrom
Conversation
_prepare_evaluator() stored callable evaluators in globals() of the api module, which is inaccessible from ProcessPoolExecutor worker processes. Workers import openevolve.api fresh and the dynamic attribute doesn't exist in their memory space, causing AttributeError on every evaluation. Fix: serialize the callable to disk via cloudpickle/pickle and have the evaluator wrapper load it from the file. Also document the if __name__ == '__main__' guard requirement for macOS/Windows multiprocessing. Verified with a local LLM endpoint (Ollama) to confirm cross-process evaluation works end-to-end.
892e988 to
79b72b0
Compare
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.
Summary
_prepare_evaluator()stored callable evaluators inglobals()of theapimodule, which is inaccessible fromProcessPoolExecutorworker processes. Workers importopenevolve.apifresh and the dynamic attribute doesn't exist in their memory space, causingAttributeErroron every evaluation.cloudpickle/pickleand have the evaluator wrapper load it from the file.if __name__ == '__main__':guard to the library usage example in the README, with a note about macOS/Windows multiprocessing requirements.Changes
openevolve/api.pyglobals()storage with pickle-to-disk serializationpyproject.tomlcloudpickle>=2.0.0dependencytests/test_api.pyREADME.md__main__guard to library example + noteReproduction
Before this fix, using
evolve_function(),evolve_code(), orevolve_algorithm()with process-parallel evaluation produces:Test plan