Closed
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR parallelizes heavy per-evaluation loops in both the query adapter updater and evaluation runner by adding a max_workers parameter and using ThreadPoolExecutor to process each eval concurrently.
- Adds
max_workersarguments toupdate_query_adapterandanswer_evalsto control parallelism. - Introduces
process_evalhelper functions with thread-local sessions to handle per-eval work. - Replaces sequential loops over evals with futures, progress bars, and result aggregation.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/raglite/_query_adapter.py | Parallelize update_query_adapter by spawning threads per eval |
| src/raglite/_eval.py | Parallelize answer_evals by spawning threads per eval |
Comments suppressed due to low confidence (3)
src/raglite/_query_adapter.py:47
- The new
max_workersparameter should be documented in the function's docstring (describe how it controls concurrency).
max_workers: int | None = None,
src/raglite/_query_adapter.py:195
- Variable
Nis not defined inprocess_evalbefore being passed to_optimize_query_target, leading to a NameError. You need to buildN(negative embeddings) as you did forP.
t = _optimize_query_target(q, P, N, α=optimize_gap)
src/raglite/_eval.py:198
- The new parallel branch controlled by
max_workersis not covered by existing tests; add tests foranswer_evalswithmax_workers > 1to ensure correct ordering and error handling.
max_workers: int | None = None,
| with ThreadPoolExecutor(max_workers=max_workers) as executor: | ||
| # Submit all tasks with their original index | ||
| future_to_eval_idx = { | ||
| executor.submit(process_eval, eval_): (eval_, idx) |
There was a problem hiding this comment.
[nitpick] Calling create_database_engine inside each thread for every eval can be expensive; consider creating the engine once outside and passing a shared session factory to avoid repeated engine initialization.
Suggested change
| executor.submit(process_eval, eval_): (eval_, idx) | |
| executor.submit(process_eval, eval_, engine): (eval_, idx) |
Member
|
Superseded by #157. |
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.
Related to this issue: #152