accelerate_skill

This skill simplifies distributed training with HuggingFace Accelerate, enabling seamless multi-GPU/TPU setups via a four-line integration.
  • TeX

5.2k

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill orchestra-research/ai-research-skills --skill accelerate

  • SKILL.md8.1 KB

Overview

This skill provides a minimal, unified API to add distributed training to any PyTorch script in four lines. It standardizes device placement, mixed precision (FP16/BF16/FP8), and integration with DDP, DeepSpeed, FSDP, and Megatron while exposing an interactive configuration and a single launch command. The result is a consistent workflow across single-GPU, multi-GPU, multi-node, and TPU setups.

How this skill works

Accelerate wraps your model, optimizer, and dataloader with an Accelerator instance and handles device placement, mixed-precision autocasting, gradient scaling, and backward calls. It plugs into multiple backends (native DDP, DeepSpeed ZeRO, FSDP, Megatron) via plugins or config files and exposes helpers for accumulation, checkpointing, and process coordination. Launching is done with a single CLI command that reads the interactive config or a JSON backend config.

When to use it

  • When you want to convert a single-GPU script to multi-GPU/multi-node with minimal code changes.
  • When you need unified support for DeepSpeed, FSDP, DDP, or Megatron without switching APIs.
  • When you want automatic device placement and mixed-precision support (FP16/BF16/FP8).
  • When you prefer an interactive configuration and a single launch command across environments.
  • When quick prototyping and compatibility with the HuggingFace ecosystem are priorities.

Best practices

  • Do not manually .to('cuda') tensors or models after calling prepare(); let Accelerate handle placement.
  • Use accelerator.backward(loss) and accelerator.accumulate(model) for correct gradient handling and accumulation.
  • Run accelerate config to generate backend settings and select mixed precision or plugins before launching.
  • Save and load checkpoints via accelerator.save_state and accelerator.load_state, and restrict saves to accelerator.is_main_process.
  • Set seed with accelerate.utils.set_seed for reproducible results across sharded or FSDP runs.

Example use cases

  • Convert a local single-GPU training script to an 8-GPU run by adding Accelerator.prepare and using accelerate launch.
  • Enable BF16 on supported hardware for faster training with minimal code changes via mixed_precision='bf16'.
  • Deploy ZeRO-2 DeepSpeed by passing a deepspeed config or deepspeed_plugin to Accelerator for large-model optimization.
  • Use FSDP for ZeRO-3 equivalence and full-parameter sharding with an FSDP plugin and automatic wrapping.
  • Apply gradient accumulation to simulate larger effective batch sizes across multiple devices with gradient_accumulation_steps.

FAQ

No. After model, optimizer, dataloader = accelerator.prepare(...), Accelerate handles device placement automatically.

How do I enable mixed precision?

Instantiate Accelerator with mixed_precision='fp16'|'bf16'|'fp8' or select the option in accelerate config; autocast and scaling are handled for you.

How do I checkpoint in distributed training?

Use accelerator.save_state('path') on the main process (accelerator.is_main_process) and accelerator.load_state('path') on all processes.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
accelerate skill by orchestra-research/ai-research-skills | VeilStrat