技術指南

集體溝通和 NCCL

Collective communication coordinates data across a group of participating devices.

聆聽此指南AI 語音敘述 · ~2 min

本頁閱讀時間約2分鐘
  1. 概述
  2. 深入探討
  3. 現實世界的實施
  4. 集體溝通和 NCCL 的未來
  5. 付諸實踐
  6. 不斷探索
  7. 常見問題

概述

NCCL implements GPU communication operations such as all-reduce, all-gather and broadcast; their performance depends on message size, topology, hardware and configuration.

深入探討

訓練大型模型意味著每個 GPU 在自己的資料切片上計算梯度,然後所有 GPU 必須在下一步之前就組合結果達成一致。這種協調是透過集體操作完成的:對 GPU 上的值進行 all-reduce 求和,並為每個人提供結果; all-gather 將每個 GPU 的片段收集到所有 GPU 的完整副本中;廣播將一個 GPU 的資料發送給其餘 GPU;減少分散組合然後分裂。 NCCL(NVIDIA Collective Communications Library)使用拓樸感知演算法(例如環和樹全歸約)跨伺服器中的 GPU 以及跨伺服器高效地實現這些功能。它利用節點內部的 NVLink 以及節點之間的 InfiniBand 或 RoCE,是 PyTorch DDP、FSDP、DeepSpeed 和 Megatron 下的通訊主幹。

現實世界的實施

使用 PyTorch DistributedDataParallel 中的 all-reduce 同步所有 GPU 上的每個訓練步驟的梯度

透過 FSDP 或 DeepSpeed ZeRO 中的全收集和減少分散功能對分片優化器狀態進行按需收集參數

在訓練運行開始時將初始模型權重從一個 GPU 廣播到所有其他 GPU

在 NVLink 和 InfiniBand 上使用環 all-reduce 來保持多節點 GPU 叢集的高頻寬

集體溝通和 NCCL 的未來

Larger models and clusters motivate work on computation/communication overlap, topology-aware routing and network offloads. These can improve some workloads while adding configuration and debugging needs. Compare algorithms with representative tensor sizes and record versions and topology. Correct participation and buffer handling remain essential even when a library automates much of the routing. A link-bandwidth claim alone cannot establish end-to-end training speed.

付諸實踐

為什麼這很重要

  • 成本與預算. 多年來,架構決策決定著效能和營運成本。
  • 更明確的決策. 技術教育幫助團隊選擇正確的堆疊,而不僅僅是最新的堆疊。
  • 品質管控. 更好的工程選擇可以減少生產中的可靠性事故。

留意

  • 優化一項基準測試可以隱藏更廣泛的系統弱點。
  • 基礎設施和維護成本常常被低估。
  • 隨著系統變得更加複雜,安全性和可觀察性差距可能會擴大。

後續步驟

  1. 在實施之前定義延遲、品質和成本目標。
  2. 在實際負載和資料條件下進行基準測試。
  3. 儀器監控錯誤、漂移和使用者影響。
  4. 在擴展之前準備回滾和事件回應路徑。

不斷探索

免費電子報

獲取每日 AI 簡報

每個工作日上午提供三則經過驗證的 AI 新聞,以淺顯易懂的英文撰寫。永久免費,無廣告。

每個工作日一封電子郵件。一鍵取消訂閱。我們絕不出售或分享您的地址。

測試一下自己

Take the Collective Communication and NCCL quiz

每個答案皆有即時回饋,通過課程後可獲得具備可驗證 ID 的可分享證書。

開始測驗

支持免費的 AI 教育。AI Understanding 是一個 501(c)(3) 非營利組織——絕無廣告,絕無付費牆。 捐款

常見問題

What is Collective Communication and NCCL?

Collective communication coordinates data across a group of participating devices. NCCL implements GPU communication operations such as all-reduce, all-gather and broadcast; their performance depends on message size, topology, hardware and configuration.

all-reduce 操作在分散式訓練中能完成什麼?

All-reduce 對每個 GPU 上的值求和(或以其他方式組合),並將相同的結果分配回所有 GPU,這就是梯度同步的方式。

縮寫 NCCL 代表什麼?

NCCL是NVIDIA集體通訊庫,它實現了快速的多GPU和多節點集體操作。

Why can chunked ring communication be useful for a large tensor?

A ring organizes chunk movement, but performance still depends on the network and workload.

哪個集體操作將每個 GPU 的資料收集到所有 GPU 持有的完整副本?

All-gather 收集每個 GPU 中的不同部分,並在所有 GPU 上組裝完整的集合,在 FSDP 等分片訓練中大量使用。

What does a supported network reduction offload such as SHARP do?

Offload capability is configuration-dependent and must be evaluated.