跳到主要内容Skip to main content
训练与微调Training & Fine-tuning生产可用Production

Accelerate

huggingface / accelerate

把 PyTorch 的多 GPU、TPU、混合精度、梯度累积、FSDP 与 DeepSpeed 启动样板收进一个 API:设备放置、分布式启动和混合精度不用手写。Pulls PyTorch’s multi-GPU, TPU, mixed-precision, gradient-accumulation, FSDP and DeepSpeed boilerplate into one API: device placement, distributed launch and AMP without hand-written scaffolding.

9.9k stars 1611 forks Python 语言Language Apache-2.0 许可License 最近推送Last push 2026-11-18

为什么选Why choose it

  • 单卡训练脚本加一行 launch 就能跑多卡。A single-GPU script can launch multi-GPU with one command.
  • 和 Transformers Trainer 解耦,自定义训练循环也能用。Works with custom training loops, not only the Transformers Trainer.
  • FSDP / DeepSpeed 配置集中,少写分布式样板。Centralizes FSDP / DeepSpeed configuration and removes distributed boilerplate.

不适合Not for

不是完整训练框架;数据加载、实验管理和评测仍要自己搭。Not a complete training framework; data loading, experiment tracking and evaluation are still yours.
多机通信依赖 NCCL 与网络,配置错误排查成本高。Multi-node communication depends on NCCL and networking; misconfiguration is expensive to debug.
极端大规模仍要专门的分片与容错方案。Extreme scale still needs dedicated sharding and fault tolerance.

最小上手Minimum setup

  1. pip install accelerate,运行 accelerate config 生成默认配置。pip install accelerate, then run accelerate config to generate a default setup.
  2. 用 accelerate launch 跑一个单卡脚本,确认设备与混合精度。Launch a single-GPU script with accelerate launch to verify device and AMP.
  3. 再开多卡/FSDP,记录吞吐与显存,对比单卡基线。Then enable multi-GPU/FSDP and record throughput and VRAM against the single-GPU baseline.

依赖与成本Dependencies and cost

Python + PyTorch;多卡需要 NCCL 与同机/多机网络;DeepSpeed/FSDP 需要额外依赖与显存预算。Python + PyTorch; multi-GPU needs NCCL and intra-/inter-node networking; DeepSpeed/FSDP add dependencies and VRAM budget.

许可与使用边界License and usage boundaries

Apache-2.0;随附的 DeepSpeed、Transformer Engine 等组件各自许可,商用前核对。Apache-2.0; bundled or optional DeepSpeed, Transformer Engine and other components carry their own licences.

开源不等于可商用:GPL / AGPL 有传染性;代码许可、模型许可、生成内容许可要分开看。上线前读仓库 LICENSE 与模型卡,必要时让法务确认。Open source is not automatically commercial-use friendly: GPL / AGPL are copyleft; code, model and output licenses are separate. Read the LICENSE and model card before launch, and involve legal when needed.

替代与相邻Alternatives and neighbors

  • DeepSpeed — 规模 / 性能Scale / performance,微软的大模型训练优化库:ZeRO、Offload、混合精度与 MoE 训练,把显存与吞吐压到可用。Microsoft's large-model training library: ZeRO, offload, mixed precision and MoE training to make VRAM and throughput usable.
  • LitGPT — 生产可用Production,Lightning AI 的轻量 LLM 训练、微调与部署配方:20+ 模型,支持 pretrain、SFT、LoRA、量化与推理,强调单卡可跑与可读代码。Lightning AI’s lightweight recipes for LLM training, fine-tuning and deployment: 20+ models, pretraining, SFT, LoRA, quantisation and inference, with an emphasis on single-GPU runs and readable code.
  • Axolotl — 生产可用Production,一份 YAML 配置跑通微调:支持 LoRA、QLoRA、全参、DPO、GRPO 与多机训练。One YAML config for fine-tuning: LoRA, QLoRA, full-parameter, DPO, GRPO and multi-node training.

下一步Next steps

  • 打开 GitHub,先读 README、LICENSE、最近 release 与 issue。Open GitHub and read the README, LICENSE, latest release and issues first.
  • 按“部署依赖 / 显存 / 数据 / 网络 / 权限”列一张上手清单。Make an onboarding checklist for deployment dependencies, VRAM, data, network and permissions.
  • 用一个小样本跑通,再决定是否进生产;不要直接上生产数据。Run a small sample first, then decide on production; never start with production data.

GitHub 仓库 ↗GitHub repository ↗ 文档 ↗Docs ↗ 加入对比Add to compare

快照口径:stars / forks / language / license / pushed_at 来自 GitHub API 2026-11-20 快照;之后的变化没有回写。标签与“适合 / 不适合”是编辑判断,不是 GitHub 元数据。Snapshot: stars / forks / language / license / pushed_at come from the GitHub API snapshot on 2026-11-20; later changes are not written back. Tags and “fit / not fit” are editorial judgments, not GitHub metadata.
不背书:本站只做索引与风险提示,不审计代码、不保证安全、不替你做许可判断。仓库脚本与模型权重请自行审查。No endorsement: this site only indexes and flags risks; it does not audit code, guarantee security or make license decisions for you. Review repository scripts and model weights yourself.