accelerate
Use Hugging Face Accelerate for PyTorch training-loop migration, distributed launch/configuration, DeepSpeed/FSDP/TPU backend setup, big-model inference/offload, checkpointing, tracking, and troubleshooting.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- accelerate
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Use Hugging Face Accelerate for PyTorch training-loop migration, distributed launch/configuration, DeepSpeed/FSDP/TPU backend setup, big-model inference/offload, checkpointing, tracking, and troubleshooting.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/repo-provenance.md2.7 KB
- 参考文档references/repo-routing-metadata.json439 B
- 参考文档references/troubleshooting.md3.4 KB
- 脚本scripts/check_accelerate_environment.py4.1 KB
03 SKILL.md 正文
Accelerate
Use this repo skill when a task involves Hugging Face Accelerate: adapting PyTorch code with Accelerator, building accelerate launch commands, validating config files, choosing distributed backends, loading large models with device maps/offload, or saving/logging training state.
Install And Import Check
For normal package use:
pip install accelerate
python - <<'PY'
import accelerate
from accelerate import Accelerator
print(accelerate.__version__)
print(Accelerator)
PY
Install optional backends only for workflows that need them, such as DeepSpeed, torch-xla, transformer-engine, torchao, bitsandbytes, experiment trackers, or model libraries. Do not install broad development or testing extras unless the user explicitly asks for repository development coverage.
Route By Task
- Use
sub-skills/training-loop-integration/to migrate raw PyTorch training/evaluation loops toAccelerator,prepare(),backward(), mixed precision, dataloader handling, gradient accumulation, DDP kwargs, and distributed-loop debugging. - Use
sub-skills/configuration-and-cli/to create or validate Accelerate config YAML, constructaccelerate launchcommands, inspectaccelerate env, estimate memory, merge weights, and plan multi-node or SLURM launches without executing them. - Use
sub-skills/distributed-training-backends/to choose and configure DeepSpeed, FSDP/FSDP2, Megatron-LM, TPU/XLA, FP8, quantization, compilation, tensor/context parallelism, Local SGD, or DDP communication hooks. - Use
sub-skills/big-model-inference/forinit_empty_weights,infer_auto_device_map,load_checkpoint_and_dispatch, CPU/disk offload, model hooks, PiPPy/distributed inference, and memory-sizing workflows. - Use
sub-skills/checkpointing-and-tracking/forsave_state,load_state, checkpoint hooks,ProjectConfiguration, model export, experiment trackers, distributed-safe logging, profiling, and memory cleanup.
Shared References And Scripts
- Read
references/troubleshooting.mdfirst for cross-cutting install/import, CLI, optional dependency, hardware, and distributed hang triage. - Read
references/repo-provenance.mdbefore deciding whether this skill matches a current Accelerate checkout or should be refreshed. - Run
scripts/check_accelerate_environment.py --helpor the script itself for a safe import/CLI/backend availability diagnostic.
Common Decision Points
- Prefer
Acceleratorandaccelerator.prepare(...)for ordinary training loops; do not start with backend-specific plugins until the baseline loop is clear. - Prefer
accelerate configor a reviewed config YAML when launch commands become long, multi-node, or backend-specific. - Treat DeepSpeed, FSDP, TPU/XLA, FP8, and quantization as optional backend surfaces with package, hardware, and version constraints.
- Use big-model dispatch/offload APIs for model loading and inference memory pressure; do not use them as a replacement for normal training-loop preparation.
- Use checkpointing/tracking helpers from the nearest sub-skill before adding custom save/load or logging code in distributed jobs.
Safety Defaults
- Run helper scripts with
--helpfirst when adapting them. - Avoid commands that download models/datasets, launch multi-process distributed jobs, require GPUs/TPUs/SLURM, or contact external tracker services unless the user explicitly asks and the environment is ready.
- For verification in limited environments, prefer parser checks, config validation, tiny CPU smoke tests, and static backend diagnostics over full distributed execution.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).