技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
training-loop-integration【数据与研究】Migrate raw PyTorch training and evaluation loops to Hugging Face Accelerate using Accelerator, prepare(), backward(), gradient accumulation, dataloader behavior, gather/reduce, mixed precision, DDP kwargs, local SGD, communication hooks, and basic distributed logging.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this sub-skill when adapting an existing PyTorch model, optimizer, dataloader, scheduler, or evaluation loop to Accelerate while keeping the training code mostly framework-neutral.
accelerate config, accelerate launch, launch flags, config files, or process-count setup, use ../configuration-and-cli/.../distributed-training-backends/.save_state, load_state, model checkpoint saving, trackers, profiler, or experiment dashboards, use ../checkpointing-and-tracking/.references/workflows.md for migration recipes and loop patterns.references/api-reference.md for constructor options, wrappers, dataloader semantics, gather/reduce, kwargs handlers, logging, and scheduler behavior.references/troubleshooting.md when a distributed loop hangs, metrics are wrong, gradients do not sync, or device placement behaves unexpectedly.scripts/accelerator_loop_smoke.py to verify a minimal CPU training loop in the current environment.Accelerator early, before distributed-sensitive objects need its state..cuda() and direct .to("cuda"); prefer automatic device placement through accelerator.prepare().accelerator.prepare(...) and unpack them in the same order.loss.backward() with accelerator.backward(loss).Accelerator(gradient_accumulation_steps=N) or a GradientAccumulationPlugin, then wrap each minibatch body in with accelerator.accumulate(model):.accelerator.gather_for_metrics(...) for evaluation metrics and accelerator.pad_across_processes(...) before gathering variable-size tensors.accelerator.print(...) or accelerate.logging.get_logger(...) instead of unsynchronized process-wide print() spam.python skills/accelerate/sub-skills/training-loop-integration/scripts/accelerator_loop_smoke.py
python skills/accelerate/sub-skills/training-loop-integration/scripts/accelerator_loop_smoke.py --help
The smoke script is intentionally CPU-safe and tiny. It validates importability, Accelerator.prepare, Accelerator.accumulate, Accelerator.backward, scheduler wrapping, and metric gathering without requiring a distributed launcher.