-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Open
Description
python version : 3.10
dspy version : 3.0.4
When using UsageTracker together with MIPROv2, the following error occurs:
AttributeError: '_contextvars.ContextVar' object has no attribute 'overrides'
After debugging, I found that this error is triggered when using ParallelExecutor inside a with dspy.context(...): block.
This causes MIPROv2._optimize_prompt_parameters() to fail when evaluating the optimized prompts—because it's running inside a with dspy.context(lm=self.task_model): block, and the Evaluate call uses ParallelExecutor under the hood.
Below is a minimal reproducible example.
The error can be observed at line 153 in parallelizer.py.
import dspy
from dspy.utils.parallelizer import ParallelExecutor
from dspy.utils.usage_tracker import UsageTracker
dspy.configure(lm=lm)
dspy.settings.configure(usage_track=True,usage_tracker=UsageTracker())
def do_infer(text):
return lm(text)
with dspy.context(lm=lm):
executor = ParallelExecutor(num_threads=2)
results = executor.execute(do_infer, batch_data)I’m wondering—is this my fault, or is it actually a bug?
Copilot
Metadata
Metadata
Assignees
Labels
No labels