liveBook · Manning

Distributed training

As explained in Designing Deep Learning Systems: A guide for software engineers

Distributed training is the process of training a machine learning model across multiple computing devices or processes, often with data partitioned among workers.

Distributed training runs model training across multiple CPU or GPU devices so larger datasets and models can be trained faster. A training service treats distributed code as a workload to schedule: it provisions a worker group, supplies framework-specific communication settings, starts the processes, and returns the trained model. This keeps execution infrastructure separate from model development. section 4.0 section 4.2.4 section 3.6

Choose the parallelism strategy according to the model and operational cost. Data parallelism partitions data among devices, has standardized conversion patterns, and usually needs only small changes to single-device code. Model parallelism splits a network into sequential subnetworks on different devices; pipeline parallelism further divides batches into microbatches so devices can overlap work rather than sit idle. Model and pipeline approaches require architecture-specific changes and are harder to debug. section 4.1 section 4.5

A production-oriented distributed run has distinct responsibilities:

  • Data scientists adapt training code for the selected framework and request a worker-group size. section 4.2.4 section 4.3.1
  • The training service allocates workers, assigns addresses and task indexes, initializes distributed libraries, and launches the processes. section 4.2.4
  • Kubernetes manages cluster resources, pod execution, interworker communication, and job status for distributed jobs. section 4.3.1
  • The master worker can report synchronized progress and persist models or checkpoints, avoiding duplicate output from every worker. section 4.5

TensorFlow worker configuration

Each TensorFlow worker receives a tf_config environment value describing the worker cluster and its own task type and index. A service generates these values automatically when dynamically provisioning workers, rather than requiring users to determine IP addresses and indexes themselves. section 4.2.4

tf_config = {
  'cluster': {
    'worker': ['192.168.4.53:12345', '192.168.4.55:23456']
  },
 
  # A 'task' provides information of the current task 
  # and is different for each worker. It specifies 
  # the 'type' and 'index' of that worker.
  'task': {'type': 'worker', 'index': 0}
}

The configuration shows two worker endpoints and identifies the current worker by its task index, enabling distributed processes to locate one another. section 4.2.4

Use a unified training API across local Docker execution and Kubernetes-backed distributed execution. Containerized code and a clear protocol let the service run single-device or distributed workloads without interpreting model algorithms. TensorFlow, PyTorch, and Horovod differ in APIs and configuration, but their worker-based execution workflow can be supported through one service approach; Horovod can additionally provide one execution method across several frameworks. section 4.3.1 section 3.6 section 4.5

Distributed execution introduces operational concerns beyond speed: availability, resilience, and failure recovery matter for worker groups. When a model does not fit on one GPU, memory-saving techniques such as gradient accumulation or memory swapping are easier to implement but slow training; model parallelism is the alternative strategy. section 4.5

How Designing Deep Learning Systems: A guide for software engineers covers it

How deep it goes
Explains parallelism trade-offs, worker configuration, service orchestration, and Kubernetes execution without mathematical derivations.
Examples
Uses TensorFlow tf_config worker addresses and indexes, an intent-classification PyTorch workload, and Kubernetes job-tracker architecture.
What it assumes
Assumes model training code and introduces distributed execution patterns alongside service and worker-group responsibilities.
What you can do after
Operate/configure distributed training runs by selecting workers, frameworks, and Kubernetes-backed execution while preserving a unified API.
How it connects
Connects data parallelism, model parallelism, pipeline parallelism, Kubernetes, Docker, TensorFlow, PyTorch, and Horovod.

Also explained in

Compare how 6 books explain distributed training →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Designing Deep Learning Systems: A guide for software engineers. The section links point to the parts of the book it draws on.