01
中文:训练时,每份参数在显存里实际要存多份东西。论文 Section 3.1 给出了具体公式:fp16 参数 + fp16 梯度 + Adam 优化器状态(fp32 动量+方差+参数副本),合计约 16Ψ 字节(Ψ = 参数数量)。
ENG:During training, each model parameter ψ requires multiple memory copies: fp16 parameters, fp16 gradients, and Adam optimizer states (fp32 momentum, variance, and a copy of parameters). Total ≈ 16ψ bytes per parameter.
# Memory Breakdown (per parameter ψ)
fp16 parameters: 2Ψ bytes
fp16 gradients: 2Ψ bytes
Adam optimizer (K=12): KΨ bytes ← fp32 momentum + variance + fp32 param copy
Total: ~16Ψ bytes | GPT-2 1.5B → 24 GB (vs 3 GB for params alone)
中文:以 GPT-2(1.5B 参数)为例:fp16 参数本体只占 3 GB,但加上优化器状态等,显存跳到 24 GB——是前者的 8 倍。如果是 1 万亿参数(1T)模型,模型状态显存需求约 16 TB,32 GB V100 卡要 500 张才能装下。
ENG:For GPT-2 (1.5B params): fp16 weights alone = 3 GB, but with optimizer states the requirement jumps to 24 GB. A 1 Trillion (1T) parameter model needs ~16 TB for model states alone — requiring ~500 × 32 GB V100 GPUs.
02
🔵 Data Parallelism(数据并行)
优势 / Pros:扩展效率高,通信量小,实现简单 / High scalability, low communication overhead, easy to implement
问题 / Cons:每张卡复制完整模型,显存冗余严重 / Every GPU stores a full replica — memory inefficient
🔵 Model Parallelism(模型并行)/ Pipeline Parallelism(流水线并行)
优势 / Pros:把模型切分到多卡,显存够用 / Partition model across GPUs — fits large models
问题 / Cons:计算粒度降低,跨节点通信开销大;需改动模型代码 / Reduced compute granularity, high cross-node communication, requires model code changes
中文:原文 Section 4.1 的核心洞察:DP 计算效率高但显存冗余,MP 显存效率高但计算效率低——两者是 tradeoff,既往方案只能二选一。
ENG:Paper Section 4.1 insight: DP offers high compute efficiency but memory redundancy; MP offers memory efficiency but lower compute efficiency. Prior work forces a tradeoff — ZeRO aims to have both.
03
中文:ZeRO 把显存优化分为三个依次叠加的阶段。每一阶段比上一阶段多切分一部分模型状态(Section 5 原文定义)。
ENG:ZeRO partitions model states across data-parallel GPUs in three cumulative stages (Section 5). Each stage shards an additional component of model state.
三阶段对照 / Three-Stage Comparison
阶段 / Stage | 分片内容 / Sharded | 显存节省 / Mem. Saving | 通信量 / Comm. |
|---|---|---|---|
ZeRO-1(Pos) | Optimizer States(优化器状态) | 最高 4× | = DP |
ZeRO-2(Pos+g) | + Gradients(梯度) | 最高 8× | = DP(原文证明) |
ZeRO-3(Pos+g+p) | + Parameters(参数) | 最高 64×(512 GPUs) | +α |
04
"
中文:ZeRO-2 分片梯度后,通信量 = 2Φ,与原始数据并行完全相同。这是论文 Section 7.2.1 的核心证明。
ENG:With gradient partitioning (Pos+g), communication volume = 2Φ — exactly the same as standard DP. This is proven in Section 7.2.1 of the paper.
中文:这意味着 ZeRO-2 用和普通数据并行完全一样的通信量,换来了 8 倍的显存节省——不增加通信负担,这是 ZeRO 最重要的工程价值。
ENG:ZeRO-2 achieves 8× memory reduction with identical communication volume compared to naive DP. No communication overhead — this is ZeRO's core engineering contribution.
05
硬件 / Hardware:400 × V100 GPU(25 DGX-2 nodes),节点间带宽 800 Gbps。原文 Table 2、Table 5 数据:
模型 / Model | 并行方式 / Config | GPU 数量 | 结果 / Result |
|---|---|---|---|
60B 参数 | ZeRO-100B | 64–400 | 38 TFlops/GPU,聚合 15 Petaflops |
170B 参数 | ZeRO + MP=16 | 400 | 超线性加速(GPU 翻倍,性能超线性增长) |
13B 参数 | ZeRO-100B(无 MP) | 128 | 40+ TFlops/GPU,无需模型并行 |
中文:原文 Section 10.4 特别指出:13B 参数模型不需要任何模型并行,直接用 ZeRO 训,平均单卡 40 TFlops。意味着普通研究者不需要懂模型并行,也能训练超大规模模型。
ENG:Section 10.4: 13B parameter models can be trained without any model parallelism using ZeRO alone, at 40+ TFlops/GPU average. This democratizes large model training — no need to understand MP/PP to train large models.
06
中文:两者正交(orthogonal),可以叠加。原文 Section 4.1:"ZeRO powered DP is orthogonal and complimentary to pipeline model parallelism." 具体分工:
ENG:ZeRO and model parallelism are orthogonal and complementary. They can be stacked together.
三者叠加 = 2019-2020 年万卡集群训练方案的完整拼图,也是今天训练 GPT-3(175B)、LLaMA(65B)等大模型的标准范式。
💡 核心洞察 / Core Insight
中文:ZeRO 的本质是用通信换显存——ZeRO-2 在通信量不变的情况下,把显存砍到 1/8,是论文最重要的工程结论。三个阶段按需开启(ZeRO-1 → ZeRO-2 → ZeRO-3),现已成为 DeepSpeed 框架的标准底座。
ENG:ZeRO trades communication for memory. ZeRO-2 achieves 8× memory reduction with zero communication overhead. Three stages (Pos → Pos+g → Pos+g+p) are additive — enable them progressively as memory runs out. Now standard in DeepSpeed, powering Turing-NLG (17B) and beyond.
本周把三个阶段(Pos / Pos+g / Pos+g+p)对应的显存节省数字记下来
本月对照 DeepSpeed 文档,用 ZeRO-2 配置跑通一个 7B 模型
永远所有「并行」概念(DP / MP / PP / TP / ZeRO)先区分「切存储」还是「切计算」,不会再混
· · ·
— END —