Skip to content

Add unit test for dspy.Parallel #8122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
chenmoneygithub opened this issue Apr 25, 2025 · 1 comment · Fixed by #8124
Closed

Add unit test for dspy.Parallel #8122

chenmoneygithub opened this issue Apr 25, 2025 · 1 comment · Fixed by #8124
Assignees
Labels
good first issue Good for newcomers

Comments

@chenmoneygithub
Copy link
Collaborator

This class is used to run DSPy modules in parallel in a thread-safe way. The code is located in dspy/utils/parallelizer.py, a sample usage is like below:

import dspy

dspy.settings.configure(lm=dspy.LM("openai/gpt-4o-mini"))

cot = dspy.ChainOfThought("question->answer")

parallelizer = dspy.Parallel()

results = parallelizer(
    [
        (cot, {"question": "What is the meaning of life?"}),
        (cot, {"question": "why did a chicken cross the kitchen?"}),
        (cot, {"question": "what is the capital of France?"}),
    ]
)
print(results)

We don't have unit test for this class now, and should test the following:

  • Worker threads don't affect each other, for example, each worker thread can maintain its own trace.
  • Worker threads are executed in parallel, which means it should be faster than executing in sequential order.
  • The parallel run doesn't crash until max_errors is hit.
@SanjanShiv
Copy link
Contributor

Hey @chenmoneygithub, I've submitted a PR addressing this issue. When you get a chance, could you review it? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants