第13章計算の性能
13.7.2. Ring Synchronization13.7.2 リング同期
When it comes to synchronization on modern deep learning hardware we often encounter significantly bespoke network connectivity. For instance, the AWS p3.16xlarge and NVIDIA DGX-2 instances share the connectivity structure of Fig. 13.7.4. Each GPU connects to a host CPU via a PCIe link which operates at best at 16 GB/s. Additionally each GPU also has 6 NVLink connections, each of which is capable of transferring 300 Gbit/s bidirectionally. This amounts to around 18 GB/s per link per direction. In short, the aggregate NVLink bandwidth is significantly higher than the PCIe bandwidth. The question is how to use it most efficiently.
英語のヒント
現代の深層学習のハードウェアでの同期となると、かなり特注のネットワーク接続に出会うことが多い。たとえば、AWSのp3.16xlargeとNVIDIA DGX-2のインスタンスは、図13.7.4の接続構造を共有している。各GPUは、せいぜい16 GB/sで動作するPCIeリンクでホストのCPUにつながる。さらに、各GPUには6本のNVLink接続もあり、それぞれが双方向に300 Gbit/sを転送できる。これは、リンクあたり、方向あたり約18 GB/sになる。要するに、NVLinkの合計帯域はPCIeの帯域よりずっと大きい。問題は、それを最も効率よく使う方法である。
Image omitted because its reuse rights could not be verified.権利の確認ができないため画像を割愛。
Fig. 13.7.4図13.7.4
NVLink connectivity on 8 V100 GPU servers (image courtesy of NVIDIA).
英語のヒント
8個のV100 GPUのサーバーでのNVLinkの接続(画像はNVIDIAの提供)。
It turns out that the optimal synchronization strategy is to decompose the network into two rings and to use them to synchronize data directly (Wang et al., 2018). Fig. 13.7.5 illustrates that the network can be decomposed into one ring (1-2-3-4-5-6-7-8-1) with double NVLink bandwidth and into one (1-4-6-3-5-8-2-7-1) with regular bandwidth. Designing an efficient synchronization protocol in this case is nontrivial.
英語のヒント
最適な同期の戦略は、ネットワークを二つのリングに分解し、それらを使ってデータを直接同期させることだとわかっている(Wang et al., 2018)。図13.7.5は、ネットワークを、NVLinkの帯域が2倍の一つのリング(1-2-3-4-5-6-7-8-1)と、通常の帯域のもう一つのリング(1-4-6-3-5-8-2-7-1)に分解できることを示している。この場合、効率的な同期のプロトコルを設計するのは自明ではない。
Fig. 13.7.5図13.7.5
Decomposition of the NVLink network into two rings.
英語のヒント
NVLinkのネットワークの二つのリングへの分解。
Consider the following thought experiment: given a ring of computing nodes (or GPUs) we can send gradients from the first to the second node. There it is added to the local gradient and sent on to the third node, and so on. After steps the aggregate gradient can be found in the last-visited node. That is, the time to aggregate gradients grows linearly with the number of nodes. But if we do this the algorithm is quite inefficient. After all, at any time there is only one of the nodes communicating. What if we broke the gradients into chunks and started synchronizing chunk starting at node ? Since each chunk is of size the total time is now . In other words, the time spent to aggregate gradients does not grow as we increase the size of the ring. This is quite an astonishing result. Fig. 13.7.6 illustrates the sequence of steps on nodes.
英語のヒント
次の思考実験を考えよう。個の計算ノード(あるいはGPU)のリングが与えられたとき、最初のノードから2番目のノードに勾配を送れる。そこで勾配は局所的な勾配に足され、3番目のノードに送られる、というように続く。ステップの後、集約した勾配は最後に訪れたノードにある。つまり、勾配を集約する時間はノードの数に比例して増える。しかし、こうすると、アルゴリズムはかなり効率が悪い。結局のところ、どの時点でも通信しているノードは一つしかない。勾配を個の塊に分け、塊の同期をノードから始めたらどうだろうか。各塊の大きさはなので、全体の時間はいまやになる。言い換えると、勾配を集約するのにかかる時間は、リングの大きさを増やしても増えない。これはかなり驚くべき結果である。図13.7.6は、個のノードでのステップの流れを示している。
Fig. 13.7.6図13.7.6
Ring synchronization across 4 nodes. Each node starts transmitting parts of gradients to its left neighbor until the assembled gradient can be found in its right neighbor.
英語のヒント
4個のノードにわたるリング同期。各ノードは、組み立てた勾配が右隣のノードで得られるまで、勾配の一部を左隣のノードに送り始める。
If we use the same example of synchronizing 160 MB across 8 V100 GPUs we arrive at approximately . This is better than using the PCIe bus, even though we are now using 8 GPUs. Note that in practice these numbers are a bit worse, since deep learning frameworks often fail to assemble communication into large burst transfers.
英語のヒント
8個のV100 GPUで160 MBを同期させる同じ例を使うと、およそになる。いまは8個のGPUを使っているにもかかわらず、これはPCIeバスを使うよりよい。深層学習のフレームワークはしばしば通信を大きなバースト転送にまとめられないので、実際にはこれらの数字は少し悪くなることに注意してほしい。
Note that there is a common misconception that ring synchronization is fundamentally different from other synchronization algorithms. The only difference is that the synchronization path is somewhat more elaborate when compared with a simple tree.
英語のヒント
リング同期はほかの同期のアルゴリズムと根本的に違う、というよくある誤解があることに注意してほしい。唯一の違いは、単純な木と比べて、同期の経路がいくらか凝っていることである。