Cert EspressoLearn. Practise. Find your flow.

A LITTLE FOCUS.
A BIG NEXT STEP.

Your pace. Your space.
Google Cloud · Professional Machine Learning Engineer

Hardware and distributed training

Professional Machine Learning Engineer · Lesson 11 of 19 · 1:18:47

YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗

Learning with these videos? Subscribe for new courses and exam-style questions.

In this lesson

Prepare for the Google Cloud Professional Machine Learning Engineer exam, on the official exam guide. In this lesson: choosing CPUs, GPUs, or TPUs, when TPUs do not fit, data parallelism and model parallelism, worker pools in distributed training jobs, and Reduction Server. Includes three original practice questions, with Cymbal Insurance, a fictional car and home insurer, as the example.

Study notes

The text of this lesson, to read at your own pace. Information as of November 2026.

Three days per run

Cymbal Insurance's damage severity model now takes three days per training run, on CPUs. The team wonders whether it needs GPUs, TPUs, or simply more machines. The right answer depends on what the model spends its time doing.

CPUs, GPUs, and TPUs

Each kind of hardware has its sweet spot. CPUs suit quick prototypes, simple models that train fast, small batches, and models limited by input and output rather than computation. GPUs suit medium to large models with larger batches, and models with custom PyTorch or JAX operations, with many types available, from L4 to H100 and B200. TPUs suit models dominated by matrix computations, with no custom operations in the main training loop, large models with large batches, very large embeddings for ranking and recommendations, and runs that last for weeks or months.

When TPUs do not fit

TPUs are not suited to programs with frequent branching or many element by element operations, nor to workloads that need high precision arithmetic. Custom operations inside the main training loop, and tensors whose shapes keep changing, also slow them down, because the compiler must rebuild the program for each new shape. And faster hardware only helps when the job is limited by computation: if the model waits for data, speed up the data input first, before buying bigger accelerators.

Data and model parallelism

There are two main ways to spread training over many devices. In data parallelism, every worker holds a full copy of the model and trains on a different slice of the data, and the gradients are combined at each step: it is the simplest way to go faster, as long as the model fits on one device. In model parallelism, the model itself is split across devices, by layers or by tensors, when it is too large for one accelerator's memory, at the price of more communication. The largest models combine both, on TPU slices or on GPUs with fast links between them.

Distributed training on Agent Platform

On Agent Platform, a distributed custom job is a set of worker pools. The first pool holds exactly one primary replica, which coordinates the others, and the second pool holds the workers. The third pool holds parameter servers, or Reduction Server, and the fourth pool holds evaluators. Reduction Server is an all reduce algorithm in its own worker pool, which cuts the time spent exchanging gradients in multi node GPU training, with data parallelism in TensorFlow or PyTorch. Distributed training also works inside training pipelines and hyperparameter tuning jobs.

Recap

Let's recap. CPUs for prototypes and small models, GPUs for larger models and custom operations, and TPUs for large matrix workloads that train for weeks. TPUs do not fit branching, high precision, custom operations in the loop, or changing shapes. Data parallelism copies the model and splits the data, and model parallelism splits a model too large for one device. Worker pools hold one primary replica, workers, parameter servers or Reduction Server, and evaluators. And Reduction Server speeds up gradient exchange in multi node GPU training.

Quick checks for this lesson

The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.

  1. A large transformer model is dominated by matrix multiplications, has no custom operations, uses very large batches, and will train for several weeks. Which hardware fits best?

    • A large pool of CPUs
    • A TPU slice
    • One small GPU, such as one L4
    • A faster disk for the training data
    Show the answer

    A TPU slice

    TPUs are built for large matrix computations, large batches, and runs that last for weeks. “A large pool of CPUs” would take far too long, because CPUs are suited to small, simple models. “One small GPU, such as one L4” would be far too small for a large transformer. And “A faster disk for the training data” would not help, because this model is limited by computation, not by data input.

  2. A new model is too large to fit in the memory of one GPU, even with a batch of one example. How should training be spread out?

    • Data parallelism on eight GPUs
    • A smaller batch size
    • A primary replica with no workers
    • Model parallelism across several GPUs
    Show the answer

    Model parallelism across several GPUs

    Model parallelism splits the model itself across several devices, so each one holds only a part. “Data parallelism on eight GPUs” would give each worker a full copy, which still does not fit. “A smaller batch size” would not shrink the model, which already fails with one example. And “A primary replica with no workers” would only add a coordinator, while the model still does not fit.

  3. A PyTorch model trains with data parallelism on eight GPU nodes, and profiling shows that exchanging gradients between nodes is now the bottleneck. What should the team add?

    • A Reduction Server worker pool
    • Eight more GPU nodes
    • An evaluator worker pool
    • A larger disk on each node
    Show the answer

    A Reduction Server worker pool

    Reduction Server speeds up the exchange of gradients in multi node GPU training with data parallelism. “Eight more GPU nodes” would add more nodes, and so even more gradients to exchange. “An evaluator worker pool” would only evaluate the model, and changes nothing in training speed. And “A larger disk on each node” would not move any gradients, so the bottleneck would stay.