torchtune
meta-pytorch / torchtune
PyTorch 原生的微调配方库:可读的训练循环、FSDP、激活检查点与常用后训练配方。A PyTorch-native fine-tuning recipe library: readable training loops, FSDP, activation checkpointing and common post-training recipes.
为什么选Why choose it
- 训练循环写得薄,便于读源码和改数据、损失与采样。Thin training loops make it easy to read the source and change data, loss or sampling.
- 原生支持 FSDP 与激活检查点,能从单卡扩到多卡。Native FSDP and activation checkpointing scale from one GPU to many.
- 配方覆盖 SFT、DPO 与量化感知训练,不依赖第三方训练框架。Recipes cover SFT, DPO and quantisation-aware training without a third-party training framework.
不适合Not for
想要开箱 WebUI 与大量现成模型模板,LLaMA-Factory 更省事。For an out-of-the-box WebUI and many ready model templates, LLaMA-Factory is less work.
非 PyTorch 技术栈或需要 TensorFlow 的团队不适用。Not for non-PyTorch stacks or teams that require TensorFlow.
最小上手Minimum setup
- 按官方 recipe 选一个与显存匹配的模型规模,先跑单卡 SFT。Pick an official recipe whose model size fits your VRAM and run single-GPU SFT first.
- 确认 tokenizer、chat template 与数据格式一致,再开激活检查点。Confirm tokenizer, chat template and data format line up before enabling activation checkpointing.
- 扩到多卡前先测单卡吞吐与显存峰值,避免把通信瓶颈当成模型问题。Measure single-GPU throughput and peak VRAM before scaling out, so communication bottlenecks are not mistaken for model issues.
依赖与成本Dependencies and cost
Python + PyTorch/CUDA;多卡需 FSDP 环境;显存取决于模型、序列长度与检查点策略。Python + PyTorch/CUDA; multi-GPU needs an FSDP environment; VRAM depends on model, sequence length and checkpointing strategy.
许可与使用边界License and usage boundaries
代码 BSD-3-Clause;模型权重与数据集另有许可。Code is BSD-3-Clause; model weights and datasets 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
- TorchTitan — 规模 / 性能Scale / performance,PyTorch 官方的大模型训练配方:张量并行、流水并行、FSDP 与分布式检查点,按 Llama 3 路线给参考实现。PyTorch's official large-model training recipe: tensor parallelism, pipeline parallelism, FSDP and distributed checkpoints, following the Llama 3 path.
- 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.
下一步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