It is not truly parallel #906

Closed
opened 2026-02-20 17:42:18 -05:00 by yindo · 5 comments
Owner

Originally created by @dcdmm on GitHub (Aug 8, 2025).

Checked other resources

  • This is a bug, not a usage question. For questions, please use the LangChain Forum (https://forum.langchain.com/).
  • I added a clear and detailed title that summarizes the issue.
  • I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example).
  • I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue.

Example Code

from IPython.display import Image, display
from typing import Any
from typing_extensions import TypedDict
from langgraph.graph import StateGraph, START, END
import time
from typing import Annotated
from operator import add

class State(TypedDict):
    state: Annotated[list, add]

class ReturnNodeValue:
    def __init__(self, node_secret: str, delay: float = 0.0):
        self._value = node_secret
        self._delay = delay

    def __call__(self, state: State) -> Any:
        time.sleep(self._delay) 
        print(f"Adding {self._value} to {state['state']}")
        return {"state": [self._value]}

builder_par = StateGraph(State)
builder_par.add_node("a", ReturnNodeValue("I'm A"))
builder_par.add_node("b", ReturnNodeValue("I'm B", 0.1))
builder_par.add_node("b2", ReturnNodeValue("I'm B2", 0.2))
builder_par.add_node("c", ReturnNodeValue("I'm C", 0.5))
builder_par.add_node("d", ReturnNodeValue("I'm D"))
builder_par.add_edge(START, "a")
builder_par.add_edge("a", "b")
builder_par.add_edge("a", "c")
builder_par.add_edge("b", "b2")
builder_par.add_edge("b2", "d")
builder_par.add_edge("c", "d")
builder_par.add_edge("d", END)
graph_par = builder_par.compile()

display(Image(graph_par.get_graph().draw_mermaid_png()))

start_time_par = time.time()
print(graph_par.invoke({"state": []}))  
end_time_par = time.time()
print(end_time_par - start_time_par) 

Error Message and Stack Trace (if applicable)


Description

According to the graph structure, node b2 only needs to wait for node b to finish executing, and does not need to wait for node c to finish executing, so the time consumed should be 0.5 seconds instead of 0.8 seconds.

System Info

pip install -U langgraph

Originally created by @dcdmm on GitHub (Aug 8, 2025). ### Checked other resources - [x] This is a bug, not a usage question. For questions, please use the LangChain Forum (https://forum.langchain.com/). - [x] I added a clear and detailed title that summarizes the issue. - [x] I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example). - [x] I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue. ### Example Code ```python from IPython.display import Image, display from typing import Any from typing_extensions import TypedDict from langgraph.graph import StateGraph, START, END import time from typing import Annotated from operator import add class State(TypedDict): state: Annotated[list, add] class ReturnNodeValue: def __init__(self, node_secret: str, delay: float = 0.0): self._value = node_secret self._delay = delay def __call__(self, state: State) -> Any: time.sleep(self._delay) print(f"Adding {self._value} to {state['state']}") return {"state": [self._value]} builder_par = StateGraph(State) builder_par.add_node("a", ReturnNodeValue("I'm A")) builder_par.add_node("b", ReturnNodeValue("I'm B", 0.1)) builder_par.add_node("b2", ReturnNodeValue("I'm B2", 0.2)) builder_par.add_node("c", ReturnNodeValue("I'm C", 0.5)) builder_par.add_node("d", ReturnNodeValue("I'm D")) builder_par.add_edge(START, "a") builder_par.add_edge("a", "b") builder_par.add_edge("a", "c") builder_par.add_edge("b", "b2") builder_par.add_edge("b2", "d") builder_par.add_edge("c", "d") builder_par.add_edge("d", END) graph_par = builder_par.compile() display(Image(graph_par.get_graph().draw_mermaid_png())) start_time_par = time.time() print(graph_par.invoke({"state": []})) end_time_par = time.time() print(end_time_par - start_time_par) ``` ### Error Message and Stack Trace (if applicable) ```shell ``` ### Description According to the graph structure, node b2 only needs to wait for node b to finish executing, and does not need to wait for node c to finish executing, so the time consumed should be 0.5 seconds instead of 0.8 seconds. ### System Info pip install -U langgraph
yindo added the bugpending labels 2026-02-20 17:42:18 -05:00
yindo closed this issue 2026-02-20 17:42:18 -05:00
Author
Owner

@dcdmm commented on GitHub (Aug 8, 2025):

Shouldn't (b, b2) and c be parallel? Actually, only b and c are parallel.

@dcdmm commented on GitHub (Aug 8, 2025): Shouldn't (b, b2) and c be parallel? Actually, only b and c are parallel.
Author
Owner

@hinthornw commented on GitHub (Aug 8, 2025):

Different supersteps. Read the docs.

@hinthornw commented on GitHub (Aug 8, 2025): Different supersteps. Read the docs.
Author
Owner

@dcdmm commented on GitHub (Aug 8, 2025):

Different supersteps. Read the docs.

I don't understand what you mean, but I know this can be solved by subgraph

@dcdmm commented on GitHub (Aug 8, 2025): > Different supersteps. Read the docs. I don't understand what you mean, but I know this can be solved by subgraph
Author
Owner
@hinthornw commented on GitHub (Aug 8, 2025): Example: https://langchain-ai.github.io/langgraph/how-tos/graph-api/?h=superstep#run-graph-nodes-in-parallel
Author
Owner

@dcdmm commented on GitHub (Aug 8, 2025):

Example: https://langchain-ai.github.io/langgraph/how-tos/graph-api/?h=superstep#run-graph-nodes-in-parallel

So the parallel strategy here is problematic and must be done through subgraphs

@dcdmm commented on GitHub (Aug 8, 2025): > Example: https://langchain-ai.github.io/langgraph/how-tos/graph-api/?h=superstep#run-graph-nodes-in-parallel So the parallel strategy here is problematic and must be done through subgraphs
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#906