-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Fix ParallelExecutor crash when Parallel called from within module forward() #9104
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,10 +89,10 @@ def worker(parent_overrides, submission_id, index, item): | |
| from dspy.dsp.utils.settings import thread_local_overrides | ||
|
|
||
| original = thread_local_overrides.get() | ||
| token = thread_local_overrides.set({**original, **parent_overrides.copy()}) | ||
| new_overrides = {**original, **parent_overrides.copy()} | ||
| if parent_overrides.get("usage_tracker"): | ||
| # Usage tracker needs to be deep copied across threads so that each thread tracks its own usage | ||
| thread_local_overrides.overrides["usage_tracker"] = copy.deepcopy(parent_overrides["usage_tracker"]) | ||
| new_overrides["usage_tracker"] = copy.deepcopy(parent_overrides["usage_tracker"]) | ||
| token = thread_local_overrides.set(new_overrides) | ||
|
|
||
| try: | ||
| return index, function(item) | ||
|
|
@@ -154,7 +154,9 @@ def all_done(): | |
| try: | ||
| index, outcome = f.result() | ||
| except Exception: | ||
| pass | ||
| logger.error(f"Worker failed: {e}") | ||
|
||
| if self.provide_traceback: | ||
| traceback.print_exc() | ||
| else: | ||
| if outcome != job_cancelled and results[index] is None: | ||
| # Check if this is an exception | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable, can we keep the comment? And also can you add a test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TomeHirata Added the comment back in directly above the deep copy.