§12.1–12.1.4Large-Scale Deep Learning · CPU · GPU · Distributed · Compression

Part II DL pp. 443–448 · ~4 min read

  • data parallelism
  • model parallelism
  • asynchronous sgd
  • parameter server
  • model compression

§12.1 Large-scale deep learning

Deep learning rests on connectionism: an individual unit is not intelligent, but a large population acting together can be. That is why size is paramount — one of the biggest drivers of neural networks’ rising accuracy from the 1980s to today was the exponential growth in network size (yet artificial nets are still only as large as an insect’s nervous system). Big networks demand serious hardware and software.

§12.1.1 Fast CPU implementations

Careful CPU specialization pays off. In 2011, a tuned fixed-point implementation beat a strong floating-point system threefold (Vanhoucke 2011) — though which is faster depends on the CPU. Other wins: cache-friendly data layout and vector instructions. Researchers who neglect these details let implementation speed cap model size, which caps accuracy.

§12.1.2 GPU implementations

Graphics hardware was built to transform many vertices and shade many pixels in parallel, with simple, branch-free arithmetic over massive memory buffers. Neural networks need exactly the same profile — large buffers of parameters, activations, and gradients (too big for cache, so memory bandwidth is the bottleneck), updated in parallel with little control flow:

Why GPUs suit neural nets — CPU vs GPU characteristics. Click a cell for detail.
CPUGPU
Parallelisma few fast coresthousands of simple cores
Memory bandwidthlowerhigh — the usual advantage
Branchingstrong (complex control)weak — warps serialize
Clock speedhighlower (traded for parallelism)
Cachinglarge caches; cache-friendly codemost writable memory uncached
Dotted-underlined cells have explanations — click one.

General-purpose GPUs (GP-GPUs) with CUDA made this programmable, and deep learning adopted them fast. Because efficient GPU code is hard, the practical workflow is to build models as calls to a library of tuned operations (convolution, matrix multiply) — Theano, TensorFlow, Torch — so the same program runs on CPU or GPU without rewriting kernels.

§12.1.3 Large-scale distributed training

When one machine isn’t enough, distribute the work. Data parallelism sends different examples to different machines — trivial for inference. Model parallelism splits a single datapoint’s model across machines. Training-data parallelism is harder: standard SGD is sequential (step tt needs the parameters from step t1t-1). The fix is asynchronous SGD — workers read the shared parameters from a parameter server , compute a gradient, and push an update without a lock. Drag the worker count to see the tradeoff:

Fig (interactive) — asynchronous SGD. More lock-free workers raise the step rate, but stale reads and overwrites cut improvement-per-step, so the net speedup is sublinear — yet still far faster than sequential SGD (Dean 2012).
parameter server θw1w2w3stalew4read (no lock)update (no lock)
ideal linearnet speedup18 workers
step rate
4.0×
improvement / step
51%
net speedup
2.0×

Each worker reads θ, computes a gradient, and writes back without a lock. With 4 workers the step rate is ~4× — but because some updates are computed from stale θ and overwrite each other, each step improves the model only 51% as much. The net speedup (2.0×) is sublinear, yet still far faster than sequential SGD — which is why distributed async SGD (Dean 2012) trains most large industrial models.

Data parallelism vs model parallelism

Data parallelism replicates the model and splits the examples; model parallelism splits the model and shares one example. They compose — a large system often does both, with asynchronous SGD coordinating parameter updates across the whole fleet.

§12.1.4 Model compression

For deployment, inference cost usually matters far more than training cost — train once on a cluster, serve billions of users on resource-constrained devices (a phone). Model compression replaces an expensive model — often a large regularized net or an ensemble — with a smaller one trained to mimic it. It works when the big model’s size was driven by preventing overfitting: once it has fit f(x)f(x), you can generate unlimited (x,f(x))(x, f(x)) training pairs to teach a compact student.

Model compression — a large model (or ensemble) labels many sampled inputs with f(x); a small student is trained to match, giving cheap inference.
large model /ensemble f(x)sample x,label with f(x)small studentcheap inferencesample from test-like distribution (corrupt data / generative model)

An alternative trains the student on the original points but to copy other features of the teacher — such as its posterior over the incorrect classes (distillation, Hinton 2015).

Next: computing only what each input needs, specialized hardware, and the start of computer vision — dynamic structure, hardware, and computer vision.

Check yourself — large-scale deep learning

1.Why does the book emphasize that the number of neurons must be LARGE?

2.Why is GPU hardware well suited to neural networks?

3.Which is a real consideration when writing high-performance GPU code?

4.What is the difference between data parallelism and model parallelism, and why is asynchronous SGD used?

5.In the AsyncSGDLab, raising the worker count increases the step rate but the net speedup stays sublinear. Why?

6.What is model compression, and when is it applicable?

6 questions