DeepSpeed
DeepSpeed wraps a PyTorch model with a training engine that coordinates precision, optimization and distributed execution. Its ZeRO optimizer removes replicated training state across data-parallel workers, enabling configurations that would otherwise exceed device memory.
Training script
The application supplies a PyTorch module, training batches and a configuration. deepspeed.initialize() returns the wrapped engine and sets up the configured training components. The script calls the engine for forward, backward and optimization.
- Training script DeepSpeed enginetraining API calls
One pass through the system.
Select a step to highlight the components involved in the diagram.
Why it is built this way.
Sharding saves memory through communication
ZeRO-3 can fit more persistent state, but parameter gathers add traffic and synchronization. Interconnect bandwidth, bucket sizes and overlap with computation affect whether the memory saving also produces a useful step time.
Offloading moves the bottleneck
CPU or NVMe capacity extends what can fit, but those bytes must travel back when needed. Host memory bandwidth, transfer links and storage throughput can dominate. Offload is a capacity tool, not an automatic performance improvement.
A distributed step is a group operation
A single slow rank can hold up collective progress. Checkpointing and control flow must follow the engine’s distributed contract; saving only from rank zero can hang when other ranks are expected to participate.
Read the implementation.
deepspeed/runtime/engine.pyThe training engine and its forward/backward/step boundary.
deepspeed/runtime/zero/stage3.pyStage 3 optimization, gradient partitions and updates.
deepspeed/runtime/zero/partition_parameters.pyParameter partitioning and gather lifecycle.
Go deeper with the official docs
- DeepSpeed training engine and checkpoints
- ZeRO stages and memory ownership
- ZeRO-3 configuration and offload
Educational diagrams, synthesized from the linked project documentation. Components and boundaries vary by version and deployment.