<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>与分布式训练结合 - - 集合通信博客</title><link>https://hccl.club/docs/training/</link><description>与分布式训练结合 - - 集合通信博客</description><generator>Hugo -- gohugo.io</generator><language>zh-CN</language><lastBuildDate>Fri, 06 Nov 2026 09:00:00 +0800</lastBuildDate><atom:link href="https://hccl.club/docs/training/" rel="self" type="application/rss+xml"/><item><title>数据并行 DDP：梯度 AllReduce</title><link>https://hccl.club/docs/training/ddp-gradient-allreduce/</link><pubDate>Fri, 06 Nov 2026 10:00:00 +0800</pubDate><author><name>Innoecho</name></author><guid>https://hccl.club/docs/training/ddp-gradient-allreduce/</guid><description>&lt;p>数据并行 (Data Parallelism, DP) 是最古老也最常用的并行策略：每张卡复制一份完整模型，各吃不同的数据分片，反向传播后把各卡的梯度做平均，保证模型副本始终一致。它对模型的侵入性几乎为零，是绝大多数训练任务的默认起点。&lt;/p>
&lt;p>DP 的通信内核极其规整——每个训练步恰好一次梯度 AllReduce，消息大小就是模型参数量 $M_{params}$ 乘以每参数字节数 $b$。本文拆开 PyTorch 的 DistributedDataParallel (DDP)：看它的梯度分桶 (gradient bucketing) 机制如何把这次 AllReduce 切碎并与反向计算重叠，看它的 Reducer 与 autograd hook 如何工作，最后给出通信量口径与 Horovod 的对比。&lt;/p></description></item><item><title>ZeRO 与 FSDP：分片带来的通信</title><link>https://hccl.club/docs/training/zero-fsdp-communication/</link><pubDate>Fri, 06 Nov 2026 10:00:00 +0800</pubDate><author><name>Innoecho</name></author><guid>https://hccl.club/docs/training/zero-fsdp-communication/</guid><description>&lt;p>数据并行的显存瓶颈不在模型，而在训练状态：混合精度 (mixed precision) 加 Adam 之下，每个参数要占用 16 字节量级的状态显存，7B 模型在每张卡上就要留出 112 GB，参数副本根本放不下。ZeRO（Zero Redundancy Optimizer）的答案是：这些状态本来就没必要在每个 rank 上各存一份——按 rank 切片存储，用到时再用集合通信临时拼回来。&lt;/p>
&lt;p>分片改变了通信模式：DDP 是每步一次大 AllReduce，ZeRO-3 与 PyTorch FSDP（Fully Sharded Data Parallel）则把通信摊到每一层——前向用参数前 AllGather 拼回整层参数，反向算完梯度再 ReduceScatter 归约分片。本文梳理三级分片各自的通信代价、每层通信的时序、以及 ZeRO++ 如何把多出来的通信再压回去。&lt;/p></description></item><item><title>张量并行：每层两次 AllReduce</title><link>https://hccl.club/docs/training/tensor-parallel-communication/</link><pubDate>Fri, 06 Nov 2026 10:00:00 +0800</pubDate><author><name>Innoecho</name></author><guid>https://hccl.club/docs/training/tensor-parallel-communication/</guid><description>&lt;p>数据并行切数据，张量并行 (Tensor Parallelism, TP) 直接切权重：把一个线性层的矩阵按行列切开摊到多张卡上，每张卡算部分结果再归并。Megatron-LM 证明了这种切法与 transformer 结构严丝合缝——注意力按头切、MLP 按中间维切，一个 transformer 层只需要极少的通信点就能完整并行。&lt;/p>
&lt;p>TP 的通信特征与 DDP 完全不同：DDP 每步一次大 AllReduce，TP 则是每层前向两次、反向两次的小 AllReduce，消息是激活值而非梯度。通信次数随层数线性增长，这一特征决定了 TP 必须住在 NVLink/超节点这样的高带宽域内。本文给出这套通信的完整口径，并延伸到序列并行与异步张量并行。&lt;/p></description></item><item><title>MoE 专家并行：AlltoAll 通信</title><link>https://hccl.club/docs/training/moe-alltoall/</link><pubDate>Fri, 06 Nov 2026 10:00:00 +0800</pubDate><author><name>Innoecho</name></author><guid>https://hccl.club/docs/training/moe-alltoall/</guid><description><![CDATA[<p>混合专家 (Mixture of Experts, MoE) 用条件计算打破&quot;模型能力与算力等比增长&quot;的约束：把 transformer 的 MLP 换成一组专家网络，每个 token 只经门控路由到其中少数几个。参数可以涨到千亿万亿，每 token 的计算量却只线性于激活的专家数。</p>
<p>代价落在了通信上。专家被切到不同 GPU（专家并行，Expert Parallelism, EP）后，token 不再&quot;原地&quot;完成 MLP 计算，而要出发去专家所在的卡、算完再回来——这两个方向的搬运都由 AlltoAll 完成。MoE 训练与推理的通信主角从 AllReduce 换成了 AlltoAll，网络特征也随之改变：消息碎、模式全对称、对负载不均极其敏感。</p>]]></description></item><item><title>计算通信重叠技术</title><link>https://hccl.club/docs/training/compute-communication-overlap/</link><pubDate>Fri, 06 Nov 2026 10:00:00 +0800</pubDate><author><name>Innoecho</name></author><guid>https://hccl.club/docs/training/compute-communication-overlap/</guid><description><![CDATA[<p>并行度越大，通信占训练时间的比重越高：数据并行下每 rank 的梯度 AllReduce 字节量几乎不随卡数下降，而每卡分到的计算量却在变小；张量并行与专家并行更是把通信塞进了每一层的关键路径。若计算与通信串行执行，步时就是两者之和，规模一大通信直接吃掉扩展性。</p>
<p>计算通信重叠 (compute-communication overlap) 是所有训练框架共同的核心工程：让通信 kernel 与计算 kernel 在时间上并发，把串行的和变成 max。本文先给手段总览，再拆开 CUDA stream 与 event 的底层机制、分层 AllReduce 的字节账、1F1B 流水的覆盖逻辑，最后讲度量方法与&quot;重叠过度&quot;的坑。</p>]]></description></item></channel></rss>