kyegomez/swarms

[feat][graph_workflow][parallel branch execution]

Closed

#1,559 opened on Apr 21, 2026

 (1 comment) (0 reactions) (0 assignees)Python (986 forks)github user discovery
FEATenhancementgood first issue

Repository metrics

Stars
 (7,040 stars)
PR merge metrics
 (Avg merge 3d 5h) (17 merged PRs in 30d)

Description

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.

Contributor guide