跨大都市区域的分布式 LLM 训练:MaxText 中的流式 DiLoCo
原题Distributed LLM Training Across Metros: Streaming DiLoCo in MaxText
推荐理由Google 将流式 DiLoCo 做进 MaxText,读者可对照跨城通信、训练吞吐和模型收敛的取舍。
读前速览
Google 在 MaxText 中推出流式 DiLoCo,这是一种分布式优化算法,通过持续传输参数片段取代大规模的周期性权重同步,从而在地理位置分散的数据中心之间高效训练 LLM。
DiLoCo 通过内外循环将本地计算与全局同步解耦
训练节点先在 H 步内执行本地 AdamW 优化(内循环),然后使用全局 Nesterov 动量优化器(外循环)对权重变化量求平均,从而大幅减少总通信量。
流式 DiLoCo 通过参数分片消除周期性网络停顿
系统将模型拆分为 P 个片段(通常为 N_layers + 1),每一步同步一个片段,从而把大规模的周期性带宽峰值转化为均匀且可控的数据流。
在低带宽和网络拥塞环境下,性能显著提升
在网络严重拥塞(10 Gbit/s)时,流式 DiLoCo 相比数据并行实现 9.57x 的速度提升;由于消除了每隔 H 步出现的「同步气泡」,其表现也优于原版 DiLoCo。
在稠密架构和 MoE 架构中均能保持收敛稳定性
针对 Qwen3 和 Gemma4 模型的实测结果表明,流式 DiLoCo 的表现与同步数据并行基线相当或略胜一筹,而 Nesterov 动量则有助于稳定全局优化轨迹。
完整摘要
本文详细介绍了流式 DiLoCo 在 MaxText 中的实现。MaxText 是 Google 基于 JAX 构建的 LLM 训练框架。为克服标准数据并行训练在广域网(WAN)上遇到的网络停顿,DiLoCo 采用内外循环优化机制:各训练节点先执行本地步骤,再进行全局同步。流式 DiLoCo 进一步优化了这一机制:将模型参数拆分为多个片段,并在若干步骤中逐步同步,从而消除原版 DiLoCo 的带宽峰值。基于 Qwen3-32B 的基准测试表明,即使网络严重拥塞(10 Gbit/s),流式 DiLoCo 仍能保持较高的硬件利用率;与标准数据并行相比,速度最高提升 9.57x,同时不影响模型收敛或质量,对混合专家(MoE)架构也是如此。
目录 · 12 节
简介Introduction
传统上,训练最先进的大语言模型(LLM)依赖于由加速器组成的单体集群,其中所有设备集中部署,并通过高带宽连接紧密耦合,以持续同步梯度。然而,物理条件和成本限制使得扩展单个切片变得越来越困难。Traditionally, training state-of-the-art Large Language Models (LLMs) relies on a monolithic cluster of accelerators, where all devices are collocated and tightly coupled via high-bandwidth to constantly synchronize gradients. However, physical and cost constraints make scaling a single slice increasingly difficult.
为了进一步扩展规模,我们可以连接分布在不同地理位置的数据中心中的多个计算切片。然而,在通过广域网(WAN)跨多个数据中心进行训练时,标准的数据并行训练会遭遇严重的网络停顿,因为缓慢的 WAN 传输无法与计算完全重叠。To scale further, we can connect multiple compute slices across geographically distributed datacenters. However, when training across multiple datacenters over wide-area networks (WAN), standard data-parallel training suffers from severe network stalls because slow WAN transfers cannot be fully overlapped with computation.
为了解决这一问题,Google DeepMind 和 Google Research 团队开发了 DiLoCo(分布式低通信),这是一种分布式优化算法,旨在让训练能够适应低带宽、高延迟的连接。在这篇博客文章中,我们将探讨 DiLoCo 的核心概念、它在 MaxText(Google 基于 JAX 的开源 LLM 训练框架)中的实现方式,以及它为 Google Cloud 上的大规模 LLM 训练带来的性能优势。To address this, the Google DeepMind and Google Research teams developed DiLoCo (Distributed Low-Communication), a distributed optimization algorithm designed to make training resilient to these low-bandwidth, high-latency connections. In this blog post, we discuss the core concepts of DiLoCo, how it is implemented in MaxText (Google's open-source JAX-based LLM training framework), and the performance benefits it brings to large-scale LLM training on Google Cloud.
什么是 DiLoCo?What is DiLoCo?
DiLoCo 由 Google DeepMind 在论文《DiLoCo:语言模型的分布式低通信训练》中提出。与标准数据并行不同,标准数据并行会在每个训练步骤中同步所有设备上的梯度;DiLoCo 则将训练划分到 M 个相互独立的计算组(称为学习器)中,并允许每个学习器先独立执行许多本地优化步骤,再在组间通信。DiLoCo was introduced by Google DeepMind in the paper DiLoCo: Distributed Low-Communication Training of Language Models. Instead of synchronizing gradients across all devices at every single training step (as in standard Data Parallelism), DiLoCo partitions training across M independent compute groups, referred to as learners, and allows each learner to perform many local optimization steps independently before communicating across groups.
内外层优化循环The Inner-Outer Optimization Loop
DiLoCo 在两个层面上运行:DiLoCo operates on two levels:
- 内层循环(本地):每个学习器(通常是单个 TPU 切片,或数据中心内由多个切片组成的组)在本地数据分区上运行标准优化器(通常为 AdamW),执行 H 步(同步间隔,例如我们实验中的 H = 37–65)。在这些步骤中,不同 DiLoCo 组之间不会发生通信。标准的副本内通信(例如 ICI;如果学习器本身是由多个切片组成的组,则为副本内 DCN)仍会像往常一样在每一步进行。The Inner Loop (Local): Each learner (typically a single TPU slice or an intra-datacenter multi-slice group) runs a standard optimizer (typically AdamW) on its local data partition for H steps (the synchronization cadence, e.g., H = 37–65 in our experiments). During these steps, no communication occurs between different DiLoCo groups. Standard intra-replica communication (such as ICI, or intra-replica DCN if the learner itself is a multi-slice group) continues at every step as usual.
- 外循环(全局):每隔 H 步,M 个学习器都会计算各自当前权重与该时间间隔开始时的全局权重之间的差值(delta)。学习器通过分布式全归约在整个网络中对这些差值求平均,并应用外层优化器(通常是带 Nesterov 动量的 SGD)来更新全局权重;更新后的全局权重将作为下一个内循环时间间隔的起点。The Outer Loop (Global): Every
Hsteps, theMlearners compute the difference (delta) between their current weights and the global weights at the start of the interval. The learners average these deltas across the network via a distributedall-reduceand apply an outer optimizer (typically SGD with Nesterov momentum) to update the global weights, which then serve as the starting point for the next inner-loop interval.
尽管通信频率远低于标准同步训练(低 H 倍,例如低 1–2 个数量级),DiLoCo 仍已被证明能够实现相当的收敛效果和模型质量。Despite communicating significantly less frequently (by a factor of H, e.g., 1-2 orders of magnitude less) than standard synchronous training, DiLoCo has been shown to achieve comparable convergence and model quality.
上文介绍的 Vanilla DiLoCo 将通信总量减少了 H 倍,但所有学习器仍然每隔 H 步就一次性传输整个模型的权重增量。在网络带宽有限的情况下,这种全模型传输会每隔 H 步造成一次长时间的停顿。下一节介绍的 Streaming DiLoCo 可以缓解这一问题。The Vanilla DiLoCo described above reduces total communication volume by a factor of H, however, all learners still transmit their weight deltas for the entire model all at once at every H-th step. On a thin network pipe, that full-model transfer creates a large periodic stall every H steps. This issue is alleviated by Streaming DiLoCo, which is described in the next section.
为什么流式 DiLoCo 在低带宽环境中表现出色Why Streaming DiLoCo Shines in Low-Bandwidth Regimes
在多切片训练中,单个切片内的通信由高速芯片间互连(ICI)处理。扩展到多个切片时,跨切片同步必须通过数据中心网络(DCN)进行;如果切片分布在不同地理位置,则必须通过广域网(WAN)进行。In multi-slice training, communication within a single slice is handled by high-speed Inter-Chip Interconnects (ICI). When scaling to multiple slices, synchronization across slices must traverse the Data Center Network (DCN) or, if the slices are geographically distributed, wide-area networks (WAN).
在单个数据中心内,DCN 带宽足够高,因此 JAX 和 XLA 通常可以通过将梯度通信与反向传播计算重叠,来隐藏标准数据并行(DP)中的 all-reduce 集合通信开销。然而,在跨数据中心或链路拥塞的情况下,带宽会下降,延迟则会急剧上升。标准 DP 在每个步骤都会因等待全局梯度同步而停滞,导致模型 FLOPS 利用率(MFU)大幅下降。Within a single datacenter, DCN bandwidth is high enough that JAX and XLA can often hide standard Data Parallel all-reduce collectives by overlapping gradient communication with backward-pass computation. Across datacenters or congested links, however, bandwidth drops and latency rises sharply. Standard DP stalls at every step waiting for global gradient synchronization, collapsing Model FLOPS Utilization (MFU).
Streaming DiLoCo 将模型参数划分为 P 个互不重叠的片段,从而消除了这种同步停顿。在 H 个步骤中,模型中的每个片段都恰好同步一次,因此外循环节奏与原版 DiLoCo 完全相同,同时避免了带宽利用率的突增。Streaming DiLoCo eliminates this synchronization stall by partitioning the model's parameters into P disjoint fragments. Over the course of H steps, every single fragment in the model is synchronized exactly once, achieving the exact same outer-loop cadence as vanilla DiLoCo without spiky bandwidth utilization.
- 分片:MaxText 将模型划分为 P = NLAYERS + 1 个分片:其中一个分片包含所有非扫描参数(token 嵌入、最终层归一化和输出头),另外 Nlayers 个分片分别对应一个扫描式 Transformer 解码器层。Fragmentation: MaxText partitions the model into P = NLAYERS + 1 fragments: one fragment for all non-scanned parameters (token embeddings, final layer norm, and output head) and Nlayers fragments, one for each scanned Transformer decoder layer.
- 分步错峰流式同步:MaxText 不再每隔 H 步暂停一次并交换整个模型,而是每隔 Δh=max(1,round(H/P)) 步同步一个片段。将 H=P(Δh=1)时,每步同步一个片段,把完全相同的通信总量分摊到全部 H 步中,让网络承载近乎均匀且极小的数据流(如下文所述,在将大型嵌入矩阵均衡分配到各层片段之后),而不是遭遇巨大的周期性流量峰值。同步时不会连续同步相邻层,而是沿网络深度交错选择每个时间间隔要同步的片段(例如,片段 0、层 k、层 2k 等)。这样,每轮同步都会触及网络的不同深度,避免模型的某个完整区段在另一段更新时仍处于陈旧状态。Staggered Per-Step Streaming: Instead of pausing every H steps to exchange the entire model, MaxText synchronizes a single fragment every Δh=max(1,round(H/P)) steps. Setting H=P (Δh=1) synchronizes one fragment per step, spreading the exact same reduced communication volume across all H steps so the network sees a nearly uniform, tiny stream (once large embedding matrices are load-balanced across the layer fragments, as described next) rather than a massive periodic spike. Rather than synchronizing adjacent layers consecutively, the selection of which fragment syncs at each interval is interleaved across the depth of the network (e.g., Fragment 0, then Layer k, then Layer 2k, etc.). This ensures every round of synchronization touches different depths of the network rather than leaving an entire section of the model stale while another section updates.
- 嵌入负载均衡:由于 Fragment 0 包含扫描层之外的所有参数——词元嵌入、预 logits 层归一化以及解嵌入/输出头——其大小取决于词汇表维度,因此可能远大于其他片段。若不采取缓解措施,同步 Fragment 0 的步骤会造成网络流量激增,远超其他层片段。为此,虽然 Fragment 0 中仍保留一些非扫描向量,但会将该片段中的大型矩阵均匀拆分,并与其他 Nlayers 个片段合并。Embedding Load Balancing: Since Fragment 0 holds all parameters outside the scanned layers: the token embeddings, pre-logits layer norm, and unembedding/output head, its size depends on the vocabulary dimension, and it can be much larger than the other fragments. Without mitigation, the step that synchronizes Fragment 0 would produce a massive spike in network traffic compared to the other layer fragments. To this end, while some non-scanned vectors remain in Fragment 0, large matrices from this fragment are evenly split and merged with the other Nlayers fragments.
网络链路容量规划:数据并行、常规方案与流式 DiLoCoSizing Your Network Link: Data Parallel vs. Vanilla vs. Streaming DiLoCo
使用屋顶线模型(类似于 JAX Scaling Book),我们可以计算出为避免通信停顿,参数量为 ∣Θ∣ 的模型所需的网络带宽(每个参数占 b 字节,例如 bfloat16 时 b=2),其中每步计算时间 tstep=tfwd+tbwd。例如,标准的数据并行算法通过 all-reduce 集合通信操作在每次同步时传输 2∣Θ∣b 字节。该操作是分布式 reduce-scatter:每个节点负责归约不同的部分;随后执行 all-gather,使所有参与者都收到所有部分。要实现零通信停顿,我们将梯度的 reduce-scatter 与生成这些梯度的反向传播过程重叠,而反向传播耗时 tbwd。因此,所需的峰值带宽为 Bdp ≈ 2∣Θ∣b / tbwd。Using a roofline model (similar to the JAX Scaling Book), we can calculate the network bandwidth required to prevent communication stalls for a model with ∣Θ∣ parameters (at b bytes per parameter, e.g., b=2 for bfloat16) and per-step compute time tstep=tfwd+tbwd. For example, the standard Data Parallel algorithm transfers 2∣Θ∣b bytes per sync via an all-reduce collective, which is a distributed reduce-scatter where each node reduces a different part, followed by an all-gather so all participants receive all parts. To achieve zero communication stalls, we overlap the reduce-scatter of the gradients with the backward pass, which produces them and takes tbwd time. Therefore, the peak required bandwidth is Bdp ≈ 2∣Θ∣b / tbwd.
算例(Qwen3-32B,bfloat16,tstep≈6.2s,P=H=65):Worked Example (Qwen3-32B in bfloat16, tstep≈6.2s, P=H=65):
- 数据并行在每一步都会交换约 65.5 GB(约 524 Gb)的梯度。若要在约 6 秒的步进时间内完成传输且不发生停顿,持续的跨切片带宽至少需要约 85 Gbps(524 Gb / 6.2 s ≈ 85 Gbps)。在受限的切片间 10 Gbps 链路上,传输 65.5 GB 将耗时超过 50 秒,导致严重停顿。Data Parallel exchanges ~65.5 GB (∼524 Gb) of gradients at every single step. To finish this transfer within a ∼6s step time without stalling, it requires at least ∼85 Gbps of sustained cross-slice bandwidth (524 Gb / 6.2 s≈85 Gbps). On a constrained, inter-slice 10 Gbps link, transferring 65.5 GB would take over 50 seconds, causing massive stalls.
- 原版 DiLoCo(H=65)在 64 个本地步骤中全速运行,总通信量减少 65 倍(65 个步骤约为 65.5 GB),但每到第 65 个步骤仍会停顿一次,因为此时要一次性传输完整的约 65.5 GB 负载。Vanilla DiLoCo (H=65) runs at full speed for 64 local steps and reduces total traffic by 65x (∼65.5 GB over 65 steps), but still stalls on every 65th step while transferring the full ∼65.5 GB payload at once
- Streaming DiLoCo(P=H=65)每步只交换模型的 1/65(约 1.0 GB),65 步总计约 65.5 GB——通信量比 DP 少 65 倍——仅需约 1.3 Gbps 的带宽。即使在受到严重限速的 10 Gbps 链路上,通信也能轻松在单步耗时内完成。Streaming DiLoCo (P=H=65) exchanges just 1/65th of the model (∼1.0 GB) per step (∼65.5 GB over 65 steps—65× less traffic than DP), requiring only ∼1.3 Gbps of bandwidth. Even on a heavily throttled 10 Gbps link, communication fits comfortably inside the step time.
评估这些主张:结果与见解Evaluating the Claims: Results and Insights
1. 性能与网络弹性1. Performance and Network Resilience
为在真实网络瓶颈下评估分布式效率,我们使用内置 Linux 流量控制(tc)带宽整形功能,对 2× TPU v5p-32 切片上的 Qwen3-32B(64 个解码器层,划分为 P = 65 个片段,H = 65;dcn_diloco_parallelism=2)进行基准测试,限制切片间带宽,并设置三种网络条件:不限速(线路速率)、聚合带宽 30 Gbit/s(中度拥塞)和聚合带宽 10 Gbit/s(严重拥塞)。To evaluate distributed efficiency under realistic network bottlenecks, we benchmarked Qwen3-32B (64 decoder layers, partitioned into P = 65 fragments with H = 65) across 2× TPU v5p-32 slices (dcn_diloco_parallelism=2) using built-in Linux traffic-control (tc) bandwidth shaping to limit inter-slice bandwidth across three network regimes: Unthrottled (Line Rate), 30 Gbit/s aggregate (Moderate Congestion), and 10 Gbit/s aggregate (Severe Congestion).
主要发现:Key Findings:
- 线速至中度拥塞(不限速至 30 Gbit/s):当切片间带宽不受限制时,XLA 会将 DP 梯度归约与反向计算重叠执行,三种方法的步时相近(约 5.6–5.9 秒)。然而,当切片间带宽为 30 Gbit/s 时,数据并行已使链路饱和,步时退化至 19.41 秒;而 Streaming DiLoCo 的步时仍稳定在 5.76 秒(提速 3.37 倍)。Line Rate to Moderate Congestion (Unthrottled to 30 Gbit/s): When inter-slice bandwidth is unthrottled, XLA overlaps DP gradient reductions with backward computation, and all three methods achieve similar step times (~5.6–5.9 s). At 30 Gbit/s inter-slice bandwidth, however, Data Parallel already saturates the link and degrades to 19.41 s/step, while Streaming DiLoCo maintains a flat 5.76 s/step (a 3.37× speedup).
- 严苛网络限制(10 Gbit/s):数据并行的每步用时从 5.58 s 急剧恶化至 55.11 s,因为每步 65.5 GB 的全归约操作使链路达到饱和。原版 DiLoCo(H = 65)的表现好得多(每步 7.55 s,提速 7.30×),但仍会每隔 65 步遭遇一次周期性的全模型同步停顿。流式 DiLoCo(P = 65,H = 65)则始终保持每步 5.76 s——相比 DP 提速 9.57×,并消除了第 H 步的停顿。Severe Network Constraints (10 Gbit/s): Data Parallel degrades sharply from 5.58 s to 55.11 s/step as its 65.5 GB per-step
all-reducesaturates the link. Vanilla DiLoCo (H = 65) fares much better (7.55 s/step, a 7.30× speedup), but still suffers a periodic full-model synchronization bubble every 65 steps. Streaming DiLoCo (P = 65, H = 65) maintains a flat 5.76 s/step—delivering a 9.57× speedup over DP and eliminating the step-H stall. - 随深度和批量大小实现有利的扩展:由于我们设置 P = N_layers + 1(每个片段对应一个解码器层),增加模型深度会延长每一步中所有层的计算时间,而 Streaming DiLoCo 每步的通信量仍按 P 分摊,因此系统每步有更多计算时间来摊销后台权重传输。重要的是,随着模型深度扩展 P(因而也扩展 H)并不会损害收敛:在我们对稠密版 Qwen3-32B(64 个解码器层,P = H = 65)的实验中,Streaming DiLoCo 达到与同步数据并行基线相当的损失,模型质量没有下降。Favorable Scaling with Depth and Batch Size: Because we set P = N_layers + 1 (one decoder layer per fragment), scaling model depth increases per-step compute time across all layers while Streaming DiLoCo's per-step communication stays divided by P, giving the system even more compute time per step to amortize background weight transfers. Importantly, scaling P (and therefore H) with model depth does not degrade convergence: in our experiments on dense Qwen3-32B (64 decoder layers, P = H = 65), Streaming DiLoCo matches the synchronous Data Parallel baseline loss with no degradation in model quality.
2. 收敛性与模型质量2. Convergence and Model Quality
关于低通信训练,一个常见的问题是:允许学习者在同步之间独立训练,是否会降低模型质量——尤其是在混合专家(MoE)架构中,因为独立更新可能导致专家路由器逐渐偏离。A common question with low-communication training is whether allowing learners to train independently between synchronizations degrades model quality—especially on Mixture-of-Experts (MoE) architectures, where independent updates could cause expert routers to drift apart.
我们在 MaxText 中的两种 MoE 架构(Qwen3-30B-A3B 和 Gemma4-26B-A4B)上,对 Streaming DiLoCo 与同步数据并行预训练进行了评估,共训练 4,000 步:We evaluated Streaming DiLoCo against synchronous Data Parallel pre-training across two MoE architectures in MaxText (Qwen3-30B-A3B and Gemma4-26B-A4B) over 4,000 training steps:
实证结果证实,Streaming DiLoCo 保持了验证损失水平,甚至略有降低:Empirical results confirm that Streaming DiLoCo preserves—and even slightly improves—validation loss:
- 外层 Nesterov 动量:相比于对学习器权重进行简单平均,使用外层 Nesterov 动量优化器(β = 0.9,外层学习率 η_outer 介于 0.3 和 0.7 之间)对片段伪梯度进行更新,可以稳定全局优化轨迹。Outer Nesterov Momentum: Rather than naively averaging learner weights, stepping an outer Nesterov momentum optimizer (
β = 0.9, outer learning rateη_outerbetween0.3and0.7) across fragment pseudo-gradients stabilizes the global trajectory. - 保持热状态的内部优化器:由于同步更新只更新模型参数,而每个学习器本地 AdamW 的一阶和二阶矩缓冲区保持不变,因此片段同步后,学习器不会丢失优化器动量。Warm Inner Optimizers: Because synchronization updates only the model parameters while leaving each learner's local AdamW first- and second-moment buffers intact, learners never lose optimizer momentum after a fragment sync.
在 MaxText 中开始使用流式 DiLoCoGetting Started with Streaming DiLoCo in MaxText
MaxText 提供了原生的 JAX 和 Flax NNX 实现,支持 Vanilla 和 Streaming DiLoCo,且无需外部中央参数服务器。MaxText provides a native JAX and Flax NNX implementation of both Vanilla and Streaming DiLoCo—requiring no external central parameter servers.
1. 配置1. Configuration
你可以在 MaxText YAML 配置或 CLI 覆盖项中设置 enable_diloco: true 和 enable_streaming_diloco: true,以启用 Streaming DiLoCo。作为最佳实践,请将 num_diloco_fragments (P) 和 diloco_sync_period (H) 都设为 N_layers + 1,这样每个训练步骤恰好同步一个片段 (Δh = 1):You can enable Streaming DiLoCo in your MaxText YAML configuration or CLI overrides by setting enable_diloco: true and enable_streaming_diloco: true. As a best practice, set both num_diloco_fragments (P) and diloco_sync_period (H) to N_layers + 1 so that exactly one fragment is synchronized per training step (Δh = 1):
# Enable DiLoCo and Streaming DiLoCo
enable_diloco: true
enable_streaming_diloco: true
# Partition into N_layers + 1 fragments (e.g., 36 layers + 1 embedding/head = 37 for Qwen3-8B,
# 48 + 1 = 49 for Qwen3-30B-A3B, or 64 + 1 = 65 for Qwen3-32B)
num_diloco_fragments: 37
diloco_sync_period: 37
use_sequential_layers: false # false = interleaved layers across fragments (recommended)
# Outer Nesterov SGD optimizer hyperparameters
diloco_outer_lr: 0.7
diloco_outer_momentum: 0.9
# Multi-slice topology: number of DiLoCo learner islands across DCN/WAN
dcn_diloco_parallelism: 2 # e.g., 2 TPU slices (or set to -1 to infer from num_slices)
# Optional: emulate constrained WAN bandwidth on fast clusters via Linux tc
# dcn_bandwidth_limit: "10gbit"
2. 内部机制与延伸阅读2. Under the Hood & Further Reading
在 MaxText 中,diloco.py 会将每个全局批次拆分到 M 个学习器上,因此每个学习器每步处理 GBS / M 个 token。为了在 Streaming DiLoCo 中让跨切片通信与 TPU 计算重叠,计划处理的片段对应的权重增量会被卸载到运行在学习器主机 CPU 上的 M 路分片同步器工作进程。主机 CPU 上的同步器分片不会通过单个中央协调器进行路由,而是在后台通过网络执行分布式全规约,对片段增量求平均,同时 TPU 继续执行内循环训练步骤。随后,每个同步器分片都会在本地应用外层 Nesterov 动量更新,并将更新后的片段权重写回与其共置的 TPU 学习器。要深入了解或启动首次运行:In MaxText, diloco.py splits each global batch across the M learners so each learner processes GBS / M tokens per step. To overlap cross-slice communication with TPU computation in Streaming DiLoCo, weight deltas for the scheduled fragment are offloaded to M-way sharded syncer workers running on the learner host CPUs. Rather than routing through a single central coordinator, the host-CPU syncer shards execute a distributed all-reduce across the network in the background to average the fragment deltas while the TPUs continue running inner-loop training steps. Each syncer shard then applies the outer Nesterov momentum update locally and writes the updated fragment weights back to its colocated TPU learner. To dive deeper or launch your first run:
- 理论与链路容量规划参考:MaxText 中的 DiLoCo 和流式 DiLoCo 理论Theory & Link-Sizing Reference: DiLoCo and Streaming DiLoCo Theory in MaxText
- 分步训练方案与调优指南:DiLoCo 预训练教程,附 Qwen3 8B 和 30B 模型的示例配置方案Step-by-Step Recipes & Tuning Guide: DiLoCo Pre-training Tutorial with sample recipes for Qwen3 8B and 30B models
- 启动脚本:run_spmd_streaming_diloco.sh(稠密)和 run_olmo_qwen3_30b_streaming_diloco.sh(MoE)Launch Scripts: run_spmd_streaming_diloco.sh (Dense) and run_olmo_qwen3_30b_streaming_diloco.sh (MoE)
结论Conclusion
MaxText 中的流式 DiLoCo 将大规模 LLM 预训练与对单一整体式高带宽网络架构的依赖解耦。通过结合内层和外层优化器,并以细粒度方式流式传输参数,工程团队可以跨越拥塞的数据中心网络或地理上分散的都市区域汇集 TPU 切片,在不影响模型收敛的前提下,持续保持较高的硬件利用率。流式 DiLoCo 现已在 PyPI 上的 MaxText v0.2.5、相应的 Docker 镜像以及 GitHub main 分支中提供。立即试用,探索分布式训练工作负载。Streaming DiLoCo in MaxText decouples large-scale LLM pre-training from the requirement of a single, monolithic, high-bandwidth fabric. By combining use of an inner and outer optimizer with fine-grained parameter streaming, engineering teams can pool TPU slices across congested datacenter networks or geographically distributed metros—sustaining high hardware utilization without compromising model convergence. Streaming DiLoCo is available today in MaxText v0.2.5 on PyPI, the corresponding Docker images and on GitHub main. Try it today for experimenting with distributed training workloads.