---
title: Branch-Solve-Merge (BSM) Paradigm
url: https://www.emergentmind.com/topics/branch-solve-merge-bsm
type: topic
---

# Branch-Solve-Merge (BSM) Paradigm

The Branch-Solve-Merge (BSM) paradigm refers to a structured approach to decomposing complex computational or reasoning tasks—whether in large language model (LLM) workflows or in computer architecture control flow—into three explicit stages: branching into parallel subtasks, independently solving these subtasks, and merging the independent solutions into a final coherent result. This meta-algorithm leverages modularization and parallelism to address challenges of planning, multi-criteria constraint satisfaction, and coherence, with formal instantiations in both LLM prompting frameworks [2310.15123] and dynamic control-path prediction in hardware pipelines [2005.14691].

## 1. Principles and High-Level Structure

BSM operates through three stages:

1. **Branch**: Decomposition of the primary task or decision point into $k$ explicit, parallel subtasks (or, in hardware, into two or more execution paths post-conditional).
2. **Solve**: Execution of each subtask (or path) in isolation, using either dedicated model prompts in LLMs or separate instruction streams in hardware.
3. **Merge**: Aggregation of partial results into a unified output, regaining global coherence or selecting the correct control path.

The canonical insight is that by partitioning complex tasks, each submodule handles a focused segment, thereby mitigating the loss of coherence, constraint violations, or suboptimal path recovery that plague monolithic approaches [2310.15123].

## 2. BSM in Large Language Model Workflows

In LLM applications, BSM is implemented as a prompt-based meta-algorithm to enhance compositional reasoning, multi-faceted evaluation, and constrained generation. The process recasts a single monolithic instruction into three subprograms parameterized by targeted prompts:

- **Branch Module**: Generates a list of up to $K$ task-specific subproblems (e.g., evaluation criteria, concept clusters), sampling $k\leq K$ in practice.
- **Solve Module**: Independently prompts the base LLM to solve each $x^{(i)}$ subtask, returning $y^{(i)}$ solutions or judgments.
- **Merge Module**: Fuses $\{y^{(1)},\dots,y^{(k)}\}$ into a final outcome, either by deterministic aggregation (e.g., sum of scores) or via a neural prompt to the LLM for synthesis [2310.15123].

Formal notation for the pipeline is:
\[
\text{Branch: } X = \{x^{(1)}, \ldots, x^{(k)}\} \sim p_\theta(X | \text{prompt}_\text{branch}(x))
\]
\[
\text{Solve: } y^{(i)} \sim p_\theta(y | \text{prompt}_\text{solve}(x^{(i)}))
\]
\[
\text{Merge: } y \sim p_\theta(y | \text{prompt}_\text{merge}(\{y^{(i)}\}))
\]
Implementation typically uses greedy decoding for consistency (temperature $=0$), zero-shot prompting, and covers branching factors $K=3$–$5$ depending on complexity [2310.15123].

## 3. BSM in Dynamic Control Path Prediction

In out-of-order microarchitectures, BSM is instantiated by treating unresolved conditional branches as explicit branch points:
- **Branch**: Upon encountering a hard-to-predict branch, both successor paths are fetched and executed speculatively.
- **Solve**: Execution proceeds until a predicted merge point is encountered, determined dynamically by a merge point predictor.
- **Merge**: At the predicted merge point, correct execution is established and control reconverges; incorrect merges incur minimal penalty compared to classic mispredict flushes [2005.14691].

Dynamic Merge Point Prediction (DMPP) augments the BSM approach with learned hardware structures:
- Merge Point Predictor Table (MPPT)
- Wrong-Path Buffer (WPB)
- Update List

A confidence–cost system decides whether to invoke DMPP or fall back to traditional branch prediction, based on measured branch prediction confidence and resolution latency [2005.14691].

## 4. Algorithmic Details and Pseudocode

BSM implementation is formalized as:

```python
def BRANCH(x):
    # Generate k sub-tasks from task x
    X = model(prompt_branch(x))
    return X  # up to K items

def SOLVE(x_i):
    # Solve subtask x_i
    y_i = model(prompt_solve(x_i))
    return y_i

def MERGE(y_list):
    # Merge solutions into the final output
    y = model(prompt_merge(y_list))
    return y

def BSM(x):
    sub_tasks = BRANCH(x)
    results = [SOLVE(xi) for xi in sub_tasks]
    final_output = MERGE(results)
    return final_output
```
Variants use different aggregation strategies in MERGE, e.g., score summing for evaluation, neural fusion for text generation [2310.15123].

Hardware pseudocode for WPB and MPPT updates in the DMPP context is similarly step-structured for managing speculative execution and merge recovery [2005.14691].

## 5. Empirical Results and Benchmarks

### LLM BSM

| Model            | Domain    | Baseline Ag | BSM Ag | Position Bias Δ | Length Bias Δ |
|------------------|-----------|-------------|--------|----------------|--------------|
| Vicuna-33B       | Writing   | 0.51        | 0.56   | –10.7%         | –5.2%        |
| LLaMA-2-70B      | Writing   | 0.43        | 0.55   | –34.4%         | –15.8%       |
| GPT-4            | Writing   | 0.59        | 0.62   | –0.3%          | –2.3%        |

On constrained story generation:
- LLaMA-2-70B: All-Present rises 21.0%→28.0%; missing concepts per story drops 26.6→14.7 [2310.15123].
- BSM produced up to +26% absolute agreement with human evaluators and up to 50% reduction in position or length bias.

### DMPP/BSM in Hardware

- Merge-point location accuracy: 95%
- Coverage: 58% of all branch mispredictions replaced with correct merge point predictions
- MPKI reduction: 43% compared to TAGE-only baseline
- Up to +5% IPC speedup on branch-heavy tasks [2005.14691]

The table structures—MPPT, WPB, Update List—require modest hardware resources and integrate directly into the BSM pipeline, as the solve stage for hard conditional branches.

## 6. Representative Applications and Extensions

**LLM Applications**
- Model evaluation: Decomposition into per-criterion judgments substantially improves LLM-human agreement and mitigates order-dependent biases.
- Constrained text generation: Partitioning complex concept inclusion tasks yields higher-constrained satisfaction and improved narrative coherence.

**Hardware Applications**
- Misprediction recovery: Control-independent engines benefit from dynamic merge prediction by reducing wasted fetch and execute cycles, especially on hard-to-predict branches.

**Extensions**
- Recursive/Hierarchical BSM: Re-branch any subtask that still violates constraints, at increased compute or call cost.
- Hybrid merge strategies: Non-neural versus neural (prompt-based) merging.
- Self-consistency: Multiple solve samples per subtask can further reduce evaluation bias [2310.15123].

## 7. Practical Implementation Guidance and Limitations

**LLM BSM Implementation**
- Effective with both zero-shot and few-shot prompting.
- Parallelization of solve stage is straightforward, making wall-clock time proportional to branch, not total subtasks.
- Sensitivity to branching factor: K=3–5 effective; overly fine-grained decomposition yields diminishing returns.
- Robust to partial failures: Subtask timeouts are handled as neutral contributions or by re-invocation [2310.15123].

**Hardware BSM Integration**
- MPPT, WPB, and Update List accessed/updated in a single cycle, with <1% WPB false-negatives in simulation.
- Confidence–Cost gating ensures DMPP overheads are only incurred for high-impact branches.

**Limitations and Open Questions**
- BSM's efficacy is bounded by the quality of decomposition; insufficient or excessive branching can underperform.
- Dynamic merge prediction relies on high merge-point location accuracy; misprediction costs, while lower than full flush, are nonzero.
- Recursive decomposition and multi-stage merges introduce additional computation and complexity, potentially limiting real-time or low-latency applications.

## References

- "Branch-Solve-Merge Improves Large Language Model Evaluation and Generation" [2310.15123]
- "Dynamic Merge Point Prediction" [2005.14691]

Source: https://www.emergentmind.com/topics/branch-solve-merge-bsm