← Back to AI Infrastructure Mind Map
🖥️ AI InfrastructureID: collective-communication-nvlink

Collective Comm & NVLink Topology

集合通信与 NVLink 拓扑
🎯Core Definition
Every synchronization in multi-GPU training reduces to collective primitives. Let each rank hold a data shard of SS bytes and there be N ranks: ① AllGather (each rank broadcasts its shard to the other N−1 ranks; at the end every rank holds all NSNS bytes): each rank must receive N−1 shards, volume (N−1)S(N-1)S — every rank's data is read once by each of the other N−1 ranks; ② ReduceScatter (reduce, then keep only one's own part of the result): N−1NS\frac{N-1}{N}S per rank; ③ AllReduce (reduce then distribute to all) = ReduceScatter + AllGather: the ring implementation costs 2N−1NS→2S2\frac{N-1}{N}S \to 2S per rank (for large N each rank transmits only about twice its own data; bandwidth independent of N); ④ AllToAll (every rank sends to and receives from every other) — exactly what MoE expert-parallel token routing does: with uniform load, N−1NS\frac{N-1}{N}S per rank. Hardware bandwidth: NVLink 4.0 (H100) 900GB/s per GPU, NVLink 5.0 (B200/GB200) 1.8TB/s per GPU; InfiniBand 800Gbps (XDR) = 100GB/s, 400Gbps (NDR) = 50GB/s — NVLink 5.0 is about 18× a single 800Gbps IB link. Rail-optimized topology: the i-th GPU NIC of every node plugs into the same leaf switch (the i-th “rail”), so cross-node traffic only happens between same-index GPUs, preventing AllReduce/AllGather flows from hopping across rails and causing hotspots/congestion; together with NVSwitch full-mesh (intra-node) and leaf-spine/3D-Torus (inter-node), this forms NCCL's top-level topology design.
💡Use Cases
the core module of training-infra interviews (the prerequisite of distributed-parallel): derive Ring-AllReduce's volume, how AllGather vs AllReduce differ, why MoE uses AllToAll, how NVLink compares to IB in orders of magnitude, what rail-optimization is.
⚡Key Problems Solved
drops N-way synchronization cost from naive O(NS)O(NS) (every rank sends its full data to N−1 others) to O(S)O(S) — bandwidth stops growing with the number of GPUs, so parallelism can scale to hundreds or thousands of cards; NVLink's huge bandwidth carries TP's frequent small messages while IB carries cross-node gradient sync, and topology design keeps both flows congestion-free.
🎯Core Interview Exam Points
Fundamentals · Production Scenarios · Deep Dive
Core Def
Explain the core definition, underlying mechanism/math, and key principles of Collective Comm & NVLink Topology.
Use Cases
In production engineering, what are the primary use cases for Collective Comm & NVLink Topology and what core pain points does it solve?
🔥 High-Frequency Deep-Dive Questions
1
Derive AllGather's volume: shard SS per rank, N ranks, each ends with NSNS and must receive (N−1)S(N-1)S new bytes — explain why it grows linearly with N while Ring-AllReduce does not.
2
Decompose AllReduce into ReduceScatter + AllGather: what is each phase's volume (N−1NS\frac{N-1}{N}S and (N−1)S(N-1)S) and step count (N−1); verify the total 2N−1NS2\frac{N-1}{N}S by addition.
3
Why MoE expert parallelism is AllToAll, not AllGather: tokens route by expert ID, each rank sends to and receives from all ranks; compare volume N−1NS\frac{N-1}{N}S under uniform load with AllReduce.
4
Recite NVLink/IB numbers: NVLink 4.0 = 900GB/s, NVLink 5.0 = 1.8TB/s, IB 800Gbps = 100GB/s, 400Gbps = 50GB/s; compute how many × NVLink 5.0 is over IB 800Gbps (≈18×) and why TP must use NVLink while DP can use IB.
5
Describe rail-optimized topology: the i-th GPU of every node plugs into one shared leaf switch forming a “rail”; what problem it solves (same-index communication, no cross-rail hotspots) and its relation to NVSwitch and leaf-spine.
Updated 2026-08-12
🎯
Verify Mastery: Practice Exam Questions for "Collective Comm & NVLink Topology"
Take pitfall multiple-choice questions with derivation options; mistakes are automatically logged.
🚀 Start Card Practice ➔
← Previous CardGPU Hardware & HBMNext Card →4D Parallelism DP/TP/PP/SP

🔗 More AI Infrastructure Knowledge Cards

引用出处: TalentMe 450+ 工业级 AI 架构考点知识库 (Tech Vault) · 遵循 CC-BY-4.0 知识共享协议
URL: https://talentme.airsota.com/resources/tech/roadmap/mindmap/AI_Infra/card/collective-communication-nvlink
中文速览与面试要点

集合通信与 NVLink 拓扑 (Collective Comm & NVLink Topology)

定义: 多卡训练的一切同步都可归结为集合通信原语。设每卡持有数据分片 S 字节、共 N 卡: ① AllGather(各卡把自己的分片广播给其余 N−1 卡, 最终每卡持有全部 NS 字节): 每卡需要接收 N−1 个分片, 通信量 (N-1)S——每卡数据被其余 N−1 卡各读一遍; ② ReduceScatter(各卡数据归约后只保留自己那份结果): 每卡 N-1NS; ③ AllReduce(归约后分发给所有卡)= ReduceScatter + AllGather 两步: 环形实现下每卡 2 N-1NS 2S(N 很大时每卡只传自己数据的两倍, 带宽与 N 无关); ④ AllToAll(每卡把数据发给其余所有卡、也接收来自所有卡)——MoE 专家并行的 token 路由就是 AllToAll: 均匀负载时每卡 N-1NS。硬件带宽对比: NVLink 4.0(H100)每卡 900GB/s, NVLink 5.0(B200/GB200)每卡 1.8TB/s; InfiniBand 800Gbps(XDR)= 100GB/s, 400Gbps(NDR)= 50GB/s——NVLink 5.0 是单条 IB 800Gbps 的约 18 倍。轨优化(rail-optimized)拓扑: 每个节点的第 i 张 GPU 的网卡接入同一台叶交换机(第 i 条“轨”), 跨节点通信固定发生在同号 GPU 之间, 避免 AllReduce/AllGather 流量在多条轨之间横跳造成热点与拥塞; 配合节点内 NVSwitch 全互连与节点间叶脊/3D-Torus, 构成 NCCL 的顶层拓扑设计。 使用场景: 训练 Infra 面试的核心模块(是 distributed-parallel 的前置): “推导 Ring-AllReduce 通信量”“AllGather 和 AllReduce 差多少”“MoE 为什么用 AllToAll”“NVLink 和 IB 差几个数量级”“什么是轨优化”。 解决的问题: 让 N 卡同步的开销从朴素的 O(NS)(每卡把全量数据发给其余 N−1 卡)降到 O(S) 量级——带宽不随卡数增长, 并行规模才能扩展到数百上千卡; 同时用 NVLink 的高带宽承载 TP 这类高频小消息通信、用 IB 承载跨节点梯度同步, 并靠拓扑设计让两种流量都不打结。

核心要点

  • 手算 AllGather 通信量: 每卡分片 S、N 卡, 每卡最终持有 NS, 需新接收 (N-1)S 字节——推导它为什么随 N 线性增长而 Ring-AllReduce 不随 N 增长。
  • 把 AllReduce 拆成 ReduceScatter + AllGather 两阶段: 各阶段数据量( N-1NS 与 (N-1)S)与步数(N−1)各是多少, 相加验证总量 2 N-1NS。
  • MoE 专家并行为什么是 AllToAll 而不是 AllGather: token 按专家 ID 路由、每卡发给所有卡也接收所有卡; 均匀负载下通信量 N-1NS 与 AllReduce 的对比。
  • 背 NVLink/IB 数字: NVLink 4.0 = 900GB/s、NVLink 5.0 = 1.8TB/s、IB 800Gbps = 100GB/s、400Gbps = 50GB/s; 算 NVLink 5.0 是 IB 800Gbps 的多少倍(≈18×), 并说明为什么 TP 必须走 NVLink 而 DP 可以走 IB。
  • 描述轨优化(rail-optimized)拓扑: 每节点第 i 张 GPU 接同一台叶交换机构成“轨”; 它解决了什么问题(同号卡之间通信、避免跨轨横跳热点), 与 NVSwitch、叶脊拓扑的关系。