Skip to content

[feat][graph_workflow][parallel branch execution] #1559

@kyegomez

Description

@kyegomez

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions