From Slack: Parallel Nodes

Jithin Shaji asks:

In langgraph how do you make a certain router output start 2 nodes in parallel?

In order to have a node output parallel lines of work, you can either use the send api in order to output dynamic next steps: Graph API overview - Docs by LangChain

Another alternative is that if this parallel work is determined ahead of time, you can setup multiple edges coming from the same node to the parallel destinations.

A node can have multiple outgoing edges. If a node has multiple outgoing edges, all of those destination nodes will be executed in parallel as a part of the next superstep.

1 Like

Yeah, Set up a dummy node that returns the state, and then this dummy node will route to the 2 required nodes assume (A and B). So now A and B will run parallel once and if routed to A again, only A will run and not B.

Also does langchain need some barriers for parallel execution or does it handle it internally. For example A can be said to be a graph on its own and B redirects to END.