Problem
GraphWorkflow currently walks the topology sequentially even when the DAG has independent branches. If the graph is A -> B, A -> C, B -> D, C -> D, today B and C execute one after the other despite having no data dependency on each other.
Proposed feature
Detect independent branches at run time and execute them concurrently using ThreadPoolExecutor. A correctness-preserving pure latency win.
Design sketch
- Topological sort groups nodes into "layers": layer N contains all nodes whose dependencies are in layer < N.
- Each layer is executed concurrently with
ThreadPoolExecutor(max_workers=len(layer)).
- Per-run concurrency cap exposed as
max_parallel_nodes on the constructor (default: CPU count).
- Same deep-copy isolation pattern used in the recent
AgentRearrange.batch_run refactor to prevent shared-state bugs.
Files
swarms/structs/graph_workflow.py
Why
Pure latency improvement with no behavior change for serial graphs. DAGs with any width benefit immediately.
Problem
GraphWorkflowcurrently walks the topology sequentially even when the DAG has independent branches. If the graph isA -> B,A -> C,B -> D,C -> D, today B and C execute one after the other despite having no data dependency on each other.Proposed feature
Detect independent branches at run time and execute them concurrently using
ThreadPoolExecutor. A correctness-preserving pure latency win.Design sketch
ThreadPoolExecutor(max_workers=len(layer)).max_parallel_nodeson the constructor (default: CPU count).AgentRearrange.batch_runrefactor to prevent shared-state bugs.Files
swarms/structs/graph_workflow.pyWhy
Pure latency improvement with no behavior change for serial graphs. DAGs with any width benefit immediately.