accelerate

Convert PyTorch training scripts to distributed multi-GPU execution with HuggingFace Accelerate.

Updated Aug 22, 2026
One-click install
npx skills add https://github.com/vivekgoquest/hermes-agent-stable --skill accelerate-vivekgoquest
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: accelerate
Source: https://github.com/vivekgoquest/hermes-agent-stable/tree/main/optional-skills/mlops/accelerate
Command: npx skills add https://github.com/vivekgoquest/hermes-agent-stable --skill accelerate-vivekgoquest

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires accelerate, torch, transformers, and includes references (resource) components.

What problem does it solve? Scaling PyTorch training from a single GPU to multi-GPU or multi-node clusters normally requires rewriting code for DDP, DeepSpeed, or FSDP, which is error-prone and time-consuming. This Skill provides the patterns to make that transition with minimal code changes. ## Core Features & Use Cases - Unified Distributed API: Convert any PyTorch training loop to run on DDP, DeepSpeed ZeRO, FSDP, or Megatron-LM by adding roughly four lines of code. - Mixed Precision Training: Enable FP16, BF16, or FP8 training with automatic gradient scaling and device placement. - Configuration & Launch: Generate accelerate configs interactively and launch jobs across GPUs, nodes, or TPUs with a single command. - Use Case: You have a single-GPU training script that now needs to run on an 8-GPU node with BF16 and gradient accumulation. Apply the Accelerator pattern, run accelerate config, and launch with accelerate launch --multi_gpu --num_processes 8 train.py. ## Quick Start Convert my PyTorch training script to run on multiple GPUs using HuggingFace Accelerate and show me the launch command.

Frequently Asked Questions about accelerate

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I convert a PyTorch script to multi-GPU training?▼

Add four lines with HuggingFace Accelerate: create an Accelerator, pass your model, optimizer, and dataloader through accelerator.prepare(), and replace loss.backward() with accelerator.backward(loss). Then launch with accelerate launch --multi_gpu --num_processes 8 train.py.

Accelerate vs PyTorch Lightning vs DeepSpeed for distributed training?▼

Accelerate offers a minimal unified API over DDP, DeepSpeed, FSDP, and Megatron with about four lines of code changes. PyTorch Lightning suits users wanting callbacks and high-level abstractions, while raw DeepSpeed gives direct API control for advanced features.

Does Accelerate support DeepSpeed ZeRO and FSDP?▼

Yes, Accelerate supports DeepSpeed ZeRO stages 2 and 3 via DeepSpeedPlugin and FSDP via FullyShardedDataParallelPlugin, including CPU and NVMe offloading. You can configure them in code or through the interactive accelerate config command.

How do I enable mixed precision training with Accelerate?▼

Pass mixed_precision='fp16', 'bf16', or 'fp8' to the Accelerator constructor. BF16 needs no gradient scaling and is more stable, FP16 uses automatic gradient scaling, and FP8 requires H100 or newer GPUs.

Why is gradient accumulation not working in my training loop?▼

Gradient accumulation requires wrapping the step in the accelerator.accumulate(model) context manager and setting gradient_accumulation_steps in the Accelerator. Without the context manager, gradients synchronize every step instead of accumulating.

Can Accelerate train large models with Megatron-LM parallelism?▼

Yes, Accelerate integrates Megatron-LM through MegatronLMPlugin, supporting tensor parallelism, pipeline parallelism, sequence parallelism, and activation checkpointing. Tensor parallelism requires fast NVLink interconnects within a node.