Emmett Fear

Scaling Up Efficiently: Distributed Training with DeepSpeed and ZeRO on Runpod

How can DeepSpeed and ZeRO enable you to train large models with limited GPUs on Runpod?

Deep learning models continue to grow in size and complexity. Training a modern large language model or vision transformer often requires multiple GPUs and careful engineering to balance compute, memory and communication. For most teams and independent researchers, building an on‑prem cluster or leasing dozens of high‑end GPUs is prohibitively expensive. Yet, thanks to breakthroughs in distributed training software such as DeepSpeed and the innovative infrastructure offered by Runpod, it’s possible to train cutting‑edge models at scale without breaking the bank.

In this article you’ll learn how DeepSpeed’s Zero Redundancy Optimizer (ZeRO) and related technologies let you fit models with billions of parameters onto a single GPU and scale across many GPUs efficiently. We’ll explore how DeepSpeed achieves high performance and memory efficiency, then show how to combine these capabilities with Runpod’s Cloud GPUs, Serverless compute, and Instant Clusters to run your own distributed training jobs. By the end, you’ll have a roadmap for training bigger models faster, along with multiple opportunities to try Runpod’s platform for yourself.

The challenge of training large models

A typical transformer model has millions or billions of parameters. Training such a model involves storing the weights, gradients, optimizer states and activations in memory. Traditional data‑parallel training replicates all these states on each GPU, which means you quickly hit memory limits. To overcome this, engineers resort to complex model parallelism schemes that split layers across devices, but this increases code complexity and communication overhead.

DeepSpeed, a library from Microsoft, tackles this problem head‑on. It wraps PyTorch models and implements a suite of optimizations — from mixed precision to pipeline parallelism — to accelerate training with minimal code changes. The standout feature is the ZeRO optimizer, which partitions model states and gradients across GPUs rather than replicating them. ZeRO reduces memory consumption by up to eight times compared with traditional data‑parallel approaches. As a result, DeepSpeed users have produced language models with over 17 billion parameters without resorting to heavy model parallelism.

A subsequent extension called ZeRO‑Offload pushes the boundary further. ZeRO‑Offload uses CPU memory to host optimizer states and activations, letting a single GPU train models with up to 13 billion parameters — ten times larger than what’s possible with existing approaches. By offloading certain computations to the CPU while overlapping communication, ZeRO‑Offload democratizes billion‑scale model training on commodity hardware.

Beyond memory savings, DeepSpeed focuses on speed. For example, the library trained BERT‑large to convergence in just 44 minutes using 1,024 V100 GPUs and achieved parity with 256 GPUs in 2.4 hours. This acceleration comes from efficient compute, communication and memory kernels, as well as support for large batch optimizers like LAMB.

Why distributed training belongs on Runpod

Leveraging DeepSpeed’s innovations is only part of the equation. You also need access to reliable, affordable compute that can scale from a single GPU to a multi‑node cluster. Runpod provides exactly that:

  • Cloud GPUs: Runpod’s Cloud GPUs product lists dedicated instances with NVIDIA H100, A100, A40 and other GPUs. You can spin up powerful instances on demand and pay per second, avoiding long‑term contracts.
  • Instant Clusters: For multi‑node jobs, Instant Clusters let you provision clusters with up to 64 GPUs across 8 nodes in minutes. Each cluster includes high‑speed interconnects and supports distributed frameworks such as DeepSpeed, PyTorch’s torchrun and Ray. Billing is per second and you can tear down the cluster when training finishes.
  • Serverless: For inference and smaller training tasks, Runpod’s serverless GPU platform gives you autoscaling compute that starts in milliseconds and charges only for the time your code runs.

By combining DeepSpeed’s memory‑efficient training with Runpod’s flexible infrastructure, you can train massive models at a fraction of the cost of traditional cloud vendors. For example, use ZeRO‑Offload to train a 13 billion‑parameter model on a single A100 80 GB GPU instance, or distribute a 70 billion‑parameter model across a four‑node Instant Cluster with fast networking. Since Runpod uses per‑second billing and no long‑term commitments, you pay only for what you use.

Getting started with DeepSpeed on Runpod

Running DeepSpeed on Runpod is straightforward:

  1. Choose your infrastructure. For small to medium models (up to ~10 billion parameters with ZeRO‑Offload), a single high‑memory GPU such as an A100 80 GB may suffice. Larger models benefit from Instant Clusters. Browse the Cloud GPUs page and Instant Clusters page to choose your GPU type and region.
  2. Create an account. Sign up for Runpod and deploy your first GPU pod directly from the console. The deployment page lets you configure GPU type, memory, storage and region. If you want to experiment before committing, start with a spot instance to save on costs.
  3. Prepare your environment. Runpod instances come with popular deep learning frameworks preinstalled. For DeepSpeed, install the library via pip (pip install deepspeed). You can also bring your own Docker container; refer to Runpod’s docs for customizing images.
  4. Enable DeepSpeed and ZeRO. Modify your training script to import DeepSpeed and add a configuration file specifying ZeRO settings. A minimal config partitions optimizer states and gradients across GPUs; enabling ZeRO‑Offload only requires adding a few lines to move states to CPU.
  5. Launch distributed training. For single‑GPU ZeRO‑Offload jobs, simply run your script. For multi‑GPU training, use torchrun or DeepSpeed’s launcher with the appropriate --num_gpus argument. Instant Clusters automatically configure network interfaces and hostfiles for you. Monitor your job via Runpod’s dashboard and scale up or down as needed.

Throughout training, you can access Runpod’s metrics to track GPU utilization and billing. When the model converges, store checkpoints in object storage or transfer them to your own cloud. Then delete the cluster and pay only for the seconds used.

Best practices for efficient distributed training

While DeepSpeed abstracts away much of the complexity of distributed training, you can further optimize your jobs:

  • Use mixed precision. DeepSpeed supports FP16 and BFLOAT16 training out of the box, reducing memory footprint and speeding up matrix multiplications without sacrificing accuracy.
  • Tune batch size. Large batch training can improve throughput and convergence. DeepSpeed’s LAMB optimizer helps maintain accuracy even with very large batches.
  • Leverage pipeline parallelism. For extremely large models, pipeline parallelism allows you to split the model across multiple GPUs while keeping the memory benefits of ZeRO.
  • Monitor and profile. Runpod’s monitoring tools make it easy to view GPU utilization, network throughput and memory usage. DeepSpeed also provides a flops profiler and wall‑clock breakdown to identify bottlenecks.
  • Start small and scale. Test your training loop on a single GPU, then scale up to multiple GPUs once everything works. Runpod’s per‑second billing makes it affordable to iterate and experiment.

Why choose Runpod for your distributed training projects?

There are many cloud providers that offer GPU instances, but Runpod stands out thanks to its flexibility, price transparency and performance. With Runpod you get:

  • Per‑second billing: Only pay for the compute time you actually use. This is especially valuable for iterative experimentation and short jobs.
  • Zero hidden fees: Pricing is straightforward; there are no surprise egress or API fees. Check out the pricing page to compare GPU types and rates.
  • Global reach and low latency: Runpod operates data centers across multiple regions, giving you control over latency and data sovereignty.
  • Community and secure clouds: Choose between cost‑efficient community compute or enterprise‑grade secure environments.
  • Support for the latest hardware: Runpod regularly adds cutting‑edge GPUs like NVIDIA H100, ensuring your training jobs run on the fastest hardware available.

Want to experience the benefits yourself? Start your journey with Runpod today by signing up for an account and deploying your first GPU pod. The console makes it quick to get started.

Build what’s next.

The most cost-effective platform for building, training, and scaling machine learning models—ready when you are.