Skip to main content
Version: v2602

NCCL Ideal Communication Bandwidth Estimation Method

The PyTorch NCCL benchmark results display the ideal communication bandwidth and how efficiently the current bus bandwidth (BusBW) achieves compared to the ideal communication bandwidth. This document explains the overview of the ideal communication bandwidth estimation method.

Notation

  • BB: Unidirectional communication bandwidth per GPU for communication paths connecting GPUs
  • II: Unidirectional communication bandwidth per node for communication paths connecting nodes
  • SS: Size of data for collective communication (bytes)
  • NN: Total number of GPUs for benchmarking
    • PP: Number of GPUs per node
    • QQ: Number of nodes
    • N=P×QN = P \times Q
  • TT: Measured execution time of collective communication
  • DD: Overall data volume to be transferred in collective communication (bytes)
  • DInterD_\textrm{Inter}: Overall data volume to be transferred in inter node communication in the collective communication (bytes)
  • DIntraD_\textrm{Intra}: Overall data volume to be transferred in intra node communication in the collective communication(bytes)

Basic Concept

BusBW in NCCL benchmarks is defined by the following formula:

BusBW=DT×N\textrm{BusBW} = \frac{D}{T \times N}

For how to calculate DD, please refer to NVIDIA's NCCL Tests documentation. For example, if it takes 0.1 seconds to perform AllReduce communication of 1GB of data using 2 nodes with 8 GPUs per node, BusBW is calculated as follows:

BusBW=DT×N=S×2×(N1)T×N=1[GB]×2×(161)0.1[s]×16=19.375[GB/s]\textrm{BusBW} = \frac{D}{T \times N} = \frac{S \times 2 \times (N - 1)}{T \times N} = \frac{1 \textrm{[GB]} \times 2 \times (16 - 1)}{0.1 \textrm{[s]} \times 16} = 19.375 \textrm{[GB/s]}

The BusBW calculated by this formula can be interpreted as representing the average bandwidth per GPU, determined by dividing the total bandwidth of the entire system comprised of multiple GPUs (calculated as D/TD / T) by NN.

Let TIdealT_\textrm{Ideal} denote the ideal communication time, defined as the completion time for a collective communication operation under optimal conditions. Consequently, the theoretical upper bound on BusBW (representing the ideal communication bandwidth) is obtained by substituting TT with TIdealT_\textrm{Ideal} in the BusBW equation.

Ideal communication bandwidth=DTIdeal×N\textrm{Ideal communication bandwidth} = \frac{D}{T_\textrm{Ideal} \times N}

This equation, like the BusBW formula, can be interpreted as determining the upper bound on the total system bandwidth for a system with multiple GPUs via D/TIdealD / T_\textrm{Ideal}, and subsequently dividing that value by NN to represent the upper bound on the average bandwidth per GPU.

The TIdealT_\textrm{Ideal} considered here varies based on factors within the benchmark environment, and so on. The following sections will detail the estimation of TIdealT_\textrm{Ideal} and the ideal communication bandwidth assumed by AIBooster.

Estimation Method for Single Node Execution

When running benchmarks on a single node, the ideal communication bandwidth is estimated under the following assumptions:

  • Each GPU can simultaneously send to and receive from other GPUs in the node at speed BB
  • Each GPU in the node is connected to the same network with full bisection bandwidth
  • The network to which each GPU is connected only performs communication (does not perform in-network computation)
  • Time spent on non-communication is negligibly short (e.g., computation time in AllReduce communication)

Under these assumptions, since all NN GPUs can always send and receive data at speed BB, the ideal communication time TIdealT_\textrm{Ideal} is expressed by:

TIdeal=DB×NT_\textrm{Ideal} = \frac{D}{B \times N}

Substituting this into the ideal communication bandwidth estimation formula shown in the previous section yields the following evaluation of ideal communication bandwidth for single node execution:

Ideal communication bandwidth=B\textrm{Ideal communication bandwidth} = B

For example, when running benchmarks on a single node in an environment where GPUs capable of simultaneous send/receive at B=450[GB/s]B = 450 \textrm{[GB/s]} are connected to a full bisection bandwidth network, the ideal communication bandwidth is estimated to be 450[GB/s]450 \textrm{[GB/s]} regardless of the number of GPUs.

Estimation Method for Multi-Node Execution

When running benchmarks on multiple nodes, the ideal communication bandwidth is estimated under the following assumptions:

  • Single node assumptions are satisfied
  • Each node can simultaneously send to and receive from other nodes at speed II
  • Each node is connected to an inter-node network with full bisection bandwidth
  • The network to which each node is connected only performs communication (does not perform in-network computation)
  • Intra-node GPU communication and inter-node communication do not interfere with each other's communication performance
  • The shorter communication time (intra-node GPU communication or inter-node communication) is hidden by the longer communication time

Under these assumptions, the longer communication time, whether intra-node or inter-node, is considered the execution time of the entire collective communication. Therefore, the ideal communication time TIdealT_\textrm{Ideal} is expressed by:

TIdeal=max(Ideal communication time for inter-node,Ideal communication time for intra-node)T_\textrm{Ideal} = \max(\textrm{Ideal communication time for inter-node}, \textrm{Ideal communication time for intra-node})

The ideal communication times for inter-node and intra-node are the total amount of data to be transferred in each communication divided by the inter-node and intra-node bandwidth, respectively:

Ideal communication time for inter-node=DInterI×Q,Ideal communication time for intra-node=DIntraB×N\textrm{Ideal communication time for inter-node} = \frac{D_\textrm{Inter}}{I \times Q}, \\ \textrm{Ideal communication time for intra-node} = \frac{D_\textrm{Intra}}{B \times N}

Next, we consider the proportion of DInterD_\textrm{Inter} and DIntraD_\textrm{Intra} within DD. Collective communications handled by NCCL consist of operations where each GPU exchanges data with N1N - 1 other GPUs. For example, in AllGather, each GPU needs to send its data to the remaining N1N - 1 GPUs, while in Broadcast, the root GPU needs to send its data to the other N1N - 1 GPUs. On the other hand, in Reduce, the root GPU needs to receive data from the other N1N - 1 GPUs. Furthermore, since AllReduce is a collective communication that combines reduction and broadcast operations, it requires performing two sets of such operations. We count the number of inter-node and intra-node communications required when exchanging data with the N1N - 1 other GPUs. Here, we consider the operation of a GPU sending data to the other N1N - 1 GPUs, but the same applies to receiving data. First, data can be transferred via intra-node communication only to GPUs belonging to the same node as the sending GPU. On the other hand, for GPUs belonging to different nodes from the sending GPU, data can be sent via inter-node communication to one GPU per node, and the remaining GPUs can receive the data through intra-node communication from GPUs that have already received it. Therefore, the minimum number of inter-node communications required is Q1Q - 1, and the remaining (N1)(Q1)=NQ(N - 1) - (Q - 1) = N - Q communications can be handled via intra-node communication. Although it's possible to always use inter-node communication for GPUs on different nodes, we assume here that the minimal number of inter-node communications are carried out. Therefore, the proportions of DInterD_\textrm{Inter} and DIntraD_\textrm{Intra} within DD are:

DInter=D×Q1N1,DIntra=D×NQN1D_\textrm{Inter} = D \times \frac{Q - 1}{N - 1}, \\ D_\textrm{Intra} = D \times \frac{N - Q}{N - 1}

Substituting these formulas into the formula on TIdealT_\textrm{Ideal} yields:

TIdeal=max(DInterI×Q,DIntraB×N)=max(D×(Q1)/(N1)I×Q,D×(NQ)/(N1)B×N)T_\textrm{Ideal} = \max\left( \frac{D_\textrm{Inter}}{I \times Q}, \frac{D_\textrm{Intra}}{B \times N} \right) \\ = \max\left( \frac{D \times (Q - 1) / (N - 1)}{I \times Q}, \frac{D \times (N - Q) / (N - 1)}{B \times N} \right)

Substituting this into the ideal communication bandwidth estimation formula shown in the previous section yields the following evaluation of ideal communication bandwidth for multi node execution:

Ideal communication bandwidth=Dmax(D×(Q1)/(N1)I×Q,D×(NQ)/(N1)B×N)×N=min(I×(N1)×QN×(Q1),B×(N1)NQ)\textrm{Ideal communication bandwidth} = \frac{D} { \max\left( \displaystyle \frac{D \times (Q - 1) / (N - 1)}{I \times Q}, \frac{D \times (N - Q) / (N - 1)}{B \times N} \right) \times N } \\ = \min\left(\frac{I \times (N - 1) \times Q}{N \times (Q - 1)}, \frac{B \times (N - 1)}{N - Q} \right)

For example, when executing collective communication in an environment where GPU connections are B=450[GB/s]B = 450 \textrm{[GB/s]}, inter-node connections are I=100[GB/s]I = 100 \textrm{[GB/s]}, GPUs per node P=8P = 8, and number of nodes Q=2Q = 2, the ideal communication bandwidth is estimated as min(187.5,482.1)[GB/s]=187.5[GB/s]\min(187.5, 482.1) \textrm{[GB/s]} = 187.5 \textrm{[GB/s]}.