FrameworksFine-TuningML

Hugging Face Accelerate Documentation

by Hugging Face

IntermediateDocumentationFree~2-3 hours for the tutorials; reference docs thereafter, self-paced

Take a plain PyTorch training loop to multi-GPU, FSDP, DeepSpeed or TPU by changing about five lines.

Start LearningAdded Aug 19, 2026 · Updated Aug 19, 2026

Overview

Accelerate is Hugging Face's abstraction for running the same PyTorch code across any distributed configuration. The integration is deliberately minimal: instantiate an Accelerator, pass model, optimizer, dataloader and scheduler through accelerator.prepare(), and swap loss.backward() for accelerator.backward(loss) — roughly five lines added to an ordinary training loop, with the loop itself left under your control rather than hidden behind a Trainer class. Built on torch.distributed and torch_xla, it targets CPU, multi-CPU across nodes, single GPU, multi-GPU across single or multiple nodes, and TPU/XLA. It exposes automatic mixed precision in FP16, BF16 and FP8, gradient accumulation, Fully Sharded Data Parallel, DeepSpeed and Megatron-LM integrations, experiment-tracker hooks, and big-model inference via device_map for models that will not fit on one accelerator. The accelerate CLI handles interactive configuration and launching with accelerate launch, a notebook_launcher covers Jupyter and Colab, and a model memory estimator lets you size hardware before renting it. The documentation is organised in four parts: Tutorials for first-time users, How-to guides for specific goals such as DeepSpeed and FSDP, Conceptual guides that explain subtle distributed pitfalls like gradient synchronization, and a full API Reference. Apache-2.0 licensed with roughly 9.8k stars, it is depended on by 11 major projects including Hugging Face Transformers, Stable Diffusion web UI, InvokeAI, Catalyst and fastai.

At a Glance

Topic
Frameworks
Level
Intermediate
Format
Documentation
Cost
Free
Duration
~2-3 hours for the tutorials; reference docs thereafter, self-paced
Provider
Hugging Face
Hands-on
Yes — code/exercises
Certificate
None

What You’ll Learn

  • Convert an existing single-GPU PyTorch training loop to multi-GPU with about five lines
  • Configure and launch distributed runs using accelerate config and accelerate launch
  • Enable FSDP or DeepSpeed sharding without rewriting your training code
  • Use automatic mixed precision in FP16, BF16 or FP8 across supported hardware
  • Load and run models too large for one accelerator using device_map big-model inference
  • Avoid subtle distributed bugs around gradient synchronization, accumulation and dataloader sharding
  • Estimate a model's memory footprint before provisioning GPUs, and launch runs from a notebook

Highlights

  • You keep your own training loop — unlike Trainer-style APIs that take control of it
  • One script covers CPU, single GPU, multi-node GPU and TPU/XLA with no code branches
  • Conceptual guides explicitly document distributed pitfalls such as gradient synchronization, not just the happy path
  • notebook_launcher makes multi-GPU work from Colab and Jupyter, which most distributed libraries refuse
  • Foundational infrastructure: 11 major projects including Transformers, fastai, Catalyst and InvokeAI build on it

Who It’s For

Best For

  • Engineers scaling a working single-GPU fine-tune to multiple GPUs or nodes
  • Anyone choosing between DDP, FSDP and DeepSpeed for a given model size
  • Researchers who want distributed training without giving up a custom training loop
  • Practitioners running large models on constrained or mixed hardware

Prerequisites

  • Working knowledge of PyTorch: models, optimizers, dataloaders and training loops
  • Basic Python packaging and command-line comfort
  • Access to at least one GPU to exercise anything beyond the CPU examples

FAQ

What is Hugging Face Accelerate Documentation?

The library that sits between your PyTorch training loop and whatever hardware you actually have. Accelerate wraps model, optimizer, dataloader and scheduler so the same script runs on CPU, one GPU, multi-node GPU or TPU/XLA, with mixed precision, FSDP or DeepSpeed enabled by configuration rather than a rewrite. It is also the distributed layer under Hugging Face Transformers and ten other major PyTorch projects.

Is Hugging Face Accelerate Documentation free?

Hugging Face Accelerate Documentation is free to access.

What level is Hugging Face Accelerate Documentation for?

Hugging Face Accelerate Documentation is aimed at a intermediate audience. Recommended background: Working knowledge of PyTorch: models, optimizers, dataloaders and training loops, Basic Python packaging and command-line comfort, Access to at least one GPU to exercise anything beyond the CPU examples.

How long does Hugging Face Accelerate Documentation take?

Expect roughly ~2-3 hours for the tutorials; reference docs thereafter, self-paced. Most learners work through it at their own pace.

What will I learn from Hugging Face Accelerate Documentation?

You'll learn: Convert an existing single-GPU PyTorch training loop to multi-GPU with about five lines; Configure and launch distributed runs using accelerate config and accelerate launch; Enable FSDP or DeepSpeed sharding without rewriting your training code; Use automatic mixed precision in FP16, BF16 or FP8 across supported hardware; Load and run models too large for one accelerator using device_map big-model inference; Avoid subtle distributed bugs around gradient synchronization, accumulation and dataloader sharding; Estimate a model's memory footprint before provisioning GPUs, and launch runs from a notebook.

Topics

distributed trainingPyTorchFSDPDeepSpeedmixed precisionHugging Face

Sources

This page was written from 2 sources, 1 on domains other than huggingface.co.

  1. 1.huggingface.coindexvendor
  2. 2.github.comaccelerate