Closed krypticmouse closed 1 week ago
One important note: I think we should deepcopy the stack when we're forking a thread! Not just copy, but deep copy, because the lists in the values are mutable.
Also important: we need to handle creating threads inside threads. This means every thread needs to "inherit" / fork / deepcopy the stack from its parent, not from the main stack.
This was not as crucial before because there was no case where people nested parallelism! Now with dspy.Parallel() everyone will nest parallelism.
Hi do I use dspy.Parallel?
This pull request introduces significant refactoring and new functionality to the
dspy
package. The most important changes include the introduction of aParallelExecutor
class, updates to theEvaluate
class to use this new executor, and the addition of abatch
method in theModule
class.Parallel Execution Enhancements:
dspy/utils/parallelizer.py
: Introduced theParallelExecutor
class to handle multi-threaded execution with error handling and progress tracking.dspy/evaluate/evaluate.py
: Refactored theEvaluate
class to use theParallelExecutor
for both single-threaded and multi-threaded execution, simplifying the code and removing redundant threading and error handling logic.New Functionality:
dspy/primitives/program.py
: Added abatch
method to theModule
class to process multiple examples in parallel using theParallelExecutor
. This method supports error handling and optional traceback information.