Repository navigation
feat: parallelize rlm_query_batched subcalls for faster execution - #139
Merged
alexzhang13 merged 2 commits intoMar 19, 2026
Merged
Conversation
When rlm_query_batched fans out multiple independent child RLM calls, they now run concurrently via a bounded thread pool instead of sequentially. This reduces wall time from N*T to ~T for N I/O-bound subcalls. Key changes: - Use ThreadPoolExecutor in _rlm_query_batched for 2+ prompts - Add max_concurrent_subcalls parameter (default 4) with semaphore-style concurrency control at each recursion level - Propagate setting from RLM -> LocalREPL -> child RLMs - Thread-safe completion collection with deterministic ordering - Skip thread pool for 0-1 prompts (no overhead) Closes alexzhang13#135 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
alexzhang13
approved these changes
Mar 19, 2026
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.
Summary
Addresses #135 —
rlm_query_batchednow runs independent child RLM subcalls in parallel usingThreadPoolExecutor, reducing wall time fromN × Tto~Tfor N I/O-bound subcalls._rlm_query_batchedmax_concurrent_subcallsparameter (default: 4) on bothRLMandLocalREPL, propagated to child RLMs at each recursion level_pending_llm_callsmaintain original prompt order for deterministic metadataThreadPoolExecutorwhenlen(prompts) <= 1Files changed
rlm/environments/local_repl.py_rlm_query_batchedwithThreadPoolExecutor; addedmax_concurrent_subcallsparamrlm/core/rlm.pymax_concurrent_subcallsparam; propagated to environment and child RLMstests/test_rlm_query.pyTest plan
TestRlmQueryBatchedParalleltest class with 6 tests:test_batched_runs_in_parallel— verifies wall time is significantly less than sequentialtest_batched_respects_max_concurrent— verifies concurrency cap via active thread trackingtest_batched_preserves_order_parallel— verifies result order matches input order with random delaystest_batched_parallel_partial_failure— verifies failures in one thread don't affect otherstest_batched_pending_calls_ordered— verifies_pending_llm_callsare in prompt ordertest_single_prompt_skips_thread_pool— verifies no thread pool overhead for single promptcc @alexzhang13 @alt-glitch @lakshyaag @rawwerks — would appreciate your review and feedback!
🤖 Generated with Claude Code