---
title: Warmup-Stable and Merge (WSM) Techniques
url: https://www.emergentmind.com/topics/warmup-stable-and-merge-wsm
type: topic
---

# Warmup-Stable and Merge (WSM) Techniques

Warmup-Stable and Merge (WSM) refers to a class of techniques across learning rate scheduling in large language model (LLM) pre-training [2507.17634], parallel merge algorithms [1303.4312], and metric geometry on merge trees [2111.02738]. Each instantiation involves dividing a process into an initial "warmup" or configuration phase, a "stable" or main operation phase, and a final "merge" or aggregation step—either for models, data, or structures. The WSM methodology emphasizes efficiency, stability, and interpretability.

## 1. WSM in Learning Rate Scheduling for LLMs

The WSM framework for large language model pre-training is a decay-free, post-hoc protocol that replaces conventional Warmup-Stable-Decay (WSD) learning rate schedules. Instead of decaying the learning rate over time, WSM consists of three successive phases: linear warmup, a constant-rate stable phase, and a model merge via checkpoint averaging.

The three phases are:
- **Warmup**: Linear increase of learning rate from 0 to $\mathrm{lr}_{\mathrm{peak}}$ over $T_\mathrm{warmup}$ steps.
- **Stable**: Continue training at $\mathrm{lr}_{\mathrm{peak}}$ without decay, possibly with an annealing dataset after $T_\mathrm{switch}$.
- **Merge**: Aggregate the parameters from the last $n$ checkpoints taken every $T_\mathrm{cpt}$ steps over a merge window $T_\mathrm{merge} = n \cdot T_\mathrm{cpt}$ using principled weighted averaging.

WSM establishes a rigorous equivalence between checkpoint merging and synthetic learning-rate decay. Specifically, for checkpoints $\{\theta_{t_1},\dots,\theta_{t_k}\}$ and nonnegative weights $\{\alpha_i\}$, the merged model computes
\[
W_{\mathrm{merged}} = \frac{\sum_{i=1}^k \alpha_i W_i}{\sum_{i=1}^k \alpha_i}.
\]
The optimal choice of weights $\{c_j\}$ recovers standard decay schemes, as shown by a general inverse mapping (Theorem 3.1 in [2507.17634]), e.g., uniform averaging for linear decay or 1-sqrt weights for inverse-square-root decay. This direct mapping of decay curves to discrete merging weights allows precise emulation of any standard schedule post-hoc.

Empirical evaluation on MATH, HumanEval, and MMLU-Pro benchmarks demonstrates that WSM consistently outperforms WSD (e.g., +3.5% on MATH, +5.5% on MMLU-Pro), highlighting that merge duration is the most critical hyperparameter, surpassing the impact of checkpoint interval and quantity.

## 2. WSM in Stable, Parallel Merging Algorithms

In parallel algorithms, WSM principles are embodied in perfectly load-balanced, stable merge procedures for sorted sequences [1303.4312]. The central innovation is the co-ranking algorithm, which, given sorted arrays $A[0..m-1]$ and $B[0..n-1]$, efficiently computes—via binary search—the precise input prefixes needed so that each processing element (PE) can independently and stably merge its assigned output block.

Steps:
1. **Warmup**: Compute co-ranks for the block boundaries using an $O(\log \min(m,n))$ search per boundary.
2. **Stable Main Work**: Each PE merges its contiguous subarrays independently, preserving input order (stability).
3. **Merge**: The full result is constructed by concatenating the merged blocks.

Every PE receives an (almost) equal-sized output interval and the input partition is determined such that all boundaries preserve stability. The algorithm achieves total work $O(m+n)$ and speedup $O(p)$ up to $p \leq (m+n)/\log \min(m,n)$. Stability is enforced inherently by the co-ranking conditions, with no extra cost or need for tie-breaking indices. Synchronization is minimized, requiring only local computation and transfer.

## 3. WSM as a Metric for Merge Trees

WSM also denotes a finitely stable edit distance for merge trees in topological data analysis [2111.02738]. Given two merge trees $(T,h_T)$ and $(T',h_{T'})$, WSM distance $d_{WSM}$ is defined as the minimum cost sum over finite sequences of allowed tree-edit operations (shrink/rescale, delete/insert, ghost, split), where edge-weight changes and deletions carry specified costs.

Key properties:
- **Stability**: $d_{WSM}$ is finitely stable. There exists a bound: $d_{WSM}(T,T') \leq 2 (\dim T + \dim T') d_I(T,T')$, where $d_I$ is the interleaving distance.
- **Metric Status**: $d_{WSM}$ is a metric (satisfies the triangle inequality).
- **Computation**: Calculated by solving a sequence of small binary linear programs, with overall complexity comparable to classical unordered tree distances.
- **Discriminativity**: WSM distinguishes subtle tree differences undetected by persistence diagram Wasserstein or bottleneck metrics.

WSM has demonstrated utility in curve regression, clustering, and biomedical imaging, where its finite stability and interpretability enable robust structure-aware comparisons.

## 4. Algorithmic and Theoretical Details

### Learning Rate Merging ([2507.17634])
For $k+1$ checkpoints $\theta_{n}, \ldots, \theta_{n+k}$ and weights $c_j$, the merged model equates to a decayed-sum of gradients:
\[
\hat\theta_{n+k} = \theta_n - \sum_{i=1}^k w_i g_{n+i-1}, \quad w_i = \sum_{j=i}^k c_j.
\]
Any decay curve $\{w_i\}$ yields unique non-negative checkpoint weights
\[
c_k = w_k,\quad
c_j = w_j - w_{j+1}\ (j=1,\dots,k-1),\quad
c_0 = 1-w_1.
\]
Approximations for linear, cosine, and 1-sqrt decays are explicit, enabling curvature-matched merging.

### Parallel Merge ([1303.4312])
For two ordered arrays $A$, $B$ and $p$ PEs:
- Divide $C[0..m+n-1]$ into $p$ output blocks.
- For block $[i_r,i_{r+1}-1]$ on PE $r$: Use co_rank to find $(j_r,k_r)$ such that stable_merge$(A[0..j_r-1], B[0..k_r-1])$ produces prefix $C[0..i_r-1]$.
- Each PE merges $A[j_r..j_{r+1}-1]$, $B[k_r..k_{r+1}-1]$ to $C[i_r..i_{r+1}-1]$.
- Time per PE: $O((m+n)/p + \log \min(m,n))$; total work optimal for $p \le (m+n)/\log \min(m,n)$.

### Merge Tree Metric ([2111.02738])
Given merge trees truncated at large height $K$, represented as weighted trees $(G, w_G)$:
- Edit operations (with costs) are shrink, delete/insert, ghost, split.
- The minimal sum over edit-paths gives $d_{WSM}$, which does not depend on $K$.
- Minimization over edge matchings $M$ yields:
\[
d_{WSM}(G, G') = \min_{M}\left\{
    \sum_{(e,e')\in M} |w_G(e)-w_{G'}(e')|
    + \sum_{e\not\in\pi_G(M)} w_G(e)
    + \sum_{e'\not\in\pi_{G'}(M)} w_{G'}(e')
\right\}.
\]

## 5. Comparative Performance, Stability, and Recommendations

Empirical investigations in LLM scheduling show WSM delivers consistent, often significant, improvements over WSD across tasks and fine-tuning scenarios [2507.17634]. Merge duration proves to be the dominant hyperparameter for performance, while the choice of decay curve (1-sqrt weights) and offline-to-online merge transition are robust recommendations. WSM is compatible with all major optimizers and decouples schedule selection from knowledge of $T_\mathrm{max}$.

In parallel merging [1303.4312], the WSM approach attains near-optimal work efficiency, ties stability to a simple invariant (never splitting equal-key blocks at block boundaries), and simplifies distributed implementation relative to previous multi-selection schemes.

For merge trees [2111.02738], $d_{WSM}$ offers an $O(N+M)$-stable metric that better reflects structural changes than both bottleneck and Wasserstein distances on persistence diagrams, with computational cost comparable to classical tree edit distances and no requirement for ad-hoc saddle corrections or index augmentations.

## 6. Applications and Extensions

- **LLM Pre-training and Fine-tuning**: Post-hoc model averaging using WSM yields better-performing end models without live LR decay, is suitable for schedule sweeps via checkpoint buffering, and generalizes to continual and curriculum learning scenarios [2507.17634].
- **High-performance Sorting and Merging**: WSM-style block partitioning and co-ranking facilitate linear scaling parallel merges in sorting and database applications on both shared-memory and distributed-memory systems [1303.4312].
- **Topological Data Summaries**: The WSM merge-tree metric is applied for shape-aware curve clustering, regression, and biomedical imaging comparisons, capitalizing on its stability and interpretability [2111.02738].

## 7. Summary Table: WSM Variants and Contexts

| Domain            | Core Operation             | Stability Notion    |
|-------------------|---------------------------|---------------------|
| LLM Scheduling    | Weighted checkpoint merge  | Emulation of LR decay|
| Parallel Algorithms| Blocked stable merge      | Input-order preservation|
| Merge Trees       | Weighted edit distance     | Finite metric stability|

These applications illustrate the broad utility of the Warmup-Stable and Merge paradigm as a foundation for post-hoc optimality, stability, and robust aggregation across machine learning, algorithms, and computational topology.

Source: https://www.emergentmind.com/topics/warmup-stable-and-merge-wsm