accelerate

A thin PyTorch wrapper that runs the same raw training script on CPU, multi-GPU, or TPU with mixed precision, DeepSpeed, and FSDP support.

Library
PyPI
v1.14.0
9,841stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
91/100Excellent
Development Activity92
Maintenance100
Community72
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
87/100Excellent
Architecture90
Code Quality88
Innovation85
Learning Curve85

Accelerate is Hugging Face’s library for running unmodified PyTorch training loops across any hardware configuration — single CPU, single GPU, multiple GPUs, or TPU pods — without rewriting the training code for each target. Instead of asking developers to learn a new high-level trainer abstraction, it wraps the model, optimizer, and dataloader through a single Accelerator.prepare() call and lets the rest of a standard PyTorch script stay untouched.

The library also ships an accelerate launch CLI and accelerate config wizard that generate a hardware-aware launch configuration once, so the same script can be invoked identically in a Jupyter notebook, on a workstation, or across a Slurm/multi-node cluster. Under the hood it integrates directly with DeepSpeed, FSDP, Megatron-LM, and mixed-precision (fp16/bf16/fp8) execution, giving teams a single code path from local debugging to production-scale distributed training.

What You Get

  • Accelerator class - a single object whose prepare() call wraps model, optimizer, and dataloaders for the current hardware without touching training-loop logic.
  • accelerate launch / accelerate config CLI - interactive wizard and launcher that generate and reuse a hardware-specific config instead of hand-writing torchrun or TPU launch commands.
  • Mixed precision out of the box - fp16, bf16, and fp8 (via TransformerEngine/torchao) execution controlled by config rather than manual autocast wiring.
  • DeepSpeed, FSDP, and Megatron-LM integrations - large-model training strategies configured through DeepSpeedPlugin/FullyShardedDataParallelPlugin instead of separate launch scripts.
  • notebook_launcher - spins up distributed training directly from a Jupyter/Colab/Kaggle cell, useful for TPU notebooks that can’t shell out to a CLI.
  • big_modeling utilities - init_empty_weights and disk/CPU offloading helpers for loading models too large to fit in GPU memory, used for inference on huge checkpoints.

Common Use Cases

  • Scaling an existing PyTorch script - a team with a working single-GPU training loop wraps it with Accelerator.prepare() to run unchanged on 8 GPUs or a TPU pod.
  • Fine-tuning large language models - researchers use the DeepSpeed/FSDP plugins to fine-tune multi-billion-parameter models that don’t fit on one GPU.
  • Reproducible multi-environment training - an ML engineer runs accelerate config once per machine so the same launch command works on a laptop, a shared server, and a Slurm cluster.
  • Framework authors building on top of raw PyTorch - libraries like Transformers’ Trainer and fastai use Accelerate internally so their own users get multi-device support for free.
  • Low-memory inference on large checkpoints - engineers use init_empty_weights and automatic device/disk offloading to run inference on models that exceed available VRAM.

Under The Hood

Architecture The library is organized around a small number of composable layers rather than a monolithic trainer: state.py holds the process-group/device singleton (AcceleratorState) that every other module reads from, accelerator.py (the ~4,400-line core) exposes the public Accelerator class whose prepare() dispatches model/optimizer/dataloader wrapping to backend-specific code paths (DeepSpeed, FSDP, Megatron, plain DDP), data_loader.py reimplements PyTorch’s DataLoader to handle distributed sharding and prefetching transparently, and big_modeling.py/hooks.py implement device-placement hooks for offload-based inference. This separation means the same user-facing accelerator.prepare(...) call routes through entirely different execution strategies depending on the active AcceleratorState, and the commands/ package (the accelerate launch/config CLI) is a thin layer on top that only generates the config consumed by state.py — a change to the core abstraction (Accelerator.prepare) has to stay backward-compatible across every backend module in utils/ (deepspeed.py, fsdp_utils.py, megatron_lm.py, transformer_engine.py) simultaneously.

Tech Stack The project targets Python 3.10+ and pins a minimal runtime dependency set — numpy, packaging, psutil, pyyaml, torch>=2.0.0, huggingface_hub>=0.21.0, and safetensors — keeping the base install lightweight, with heavy integrations (DeepSpeed, torchao for fp8, bitsandbytes, transformers, wandb/tensorboard/dvclive/trackio trackers) pulled in only via extras_require groups in setup.py. Packaging is standard setuptools with a src/ layout, console-script entry points register the accelerate, accelerate-config, accelerate-launch, and accelerate-merge-weights CLIs, and CI (.github/workflows/) runs a dedicated build-and-test matrix plus nightly, Gaudi3-scheduled, and self-hosted integration-test workflows on top of the standard test suite.

Code Quality The tests/ directory contains 38 test modules covering the accelerator core, each backend integration (DeepSpeed, FSDP, Megatron, TPU), the CLI, and utility modules, using pytest with pytest-xdist/pytest-subtests/pytest-order for parallel and ordered execution as declared in the test_prod/test_dev extras. Linting and formatting run through ruff (configured in pyproject.toml with an extended PEP8/import-sorting/copyright ruleset and a banned-API check that forbids raw os.getenv calls in favor of os.environ), enforced via .pre-commit-config.yaml and a dedicated quality.yml CI workflow, and the codebase is fully type-hinted in its public API surface.

What Makes It Unique Accelerate’s distinguishing choice is refusing to introduce a new training-loop abstraction: instead of a Trainer.fit()-style API that owns the loop, it wraps only the objects (model, optimizer, dataloader) a developer already has and returns control immediately, so a five-line diff turns a single-GPU script into one that runs unchanged across CPU/multi-GPU/TPU/DeepSpeed/FSDP. That design is also why other frameworks (Transformers’ Trainer, fastai, Catalyst) build on top of it rather than around it — it functions as a distributed-execution substrate other libraries compose with, not a competing high-level framework.

Used by 13 apps in this directory

Python
90%
Apache 2.0

ART

AI Development

10,682

Give your LLM agents on-the-job training—ART lets you apply GRPO reinforcement learning to any multi-step agentic workflow with minimal code changes.

View details
84
Repo Health
82
Technical
73
Dependency
Built with
Python90%
Updated 2 days ago
Python
89%
AGPL 3.0

clarity-upscaler

AI Design Tools · Design Tools

5,118

Free open-source AI image upscaler reaching 13K resolution using Stable Diffusion, ControlNet, and Tiled Diffusion — a self-hostable alternative to Magnific.

View details
36
Repo Health
49
Technical
67
Dependency
Built with
Python89%
Updated 1 years ago
Python
100%
Apache 2.0

ClearML

Devops · Automation

6,846

Auto-magical MLOps platform that tracks experiments, versions data, orchestrates pipelines, and serves models with just two lines of code.

View details
94
Repo Health
79
Technical
69
Dependency
Built with
Python100%
Updated 1 weeks ago
Go
59%
Apache 2.0

Cog

AI Development · Devops · Developer Tools

9,464

An open-source CLI that packages machine learning models into standard, production-ready Docker containers — no Dockerfile wrangling, no CUDA version hell.

View details
90
Repo Health
88
Technical
69
Dependency
Built with
Go59%
Rust17%
HTML13%
Updated 4 days ago
Python
91%
MIT

Gemma Multimodal Fine-Tuner

AI Development

1,498

An Apple-Silicon-native LoRA fine-tuning tool for Gemma on text, image, and audio data — with a wizard CLI, live browser-based training visualizer, and streaming from GCS/BigQuery for datasets too large for local disk.

View details
49
Repo Health
68
Technical
74
Dependency
Built with
Python91%
Updated 2 weeks ago
C++
52%
MIT

GPT4All

AI Development · AI Assistants

77,392

Run large language models privately on your laptop — no GPU, no cloud, no data leaving your device.

View details
53
Repo Health
80
Technical
74
Dependency
Built with
C++52%
QML30%
Updated 1 years ago
Python
81%
Apache 2.0

headroom

AI Development · Developer Tools

68,054

Compress everything your AI agent reads — tool outputs, logs, RAG chunks, and files — before it reaches the LLM, achieving 60–95% fewer tokens with the same answers.

View details
84
Repo Health
86
Technical
72
Dependency
Built with
Python81%
Rust13%
Updated today
Python
61%
Apache 2.0

marimo

Developer Tools · Data Engineering

22,545

A reactive Python notebook that eliminates hidden state, runs reproducibly, and deploys as a web app or script — stored as pure Python, built for the AI era.

View details
89
Repo Health
91
Technical
65
Dependency
Built with
Python61%
TypeScript37%
Updated yesterday
Go
91%
MIT

NornicDB

Databases · AI Development

852

A single graph+vector+temporal database for AI workloads — Neo4j-compatible, sub-millisecond hybrid search, and built-in memory decay.

View details
78
Repo Health
82
Technical
72
Dependency
Built with
Go91%
Updated 2 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search