---
title: DiLoCo-based Distributed Merging
url: https://www.emergentmind.com/topics/diloco-based-distributed-merging
type: topic
---

# DiLoCo-based Distributed Merging

DiLoCo-based distributed merging denotes a family of low-communication training methods derived from Distributed Low-Communication training (DiLoCo), in which multiple workers execute many local optimization steps before periodically reconciling their models through a merge in parameter space rather than through per-step gradient all-reduce. In its canonical form, each worker starts from a shared model, performs \(H\) local inner-optimizer steps, forms a parameter delta relative to the last synchronized model, averages those deltas across workers, and applies an outer optimizer—typically SGD with Nesterov momentum—to obtain the next global model. The resulting design is neither standard data-parallel training nor one-shot checkpoint averaging; it is an online, repeated model-merging procedure embedded inside large-scale pretraining [2311.08105][2503.09799].

## 1. Formal structure of the merge

DiLoCo operates on two nested timescales: an inner loop of local training and an outer loop of synchronization. With \(K\) workers and synchronization interval \(H\), worker \(i\) performs \(H\) local updates on its shard \(\mathcal D_i\) before any cross-worker communication. A representative formulation writes the local update as
\[
\mathcal{L} \gets f_\theta(x,y;\theta_i^{(t)}), \qquad
g_i^{(n)} = \nabla_\theta \mathcal{L}, \qquad
\theta_i^{(t)} \gets \mathrm{InnerOpt}(\theta_i^{(t)}, \nabla \mathcal L).
\]
After those \(H\) steps, worker \(i\) forms a parameter-space displacement relative to the last synchronized reference,
\[
\Delta_i^{(t)} = \theta^{(t-H)} - \theta_i^{t},
\]
and the outer merge averages these displacements,
\[
\Delta^{(t)} = \frac{1}{K}\sum_{i=1}^{K}\Delta_i^{(t)}.
\]
The global model is then updated by an outer optimizer rather than by direct parameter replacement. In the MuLoCo specification, the outer optimizer is SGD with Nesterov momentum:
\[
u^{(t)} = \mu u^{(t-H)} + \eta_{\text{out}}\Delta^{(t)}, \qquad
\theta^{(t)} = \theta^{(t-1)} - \mu u^{(t)} - \eta_{\text{out}}\Delta^{(t)}.
\]
This is the core merge rule of the family: average worker deltas, then transform that average through an outer momentum step [2505.23725].

DiLoCo is closely related to FedAvg and local SGD, but it is not identical to either. The original formulation states that when \(OuterOpt\) is SGD, the method is equivalent to classical Federated Averaging, and when \(T=1\) it reduces to one-shot model souping. In ordinary use, however, the outer optimizer is Nesterov momentum and the merge is optimizer-mediated rather than plain arithmetic averaging. This distinguishes DiLoCo-based merging from both step-synchronous gradient averaging and post-hoc checkpoint interpolation [2311.08105].

## 2. What is merged, and what is not

The defining synchronized object in DiLoCo-based methods is a parameter delta or pseudo-gradient, not the raw minibatch gradient and not the full local optimizer state. In the original formulation the communicated quantity is
\[
\Delta^{(t)} = \frac{1}{k}\sum_{i=1}^k(\theta^{(t-1)}-\theta_i^{(t)}),
\]
while OpenDiLoCo implements the same idea by explicitly computing
\[
g_i^{\text{pseudo}} = \theta^{(t)} - \theta_i^{(t+H)}
\]
and placing that tensor into each parameter’s `param.grad` before all-reduce and outer optimization. The merge is therefore best understood as aggregation of model displacements in parameter space, followed by an outer optimizer step, rather than interpolation of whole checkpoints in the narrow FedAvg sense [2407.07852].

This separation of roles is operationally important. Inner optimizer states remain local. The original DiLoCo study explicitly reports that synchronizing the inner Adam state did not lead to significant improvements while increasing communication cost by \(\times 3\), so each replica keeps its own first and second moments. The outer optimizer state, by contrast, is associated with the global merge trajectory. A DiLoCo-based merge therefore has three logically distinct state types: local model parameters, local inner-optimizer state, and global outer-optimizer state. Only the parameter-space delta is the mandatory synchronization payload [2311.08105].

A similar separation persists across later variants. MuLoCo changes the inner optimizer from AdamW to Muon on hidden layers, but preserves the DiLoCo-style synchronization protocol. SparseLoCo replaces global outer momentum with local outer error-feedback accumulators, yet still merges compressed approximations to pseudo-gradients. Streaming and asynchronous variants fragment, delay, or reweight the synchronized object, but they continue to operate on model-difference signals rather than on per-step gradients [2505.23725][2508.15706].

## 3. Communication rationale and scaling behavior

The principal systems motivation for DiLoCo-based merging is that wide-area or cross-cluster training is constrained more by communication frequency and synchronization barriers than by raw floating-point throughput. Standard data-parallel training requires cross-worker communication every step; DiLoCo reduces that frequency by a factor of \(H\). In the original 8-worker C4 experiments with default \(H=500\), DiLoCo communicated \(500\times\) less often than per-step synchronization while matching or slightly outperforming the fully synchronous 8\(\times\)-batch baseline on a 150M-parameter transformer [2311.08105].

Subsequent scaling-law analysis treated DiLoCo itself as a scalable merge-based optimizer. In that study, synchronization cadence was usually fixed at \(H=30\), though \(H\in\{1,5,10,30,100,300\}\) was also examined. The reported behavior was that \(H=1\) performed worst, loss generally increased as \(H\) increased, and the degradation from infrequent synchronization became less pronounced as model size grew. The study also fit joint laws such as
\[
L(N,M) \approx 19.226\,N^{-0.0985}M^{0.0116},
\]
and emphasized that the optimal outer learning rate depends mainly on replica count \(M\) and cadence \(H\), not strongly on model size \(N\). This suggests that DiLoCo-based merging is not merely a bandwidth workaround; it has a scale-dependent optimization regime of its own [2503.09799].

OpenDiLoCo translated this regime into an operational framework for globally distributed training. It trained across two continents and three countries, reported \(90\text{–}95\%\) compute utilization, and observed that workers trained independently for about \(67.5\) minutes before communicating, with outer all-reduce taking about \(300\) seconds on average and accounting for only \(6.9\%\) of training time. It also showed that pseudo-gradients can be all-reduced in FP16 without noticeable performance hit. These results established DiLoCo-based merging as a concrete systems strategy for poor-bandwidth interconnects rather than a purely algorithmic curiosity [2407.07852].

## 4. Compression of the merge payload

Once communication frequency is reduced, the next bottleneck is the size of the synchronized delta itself. Standard DiLoCo still all-reduces a dense model-sized update at every outer round. Later work therefore focused on compressing the worker-local delta before aggregation. A generic compressed pipeline is
\[
\text{local train} \rightarrow \text{form local delta} \rightarrow \text{error feedback} \rightarrow \text{compress locally} \rightarrow \text{all-reduce} \rightarrow \text{outer update}.
\]
The compression operators studied include Top-\(k\) sparsification, quantization to \(2\), \(4\), or \(8\) bits, DCT Top-\(k\), and random-\(k\). Error feedback is implemented through a residual accumulator
\[
e_i^{(t)} \gets \beta e_i^{(t-H)} + \Delta_i^{(t)}, \qquad
\widehat{\Delta}_i^{(t)} = C(e_i^{(t)}), \qquad
e_i^{(t+1)} \gets e_i^{(t)} - \widehat{\Delta}_i^{(t)},
\]
and all compressed runs improve when error feedback is enabled [2505.23725].

MuLoCo is the clearest example of optimizer-dependent compressibility. It preserves the DiLoCo merge protocol but replaces AdamW in the local loop with Muon on hidden layers and AdamW on embeddings and output layers. The study reports that MuLoCo with error feedback can compress communicated deltas to \(2\) bits with next to no performance degradation, and that MuLoCo with \(2\)-bit quantization and error feedback outperforms standard AdamW-DiLoCo while communicating \(8\times\) less and having identical memory complexity. The memory accounting is also explicit: DiLoCo with AdamW inner optimization uses \(2\times\) parameter memory for optimizer accumulators, DiLoCo+EF uses \(3\times\), MuLoCo uses \(1\times\), and MuLoCo+EF uses \(2\times\) [2505.23725].

SparseLoCo pushes the same line of development further by combining outer error feedback, Top-\(k\) sparsification, and low-bit quantization. Its core outer rule is
\[
e_r^{(t)} \leftarrow \beta e_r^{(t)} + \Delta_r^{(t)}, \qquad
\hat{\Delta}_r^{(t)} \leftarrow Q\!\left(Top\text{-}k(e_r^{(t)})\right), \qquad
e_r^{(t+1)} \leftarrow e_r^{(t)} - \hat{\Delta}_r^{(t)}.
\]
In a 512M-parameter LLaMA-style setup on DCLM with \(R=8\), SparseLoCo at \(3.12\%\) density and \(2\)-bit quantization reported loss \(2.73\), pseudo-gradient size \(17\) MB, and \(163\) synchronizations, compared with dense DiLoCo loss \(2.76\), pseudo-gradient size \(0.48\) GB, and the same \(163\) synchronizations. The paper further states that sparse aggregation can actually improve model performance, whereas random-\(k\) is markedly worse than Top-\(k\) [2508.15706].

## 5. Streaming, delay, and overlap-aware merging

A separate line of work addresses not the number of communicated bits alone, but the blocking nature of the merge barrier. Streaming DiLoCo partitions the model into fragments \(p\in\{1,\dots,P\}\) and synchronizes fragments at staggered offsets \(t_p\), so that fragment \(p\) is synchronized when \(t-t_p \bmod H = 0\). For fragment \(p\), worker \(m\) computes
\[
\Delta^{(t)}_{m,p} = \theta^{(t-H)}_{m,p} - \theta^{(t)}_{m,p},
\qquad
\Delta^{(t)}_p = \frac{1}{M}\sum_{m=1}^M \Delta^{(t)}_{m,p},
\]
then applies the delayed synchronized fragment through
\[
\theta_{m,p}^{(t)} \gets \alpha \theta^{(t)}_{m,p} + (1-\alpha)\tilde{\theta}^{(t)}_{m,p}.
\]
This changes the merge from a monolithic full-model event into a fragment-wise, staggered, and partially delayed reconciliation. Empirically, the paper reported that streaming plus overlap plus FP4 communication can reduce required bandwidth by two orders of magnitude while preserving quality close to DiLoCo and data parallelism [2501.18512].

Eager Updates reinterprets the delayed outer merge more explicitly. Instead of applying a wholly stale averaged delta, it constructs a worker-specific surrogate
\[
\tilde{\Delta}_m^{(t)} =
\frac{1}{M}\big(\Delta_m^{(t)}-\Delta_m^{(t-H)}\big)+\Delta^{(t-H)}
=
\frac{1}{M}\left(\Delta_m^{(t)}+\sum_{m'\neq m}\Delta_{m'}^{(t-H)}\right).
\]
The merge is thus exact-current for the local worker’s own contribution and one-outer-step stale for all remote contributions. On a 500M model, one-outer-step eager overlap reached evaluation loss \(2.69\) versus \(2.67\) for no overlap, while naive one-step-delayed merging without the eager correction degraded to \(3.01\) unless the outer learning rate was lowered [2502.12996].

CoCoDC retains the fragment-wise non-blocking merge of Streaming DiLoCo but adds explicit delay compensation and adaptive transmission. It models the desired current-time global fragment by Taylor expansion from the stale synchronized fragment and uses a corrected local rate
\[
g^{corr,m}_{p,t_p}
=
g^m_{p,t_p}
+
\lambda\cdot g^m_{p,t_p}\odot g^m_{p,t_p}\odot \frac{\Delta \theta^m_{p,t_p}}{H},
\]
followed by
\[
\theta^{m}_{p,t_l} \leftarrow \theta^{g}_{p,t_p} + g^{corr,m}_{p,t_p}\tau.
\]
It also schedules fragment transmissions by an impact score
\[
R_{p,t_p} = \|\Delta \theta^g_p\|_2 / I_p
\]
and reported up to \(21.0\%\) fewer training steps than Streaming DiLoCo to reach comparable perplexity in a cross-region simulation [2504.17672].

## 6. Asynchrony, decentralization, and unresolved limitations

Recent work generalizes DiLoCo-based distributed merging beyond synchronous or near-synchronous periodic averaging. HeLoCo studies asynchronous low-communication training under heterogeneous devices and non-IID data, where workers return stale pseudo-gradients
\[
\Delta_i^{(s_i)} = \bar{\theta}_{s_i} - \theta_{i,H}^{(s_i)}
\]
with staleness \(\tau_i(t)=t-s_i\). It uses outer momentum as a reference direction and applies block-wise correction before merging: aligned blocks are preserved, anti-aligned blocks are attenuated, and weakly aligned blocks are rotated toward momentum. The method reported up to \(7.5\%\) improvement over asynchronous Nesterov at fixed token budget, up to \(3.3\%\) over asynchronous momentum look-ahead, and up to \(22.1\%\) over the synchronous baseline under severe system heterogeneity [2606.00271].

Other variants relax exact synchronization more structurally. Factored Gossip DiLoCo factorizes outer synchronization into a non-blocking Mix1 on prior model states and a blocking Mix2 on current outer pseudo-gradients, turning exact global averaging into a tunable approximate-mixing process. Decoupled DiLoCo replaces lock-step rounds with a central synchronizer that merges fragment pulls from a minimum quorum of learners, uses an adaptive grace window, and weights learner contributions by processed tokens. DiLoCoX extends DiLoCo-style pseudo-gradient merging to 100B-scale decentralized training through pipeline parallelism, one-step-delayed overlap, distributed outer optimizer state, and low-rank plus quantized compression; it reported pretraining a 107B model over a \(1\) Gbps network with a claimed \(357\times\) speedup over vanilla AllReduce while maintaining negligible degradation in convergence [2606.22768][2604.21428][2506.21263].

The design space also now includes modular and architecture-aware variants. DiPaCo adapts DiLoCo-style merging to path-composed modular models, where only workers sharing a module participate in merging that module, and the synchronized quantity becomes a module-wise outer gradient rather than a monolithic model delta. This indicates that DiLoCo-based merging is compatible not only with dense replicated models but also with partially overlapping parameterizations [2403.10616].

The main empirical caution is that stable pretraining loss does not guarantee preservation of downstream-capable representations. In a nanochat-based study, DiLoCo achieved stable convergence and approximately \(100\times\) communication reduction in pretraining, yet after mid-training and SFT it underperformed standard DDP on MMLU, GSM8K, HumanEval, and ChatCORE. The paper reported, for example, mid-training ChatCORE \(0.1060\) for DDP versus \(0.0192\) for DiLoCo and \(0.0165\) for a hybrid that switched from DiLoCo pretraining back to DDP; after SFT the corresponding values were \(0.1190\), \(0.0157\), and \(0.0140\). It further stated that using DiLoCo-pretrained weights and running later stages with DDP fails to recover performance, interpreting this as irreversible representation drift from asynchronous or delayed updates [2511.13761].

Taken together, these results define DiLoCo-based distributed merging as a broad research program rather than a single algorithm. The shared core is periodic reconciliation of locally trained model trajectories through parameter-space deltas and an outer optimizer. The main axes of variation are the synchronized object, the timing and topology of the merge, the degree of compression, the treatment of staleness, and the evaluation criterion used to judge merge quality. A plausible implication is that future progress will depend as much on representational and downstream diagnostics as on communication volume and pretraining loss alone.

Source: https://www.emergentmind.com/topics/diloco-based-distributed-merging