Let’s Get Certified
Module 09 / 15 · Scale prototypes into ML models

Size hardware and distribute training

Read a training profile before choosing accelerators or splitting a model.

Size hardware and distribute training

Work through the decision

A model fits on one accelerator. During training the accelerator waits idle while the CPU decodes images. Would adding three replicas shorten training fourfold?

Check your reasoning

Profile data input and step time first. Parallelize decoding, prefetch or change the data representation, then measure accelerator utilization again. If each replica holds the full model and input supply is adequate, data parallelism can distribute minibatches and synchronize gradients. A model that exceeds device memory may need sharding instead.

Watch the source lesson at 1:19:19

Compare the choices

Data parallelism
Replicate a model across devices, split minibatches, then aggregate updates. Communication and input supply limit scaling.
Model parallelism
Partition layers or tensors across devices when model state is too large for one device. Measure communication overhead.
Input pipeline profiling
Measure read, decode, host transfer and accelerator wait time before buying compute. Repair the measured bottleneck.
Matched hardware benchmark
Compare compatible CPU, GPU and TPU options using the same model, quality target, batch policy and workload. Include initialization and communication.

Test the decision

Benchmark representative batches including synchronization. A supported TPU can suit large tensor workloads, a GPU can suit supported deep-learning kernels and a CPU may win on small tabular jobs. Track time and cost to the same validation target.

Practice the guide skills

  1. Benchmark CPU, GPU and a supported TPU implementation using the same quality target. Include input wait, utilization, wall time and cost. Watch 1:19:19
  2. Sketch which examples and parameters live on each of four devices in data parallelism and model parallelism. Identify where synchronization or transfers occur. Watch 1:21:20

Official objectives for this lesson

Related lesson · Pay for compute when the workload uses it

Knowledge check

Size hardware and distribute training quiz

Answer 3 questions. Check each answer for an explanation.