Repository navigation
Commit 5995713
feat: parallelize rlm_query_batched subcalls for faster execution (#139)
* feat: parallelize rlm_query_batched subcalls using ThreadPoolExecutor
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 #135
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* move max_concurrent_subcalls as a general REPL property. add more tests
---------
Co-authored-by: dhananjai1729 <dhananjaikrishnakumarpm@Dhananjais-MacBook-Pro.local>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Alex Zhang <alex.lx.zhang@gmail.com>1 parent 2e5764b commit 5995713
4 files changed
Lines changed: 346 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
| |||
102 | 103 | | |
103 | 104 | | |
104 | 105 | | |
| 106 | + | |
| 107 | + | |
105 | 108 | | |
106 | 109 | | |
107 | 110 | | |
| |||
132 | 135 | | |
133 | 136 | | |
134 | 137 | | |
| 138 | + | |
135 | 139 | | |
136 | 140 | | |
137 | 141 | | |
| |||
238 | 242 | | |
239 | 243 | | |
240 | 244 | | |
| 245 | + | |
241 | 246 | | |
242 | 247 | | |
243 | 248 | | |
| |||
765 | 770 | | |
766 | 771 | | |
767 | 772 | | |
| 773 | + | |
| 774 | + | |
768 | 775 | | |
769 | 776 | | |
770 | 777 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
215 | | - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
216 | 218 | | |
217 | 219 | | |
| 220 | + | |
218 | 221 | | |
219 | 222 | | |
220 | 223 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
135 | 136 | | |
136 | 137 | | |
137 | 138 | | |
| 139 | + | |
138 | 140 | | |
139 | 141 | | |
140 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
141 | 148 | | |
142 | 149 | | |
143 | 150 | | |
| |||
316 | 323 | | |
317 | 324 | | |
318 | 325 | | |
319 | | - | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
320 | 332 | | |
321 | | - | |
322 | 333 | | |
323 | 334 | | |
324 | 335 | | |
| |||
329 | 340 | | |
330 | 341 | | |
331 | 342 | | |
332 | | - | |
333 | | - | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
334 | 363 | | |
335 | 364 | | |
336 | | - | |
337 | | - | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
338 | 368 | | |
339 | | - | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
340 | 384 | | |
341 | 385 | | |
342 | 386 | | |
| |||
0 commit comments