Overview
torchtune is a PyTorch library for authoring, post-training, and experimenting with large language models. It ships hackable training recipes and plain PyTorch implementations of common model families like Llama, Gemma, Mistral, Phi, and Qwen, so you can read and edit the training loop instead of working around heavy abstractions.
It is aimed at ML engineers and researchers who want to fine-tune open models on their own data and hardware. Recipes cover the full post-training lifecycle: supervised fine-tuning (SFT), LoRA and QLoRA, knowledge distillation, preference optimization (DPO), and reinforcement learning methods (PPO, GRPO), plus quantization-aware training. Each recipe is configured with a YAML file and launched from the `tune` command line tool.
As a fine-tuning framework, torchtune leans on current PyTorch APIs for memory efficiency and scaling from a single GPU up to multi-node runs. Note that the project is no longer actively maintained — development wound down in 2025 — so treat it as a reference and a stable base rather than an evolving tool.
What it does
- PyTorch-native model implementations for Llama, Gemma, Mistral, Phi, Qwen, and other popular LLM families
- Hackable recipes for SFT, LoRA/QLoRA, knowledge distillation, DPO, PPO, GRPO, and quantization-aware training
- YAML configs to set up training, evaluation, quantization, or inference without rewriting code
- Scales from a single device to multiple devices and multiple nodes
- Loads supported models from the Hugging Face Hub or Kaggle Hub
- `tune` CLI to list and run recipes (`tune ls`, `tune run`)
Getting started
Install torchtune with pip, then list the available recipes and launch one with a matching config using the `tune` CLI.
Install torchtune
Install the package from PyPI. torchtune builds on PyTorch, so a working PyTorch install with the right CUDA version should be in place first.
pip install torchtuneBrowse available recipes
Use `tune ls` to see the recipes and the configs bundled with each one.
tune ls lora_finetune_single_deviceRun a LoRA fine-tune on a single device
Launch a recipe with one of its configs. This example runs single-device LoRA fine-tuning on Llama 3.2 3B.
tune run lora_finetune_single_device --config llama3_2/3B_lora_single_deviceCommands and code are distilled from the project's own documentation — always check the official repo for the latest.
When to use it
- Fine-tune an open model like Llama or Qwen on your own dataset with LoRA or QLoRA on a single GPU
- Align a model to preferences using DPO, PPO, or GRPO post-training recipes
- Compress a larger model into a smaller one with knowledge distillation
- Apply quantization-aware training to prepare a model for low-precision deployment
How torchtune compares
torchtune alongside other open-source fine-tuning frameworks tools AI/TLDR tracks, ranked by GitHub stars.
| Tool | Stars | What it does |
|---|---|---|
| LLaMA-Factory | ★ 72.3k | An end-to-end training suite with a web UI that covers pre-training, supervised fine-tuning, and RLHF for hundreds of LLMs and multimodal models. |
| Unsloth | ★ 66.9k | A library that speeds up LoRA and QLoRA fine-tuning while cutting memory use, aimed at training models on a single GPU. |
| PEFT | ★ 21.3k | Hugging Face's library of parameter-efficient fine-tuning methods such as LoRA, DoRA, and prompt tuning that train small adapters instead of full models. |
| FinGPT | ★ 20.5k | FinGPT is an open-source project of financial LLMs, fine-tuned with LoRA on news and tweet data for tasks like sentiment analysis, relation extraction, and stock-move forecasting. |
| ms-swift | ★ 14.6k | ModelScope's framework for fine-tuning and deploying 600+ LLMs and 300+ multimodal models, supporting PEFT and full-parameter SFT, DPO, and GRPO. |
| LitGPT | ★ 13.4k | An open-source toolkit from Lightning AI to pretrain, finetune, and serve 20+ large language models, each written from scratch for speed and full control. |
| Axolotl | ★ 12.1k | A config-driven tool for fine-tuning and post-training open LLMs that supports SFT, LoRA/QLoRA, DPO, GRPO, and multi-GPU training across many model families. |
| torchtune | ★ 5.8k | A PyTorch-native library for fine-tuning and post-training LLMs with readable recipes |