meta-pytorch/torchtune

PyTorch native post-training library

torchtune – PyTorch library for training and fine‑tuning large language models

What it is – torchtune is an open‑source Python package built on top of PyTorch. It supplies ready‑made recipes (config‑driven scripts) for the whole post‑training lifecycle of large language models (LLMs): supervised fine‑tuning, LoRA/QLoRA, knowledge distillation, reinforcement‑learning‑from‑human‑feedback (DPO, PPO, GRPO), quantization‑aware training, and inference/quantization. The library also ships lightweight PyTorch implementations of many state‑of‑the‑art LLM architectures (Llama 3.x, Llama 4, Gemma 2, Mistral, Phi, Qwen 2/2.5/3, etc.).

Why it matters – Training or adapting modern LLMs is usually a heavyweight engineering effort: you need to juggle distributed training, memory‑saving tricks (activation checkpointing, offloading, 8‑bit optimizers), and model‑specific tokenizers. torchtune abstracts those concerns behind a simple CLI (tune) and a set of YAML configs, letting researchers and engineers spin up experiments on a single GPU or a multi‑node cluster with a single command.

Key features (as described in the README)

  • Recipe‑driven workflowtune run <recipe> --config <yaml> runs full‑finetune, LoRA/QLoRA, DPO, PPO, GRPO, KD, QAT, etc. Recipes are listed with tune ls.
  • Scalable across hardware – supports 1‑GPU, multi‑GPU, and multi‑node training; works on CUDA, XPU, ROCm, Apple MPS, and Ascend NPU.
  • Memory‑efficiency knobs – packed datasets, torch‑compile, chunked cross‑entropy, activation checkpointing/offloading, fused optimizer‑step, 8‑bit AdamW, LoRA/QLoRA. The README shows a concrete memory‑vs‑throughput table for Llama 3.2 3B.
  • Model catalogue – ready‑made model builders and config folders for dozens of LLM families (Llama 4, Llama 3.3 70B, Llama 3.2‑Vision, Gemma 2, Phi 4, Qwen 3, Qwen 2.5, etc.).
  • Integration with the ecosystem – Hugging Face Hub for weights, Datasets for training data, LM‑Eval Harness for evaluation, torch‑ao for quantization, FSDP2 for distributed training, Weights & Biases/Comet for logging, ExecuTorch for on‑device inference.
  • Installation – pip install torchtune (stable) together with matching PyTorch/torchvision/torchao versions; nightly builds are also available.
  • Documentation & community – full docs at pytorch.org/torchtune, Discord community, and a citation guide.

Typical workflow

  1. Download a model (e.g., tune download meta-llama/Meta-Llama-3.1-8B-Instruct).
  2. Pick a recipe – e.g., lora_finetune_single_device for LoRA on one GPU.
  3. Runtune run lora_finetune_single_device --config llama3_1/8B_lora_single_device.
  4. Scale – prepend torchrun flags or use --nproc_per_node for distributed runs.
  5. Customize – override any config field on the command line or copy the YAML locally with tune cp and edit.

Status – The project is no longer actively maintained (development wound down in 2025), but the codebase remains usable for anyone needing a solid, PyTorch‑native LLM fine‑tuning stack.


All information above is taken directly from the repository’s README; no external assumptions have been added.

Related

  • Project
  • Project
  • Project
  • Project
  • Project