
accelerate
Distribute PyTorch training to multi-GPU and TPU with four lines
Replaces Lightning Ai, Amazon Sagemaker, Google Cloud Vertex Ai, Azure Machine Learning, Run Ai

Who it's for
Researchers who develop models on a single GPU and need to move to multi-GPU training for larger models can reuse their existing training scripts with minimal changes. Accelerate handles the distributed communication without requiring a rewrite of the core training logic.
If your training scripts are already written for a high-level framework like PyTorch Lightning or Keras, adopting Accelerate adds complexity without benefit. It is designed for users who already write raw PyTorch training loops.
Teams training models with billions of parameters that exceed single-GPU memory can use Accelerate's DeepSpeed ZeRO and FSDP integrations to shard model parameters across multiple GPUs. The `accelerate config` CLI configures these strategies without requiring manual DeepSpeed config files.
DeepSpeed and FSDP support in Accelerate are marked experimental. If your production workload requires guaranteed stability on these backends, a dedicated deep learning training framework with proven large-model support may be a safer choice.
Organizations paying for Amazon SageMaker, Google Cloud Vertex AI, or Azure Machine Learning training jobs can use Accelerate on their own GPU instances as a distributed training layer. The library requires no vendor-specific APIs and runs identically across cloud providers and on-premise hardware.
If your team relies on managed data pipelines, automatic hyperparameter tuning, or integrated model deployment that SageMaker and Vertex AI provide, Accelerate covers only the distributed training portion. You would need additional tooling for the rest of the MLOps workflow.
Data scientists working in Jupyter, Colab, or Kaggle notebooks can use the `notebook_launcher` function to launch distributed training without leaving the notebook environment, including TPU backend support on Colab.
If your training run exceeds notebook session limits or requires persistent GPU access, you will need to move to a server environment. `notebook_launcher` is suitable for experiments and short training runs, not multi-hour production jobs.
The problem
Scaling a PyTorch training script from a single GPU to multi-GPU or TPU hardware is disproportionately hard. Each target configuration requires different code: separate launch commands, different device placement calls, different backends for distributed communication, and different configuration flags for DeepSpeed or mixed precision. Teams end up maintaining parallel codebases for development and production, or they adopt heavy frameworks that abstract the training loop itself, trading control for convenience. The deeper pain is that the boilerplate required for distributed training is large, brittle, and poorly documented outside the official PyTorch tutorials. Writing and maintaining custom distributed training code for every hardware target is a full-time task separate from the actual research or engineering work. Most teams either stay on a single GPU longer than their model size justifies, or they pay for managed training infrastructure that makes the hardware decision for them.
How it works
Adding five lines to an existing PyTorch script enables it to run across CPUs, single GPUs, multi-GPU nodes, multi-node clusters, and TPUs without any other modification. The `Accelerator` object handles device placement, and `accelerator.prepare()` wraps the model, optimizer, and data loader in a single call.
Automatic mixed-precision support covers FP16, BF16, and FP8 formats, including FP8 via NVIDIA TransformerEngine and Microsoft MS-AMP integrations. Enabling it requires no changes to the training loop: set the precision in the Accelerator constructor and the casting happens automatically.
Built-in support for Microsoft DeepSpeed's ZeRO optimizer stages and PyTorch Fully Sharded Data Parallel, both configured through the `accelerate config` CLI without modifying training code. A `DeepSpeedPlugin` object allows programmatic control when CLI defaults are insufficient.
The `accelerate config` command runs an interactive questionnaire that generates a config file for the target hardware. `accelerate launch my_script.py` reads that config and launches correctly, removing the need to memorize `torch.distributed.run` flags or per-platform syntax.
A `notebook_launcher` function launches distributed training directly from Jupyter, Colab, and Kaggle notebooks, including TPU backends. This covers teams who prototype in notebook environments before moving to full server runs.
Features
- Minimal code change to distribute training
- Mixed-precision training: FP16, BF16, and FP8
- DeepSpeed and FSDP integration
- `accelerate launch` CLI for any hardware target
- Notebook launcher for Colab and Kaggle
How to install
Install Accelerate via pip, then use the config command to specify your hardware target before launching training scripts.
pip install accelerate
accelerate config
accelerate launch my_script.pyRecommended for this setup
Strengths
- Apache 2.0 license with no usage restrictions: The library is Apache 2.0 licensed, meaning teams can use it commercially, modify it, and deploy it on any infrastructure without licensing fees or restrictions. Unlike managed training services that charge per compute-hour on proprietary hardware, Accelerate's cost is entirely your own infrastructure cost.
- Thin abstraction that preserves training loop control: Accelerate abstracts only the distributed boilerplate, not the training loop itself. Researchers who need custom gradient accumulation, custom optimizer steps, or non-standard model checkpointing retain full control. This is unlike high-level frameworks that require fitting your code to their API.
- Single codebase runs across all hardware configurations: The same Python script runs unchanged on a local CPU, a single GPU, a multi-GPU workstation, a multi-node cluster using MPI, and a TPU. No separate code paths for development versus production, reducing the maintenance burden when moving experiments to scale.
- Active development backed by Hugging Face Transformers: The repository receives near-daily commits and serves as the official PyTorch training backend for Hugging Face Transformers, meaning it is continuously tested against production-scale workloads. Over 9,800 GitHub stars and 1,400 forks reflect broad adoption across the ML community.
Trade-offs
- Requires writing your own training loop: Accelerate is not a high-level training framework. If you do not want to write and maintain a PyTorch training loop, the library provides no benefit. The README explicitly states this limitation. Teams that prefer abstracted training APIs should use frameworks built on top of Accelerate instead, such as fastai or Catalyst.
- DeepSpeed and FSDP support is experimental: Both DeepSpeed and Fully Sharded Data Parallel support are marked experimental in the official documentation. Teams relying on these integrations for production large-model training should expect occasional breaking changes and may need to file upstream issues or contribute fixes.
- No built-in experiment tracking or hyperparameter search: Accelerate handles distributed training primitives only. It does not include experiment logging, hyperparameter search, model evaluation, or dataset management. Teams that need a full MLOps workflow must combine it with separate tools for tracking and orchestration.
Tech stack
FAQ
No. Accelerate is not a high-level training framework and does not provide training abstractions, callbacks, or metrics. It replaces only the distributed boilerplate in a raw PyTorch training loop. PyTorch Lightning, fastai, and Catalyst are higher-level frameworks that are themselves built on top of Accelerate as a backend.
Yes. Accelerate supports CPU-only training and multi-CPU configurations, including MPI-based multi-CPU runs. CPU training is primarily useful for testing and debugging scripts before moving to GPU hardware, since training speed on CPUs is much slower for most deep learning workloads.
Accelerate is Apache 2.0 licensed, which allows commercial use, modification, and distribution without licensing fees. You can run it on your own infrastructure, integrate it into commercial products, and modify the source without any legal restrictions.
Yes. Accelerate supports FP16, BF16, and FP8 mixed precision. FP8 support requires NVIDIA TransformerEngine or Microsoft MS-AMP and is available on compatible NVIDIA hardware. Enabling mixed precision requires only a parameter change in the Accelerator constructor; no training loop changes are needed.
There is no separately managed Accelerate service. Hugging Face offers managed training infrastructure through its Inference Endpoints and AutoTrain products, but Accelerate itself is a local library you run on your own compute. It integrates with Hugging Face Transformers for managed training workflows, but the library has no cloud dependency and runs on any hardware you control.