Commit 3389a16
authored
[Pipeline] Support async ops in fused subprocess stages (#1579)
`fuse_subprocess_stages=True` fuses runs of adjacent pipe stages that
share the same isolating-pool (process/interpreter) executor instance
into one nested `Pipeline` that runs inside a worker process,
eliminating the per-stage IPC round-trip. Previously an async op could
never be part of a fused run: `PipeConfig` rejected any `executor` on an
async op, and fusion groups stages purely by executor-instance identity.
An async op between two pool stages therefore split the fusable run in
two, forcing the intermediate value to round-trip (and be pickled)
through the main process.
This commit lets an async op join a fused run by tagging it with the
same isolating-pool executor as its neighbours. The executor is never
used to run the coroutine (an async op always runs on the event loop) —
it is only the fusion-group key. When fused, the tag is stripped and the
op runs on the worker's own event loop, exactly as fused `path_variants`
async branches already do. When not fused (fusion off, or a lone async
op), the tag is ignored and the op runs on the main loop as before. The
execution engine is unchanged: each worker already rebuilds the
sub-config with the normal `build_pipeline`, which runs a full event
loop.
Details:
- `PipeConfig.__post_init__` now allows an isolating-pool executor on an
async op and rejects only non-isolating executors (e.g. a thread pool),
which have no effect on an async op.
- `convert_to_async` ignores the executor for async ops instead of
asserting it is `None`.
- `_is_isolating_pool`/`_is_interpreter_pool` moved from `_fuse` to
`_common/_convert` so `defs` can reuse them without an import cycle.
- Fusion detection: an async op that now carries an executor flows
through `_fusable_pool_executor` automatically. Inside a `path_variants`
stage, `_scan_variant_pool_executors` ignores an async op's pool tag
instead of treating it as an input-ordered pool-pipe — an async op's
executor is only a fusion-group tag (it runs on the loop, not the pool),
so its `output_order="input"` cannot be broken by pool parallelism and
must not block fusing the same-pool stage. Only a sync input-ordered
pool-pipe still blocks fusion. `_stage_concurrency` counts async ops as
zero worker threads (they run on the loop, not the thread pool).
- `run_pipeline_in_subprocess` strips any executor tag left on an
unfused async op before the op-agnostic executor-hoisting pass, so a tag
never spawns an idle worker pool the op will not use.
A fused async op must be picklable, like any fused stage. This is
documented on `PipelineBuilder.pipe` and in the parallelism guide.1 parent d8a0dbc commit 3389a16
12 files changed
Lines changed: 347 additions & 58 deletions
File tree
- docs/source/getting_started
- src/spdl
- autoresearch/pipeline_optimization/prompts
- knowledge
- pipeline
- _common
- defs
- tests/pipeline
- tools/skills/migration
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
345 | 345 | | |
346 | 346 | | |
347 | 347 | | |
348 | | - | |
349 | | - | |
350 | | - | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
351 | 366 | | |
352 | 367 | | |
353 | 368 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
271 | | - | |
| 271 | + | |
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
| |||
Lines changed: 0 additions & 31 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | 36 | | |
68 | 37 | | |
69 | 38 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
207 | | - | |
| 207 | + | |
208 | 208 | | |
209 | 209 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
284 | | - | |
285 | | - | |
286 | | - | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
287 | 289 | | |
288 | 290 | | |
289 | 291 | | |
| |||
565 | 567 | | |
566 | 568 | | |
567 | 569 | | |
568 | | - | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
569 | 573 | | |
570 | 574 | | |
571 | 575 | | |
| |||
616 | 620 | | |
617 | 621 | | |
618 | 622 | | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
619 | 628 | | |
620 | 629 | | |
621 | 630 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
174 | 188 | | |
175 | 189 | | |
176 | 190 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
205 | | - | |
206 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
207 | 210 | | |
208 | 211 | | |
209 | 212 | | |
| |||
0 commit comments