š¤ļø Parallelization
<div align="center">
Overview
š Home āŗ Workflows āŗ š¤ļø Parallelization
ā 02 Routing āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā 04 Orchestrator-Workers ā
</div>š¤ļø Parallelization
TL;DR: Execute independent tasks simultaneously and aggregate outputs. Two flavors: Sectioning (split data, combine all) and Voting (same task, pick best).
Core Concept
%%{init: {'theme': 'base', 'themeVariables': {'lineColor': '#64748b'}}}%%
flowchart LR
classDef user fill:#6366f1,stroke:#4f46e5,stroke-width:2px,color:#ffffff
classDef main fill:#8b5cf6,stroke:#7c3aed,stroke-width:2px,color:#ffffff
classDef parallel fill:#3b82f6,stroke:#2563eb,stroke-width:2px,color:#ffffff
IN["šāāļøš„"]:::user --> SPLIT["šš Split"]:::main
SPLIT -->|"ššŖŗ"| A["š¦ā”"]:::parallel
SPLIT -->|"ššŖŗ"| B["š¦ā”"]:::parallel
SPLIT -->|"ššŖŗ"| C["š¦ā”"]:::parallel
A -->|"š¦š¤"| MERGE["šš Merge"]:::main
B -->|"š¦š¤"| MERGE
C -->|"š¦š¤"| MERGE
MERGE -->|"šš¤"| OUT["šāāļøš¤"]:::user
Key Insight
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā ā ļø IMPORTANT: Parallelization vs Orchestrator-Workers ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¤
ā ā
ā In Parallelization, all spawned subagents are IDENTICAL. ā
ā Same prompt, same capabilities. They are INTERCHANGEABLE. ā
ā ā
ā š¤ļø Parallelization: š¦ā” = š¦ā” = š¦ā” (clones) ā
ā š¦ Orchestrator-Workers: š¦š ā š¦ā” ā š¦šØ (specialists) ā
ā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Characteristics
| Property | Value |
|---|---|
| Complexity | Medium |
| Parallelism | High |
| Human-Loop | Optional |
| Iteration | None |
2 Types of Parallelization
Type 1: š¤ļø Sectioning (Split DATA)
Break a task into independent subtasks run in parallel, then combine ALL results.
%%{init: {'theme': 'base', 'themeVariables': {'lineColor': '#64748b'}}}%%
flowchart LR
classDef user fill:#6366f1,stroke:#4f46e5,stroke-width:2px,color:#ffffff
classDef main fill:#8b5cf6,stroke:#7c3aed,stroke-width:2px,color:#ffffff
classDef parallel fill:#3b82f6,stroke:#2563eb,stroke-width:2px,color:#ffffff
S_IN["šāāļøš„ 100 files"]:::user --> S_SPLIT["šš¤ļø"]:::main
S_SPLIT -->|"ššŖŗ"| S1["š¦ā” Files 1-50"]:::parallel
S_SPLIT -->|"ššŖŗ"| S2["š¦ā” Files 51-100"]:::parallel
S1 -->|"š¦š¤"| S_MERGE["šš Combine ALL"]:::main
S2 -->|"š¦š¤"| S_MERGE
S_MERGE -->|"šš¤"| S_OUT["šāāļøš¤"]:::user
Examples:
- Guardrails: One instance processes queries, another screens for inappropriate content
- Evals: Each LLM call evaluates a different aspect of model performance
Type 2: š³ļø Voting (Same TASK, pick BEST)
Run the same task multiple times to get diverse outputs, then select the best.
%%{init: {'theme': 'base', 'themeVariables': {'lineColor': '#64748b'}}}%%
flowchart LR
classDef user fill:#6366f1,stroke:#4f46e5,stroke-width:2px,color:#ffffff
classDef main fill:#8b5cf6,stroke:#7c3aed,stroke-width:2px,color:#ffffff
classDef parallel fill:#3b82f6,stroke:#2563eb,stroke-width:2px,color:#ffffff
classDef success fill:#10b981,stroke:#059669,stroke-width:2px,color:#ffffff
V_IN["šāāļøš„ Write headline"]:::user --> V_COPY["šš 3 attempts"]:::main
V_COPY -->|"ššŖŗ"| V1["š¦ā” Version A"]:::parallel
V_COPY -->|"ššŖŗ"| V2["š¦ā” Version B"]:::parallel
V_COPY -->|"ššŖŗ"| V3["š¦ā” Version C"]:::parallel
V1 -->|"š¦š¤"| VOTE{"šš³ļø Compare"}:::main
V2 -->|"š¦š¤"| VOTE
V3 -->|"š¦š¤"| VOTE
VOTE -->|"šā
B wins"| BEST["š Best"]:::success
Voting Selection Strategies
| Strategy | How It Works | Best For |
|---|---|---|
| LLM Judge | Main Agent compares outputs and selects best | Creative content, subjective quality |
| Scoring Rubric | Each output scored against criteria, highest wins | Code review, compliance checks |
| Consensus | Majority agreement required | Critical decisions, validation |
| Weighted Vote | Outputs weighted by model capability | Mixed model ensemble |
Summary
| Type | Workers | Input | Output |
|---|---|---|---|
| š¤ļø Sectioning | IDENTICAL | Different DATA chunks | Combine ALL |
| š³ļø Voting | IDENTICAL | Same DATA | Pick ONE best |
When to Use
Parallelization is effective when the divided subtasks can be parallelized for speed, or when multiple perspectives are needed for higher confidence results.
When NOT to Use
- Tasks depend on each other's output
- Sequential order matters
- Limited resources
Variant: š Parallel Tool Calling
Execute multiple independent š§ tool calls in a single message for efficiency.
%%{init: {'theme': 'base', 'themeVariables': {'lineColor': '#64748b'}}}%%
flowchart TB
classDef main fill:#8b5cf6,stroke:#7c3aed,stroke-width:2px,color:#ffffff
classDef state fill:#10b981,stroke:#059669,stroke-width:2px,color:#ffffff
MA["š Main Agent"]:::main -->|Single Message| TOOLS
subgraph TOOLS["š Parallel Tool Calls"]
T1["š§ Read file1.ts"]
T2["š§ Read file2.ts"]
T3["š§ Read file3.ts"]
end
T1 --> RESULTS["ā
All Results"]:::state
T2 --> RESULTS
T3 --> RESULTS
RESULTS --> MA
classDef toolbox fill:#dbeafe,stroke:#3b82f6,stroke-width:2px,color:#1e40af
TOOLS:::toolbox
Variant: 𧬠Master-Clone
Spawn multiple isolated š¦ instances handling independent domains with no shared state.
Key Characteristics
| Property | Value |
|---|---|
| Isolation | Complete - each clone has own context |
| State Sharing | None - clones cannot communicate |
| Best For | Independent domains, parallel generation |
| Merge Strategy | Combine all outputs (no conflict resolution needed) |
Diagram
%%{init: {'theme': 'base', 'themeVariables': {'lineColor': '#64748b'}}}%%
flowchart TB
classDef main fill:#8b5cf6,stroke:#7c3aed,stroke-width:2px,color:#ffffff
classDef subagent fill:#ec4899,stroke:#db2777,stroke-width:2px,color:#ffffff
classDef state fill:#10b981,stroke:#059669,stroke-width:2px,color:#ffffff
MA["š Main Agent"]:::main
MA -->|"Context: fr-FR"| C1["š¦ Clone: fr-FR"]:::subagent
MA -->|"Context: es-ES"| C2["š¦ Clone: es-ES"]:::subagent
MA -->|"Context: de-DE"| C3["š¦ Clone: de-DE"]:::subagent
C1 -->|9 files| R1[Result: fr-FR]
C2 -->|9 files| R2[Result: es-ES]
C3 -->|9 files| R3[Result: de-DE]
R1 --> MERGE["ā
Merge Results"]:::state
R2 --> MERGE
R3 --> MERGE
MERGE --> MA
When to Use Master-Clone
| Use Case | Why Master-Clone? |
|---|---|
| Multi-locale generation | Each locale is independent domain |
| Multi-platform builds | iOS, Android, Web don't share state |
| Parallel documentation | Each doc section is self-contained |
| A/B test generation | Variants shouldn't influence each other |
| Multi-tenant operations | Tenant data must be isolated |
<div align="center">
ā 02 Routing āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā 04 Orchestrator-Workers ā
</div>