プリンキピア

第13章計算の性能

13.4.5. GPUs and other Accelerators13.4.5 GPUとそのほかのアクセラレータ

It is not an exaggeration to claim that deep learning would not have been successful without GPUs. By the same token, it is quite reasonable to argue that GPU manufacturers’ fortunes have increased significantly due to deep learning. This co-evolution of hardware and algorithms has led to a situation where for better or worse deep learning is the preferable statistical modeling paradigm. Hence it pays to understand the specific benefits that GPUs and related accelerators such as the TPU (Jouppi et al., 2017).
英語のヒント
深層学習はGPUなしには成功しなかっただろうと主張しても誇張ではない。同じ理屈で、GPUメーカーの財産が深層学習のおかげで大きく増えたと論じるのも、まったくもっともである。このハードウェアとアルゴリズムの共進化により、良くも悪くも、深層学習が望ましい統計モデリングのパラダイムであるという状況になった。したがって、GPUと、TPU(Jouppi et al., 2017)のような関連するアクセラレータの具体的な利点を理解することは割に合う。
Of note is a distinction that is often made in practice: accelerators are optimized either for training or inference. For the latter we only need to compute the forward propagation in a network. No storage of intermediate data is needed for backpropagation. Moreover, we may not need very precise computation (FP16 or INT8 typically suffice). On the other hand, during training all intermediate results need storage to compute gradients. Moreover, accumulating gradients requires higher precision to avoid numerical underflow (or overflow). This means that FP16 (or mixed precision with FP32) is the minimum requirement. All of this necessitates faster and larger memory (HBM2 vs. GDDR6) and more processing power. For instance, NVIDIA’s Turing T4 GPUs are optimized for inference whereas the V100 GPUs are preferable for training.
英語のヒント
実際によくされる区別に注意しておこう。アクセラレータは、訓練か推論のどちらかに最適化されている。後者では、ネットワークの順伝播を計算するだけでよい。誤差逆伝播のための途中のデータを格納する必要はない。さらに、それほど精密な計算は要らないかもしれない(ふつうFP16やINT8で十分である)。一方、訓練のあいだは、勾配を計算するためにすべての途中結果を格納する必要がある。さらに、勾配を累積するには、数値的なアンダーフロー(やオーバーフロー)を避けるために、もっと高い精度が要る。これは、FP16(あるいはFP32との混合精度)が最低限の要件であることを意味する。これらすべてのために、もっと速く大きなメモリ(HBM2対GDDR6)と、もっと多くの処理能力が必要になる。たとえば、NVIDIAのTuring T4 GPUは推論に最適化されており、V100 GPUは訓練に向いている。
Recall vectorization as illustrated in Fig. 13.4.5. Adding vector units to a processor core allowed us to increase throughput significantly. For example, in the example in Fig. 13.4.5 we were able to perform 16 operations simultaneously. First, what if we added operations that optimized not just operations between vectors but also between matrices? This strategy led to tensor cores (to be covered shortly). Second, what if we added many more cores? In a nutshell, these two strategies summarize the design decisions in GPUs. Fig. 13.4.7 gives an overview of a basic processing block. It contains 16 integer and 16 floating point units. In addition to that, two tensor cores accelerate a narrow subset of additional operations relevant for deep learning. Each streaming multiprocessor consists of four such blocks.
英語のヒント
図13.4.5に示したベクトル化を思い出そう。プロセッサのコアにベクトルユニットを加えたことで、スループットを大きく上げられた。たとえば、図13.4.5の例では、16の演算を同時に行えた。第一に、ベクトルのあいだの演算だけでなく、行列のあいだの演算も最適化する演算を加えたらどうだろうか。この戦略がテンソルコア(まもなく取り上げる)につながった。第二に、もっとずっと多くのコアを加えたらどうだろうか。手短に言えば、この二つの戦略が、GPUでの設計の判断を要約している。図13.4.7は、基本的な処理ブロックを概観している。そこには、16個の整数ユニットと16個の浮動小数点ユニットがある。それに加えて、二つのテンソルコアが、深層学習にかかわる追加の演算の狭い部分集合を高速化する。各ストリーミング・マルチプロセッサは、そうしたブロック四つからなる。
Image omitted because its reuse rights could not be verified.権利の確認ができないため画像を割愛。
Fig. 13.4.7図13.4.7
NVIDIA Turing processing block (image courtesy of NVIDIA).
英語のヒント
NVIDIA Turingの処理ブロック(画像はNVIDIAの提供)。
Next, 12 streaming multiprocessors are grouped into graphics processing clusters which make up the high-end TU102 processors. Ample memory channels and an L2 cache complement the setup. Fig. 13.4.8 has the relevant details. One of the reasons for designing such a device is that individual blocks can be added or removed as needed to allow for more compact chips and to deal with yield issues (faulty modules might not be activated). Fortunately programming such devices is well hidden from the casual deep learning researcher beneath layers of CUDA and framework code. In particular, more than one of the programs might well be executed simultaneously on the GPU, provided that there are available resources. Nonetheless it pays to be aware of the limitations of the devices to avoid picking models that do not fit into device memory.
英語のヒント
次に、12個のストリーミング・マルチプロセッサがグラフィックス処理クラスタにまとめられ、それらが高性能なTU102プロセッサを構成する。十分なメモリチャネルとL2キャッシュが、この構成を補う。図13.4.8に関連する詳細がある。このような装置を設計する理由の一つは、個々のブロックを必要に応じて加えたり取り除いたりして、もっとコンパクトなチップにしたり、歩留まりの問題に対処したり(故障したモジュールは有効にしないことがある)できることである。幸い、そうした装置のプログラミングは、CUDAとフレームワークのコードの層の下に隠されていて、気軽な深層学習の研究者からは見えない。特に、使える資源があれば、二つ以上のプログラムがGPUで同時に実行されることも十分ありうる。それでも、装置のメモリに収まらないモデルを選ばないように、装置の限界を知っておくことは割に合う。
Image omitted because its reuse rights could not be verified.権利の確認ができないため画像を割愛。
Fig. 13.4.8図13.4.8
NVIDIA Turing architecture (image courtesy of NVIDIA)
英語のヒント
NVIDIA Turingのアーキテクチャ(画像はNVIDIAの提供)
A last aspect that is worth mentioning in more detail are tensor cores. They are an example of a recent trend of adding more optimized circuits that are specifically effective for deep learning. For instance, the TPU added a systolic array (Kung, 1988) for fast matrix multiplication. There the design was to support a very small number (one for the first generation of TPUs) of large operations. Tensor cores are at the other end. They are optimized for small operations involving between 4×4 and 16×16 matrices, depending on their numerical precision. Fig. 13.4.9 gives an overview of the optimizations.
英語のヒント
もっと詳しく述べる価値がある最後の面は、テンソルコアである。それらは、深層学習に特に効果的な、もっと最適化された回路を加えるという最近の傾向の一例である。たとえば、TPUは、行列の積を速くするためにシストリック・アレイ(Kung, 1988)を加えた。そこでの設計は、とても少ない数(TPUの第1世代では一つ)の大きな演算をサポートすることだった。テンソルコアは反対の端にある。それらは、数値の精度に応じて4×4から16×16の行列を含む小さな演算に最適化されている。図13.4.9は、その最適化を概観している。
Image omitted because its reuse rights could not be verified.権利の確認ができないため画像を割愛。
Fig. 13.4.9図13.4.9
NVIDIA tensor cores in Turing (image courtesy of NVIDIA).
英語のヒント
TuringのNVIDIAテンソルコア(画像はNVIDIAの提供)。
Obviously when optimizing for computation we end up making certain compromises. One of them is that GPUs are not very good at handling interrupts and sparse data. While there are notable exceptions, such as Gunrock (Wang et al., 2016), the access pattern of sparse matrices and vectors do not go well with the high bandwidth burst read operations where GPUs excel. Matching both goals is an area of active research. See e.g., DGL, a library tuned for deep learning on graphs.
英語のヒント
明らかに、計算のために最適化すると、ある種の妥協をすることになる。その一つは、GPUが割り込みと疎なデータを扱うのがあまり得意でないことである。Gunrock(Wang et al., 2016)のような注目すべき例外はあるものの、疎な行列やベクトルのアクセスパターンは、GPUが得意とする高帯域のバースト読み出しの演算とうまく合わない。両方の目標を合わせることは、活発な研究分野である。たとえば、グラフでの深層学習のために調整されたライブラリであるDGLを参照。