torchtune: PyTorch Native Library for LLM Post-Training and Experimentation

This repository profile is provided by osrepos.com, an open source repository discovery platform.

torchtune: PyTorch Native Library for LLM Post-Training and Experimentation

Summary

torchtune is a PyTorch native library designed for authoring, post-training, and experimenting with Large Language Models (LLMs). It offers hackable training recipes, simple PyTorch implementations of popular LLMs, and best-in-class memory efficiency. Please note: torchtune is no longer actively maintained as of 2025.

Repository Information

Analyzed by OSRepos on July 5, 2026

Topics

Click on any tag to explore related repositories

Use at your own risk

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.

Introduction

torchtune is a PyTorch native library designed for easily authoring, post-training, and experimenting with Large Language Models (LLMs). It provides hackable training recipes for methods like Supervised Finetuning (SFT), Knowledge Distillation (KD), Direct Preference Optimization (DPO), Proximal Policy Optimization (PPO), and Quantization-Aware Training (QAT). The library also includes simple PyTorch implementations of popular LLMs such as Llama, Gemma, Mistral, Phi, and Qwen, alongside best-in-class memory efficiency and performance improvements leveraging the latest PyTorch APIs. YAML configurations simplify the setup for training, evaluation, quantization, or inference recipes.

Important Note: As of 2025, torchtune is no longer actively maintained. For more details, please refer to The future of torchtune on GitHub.

Installation

torchtune is tested with the latest stable PyTorch release (currently 2.6.0) as well as the preview nightly version. It leverages torchvision for finetuning multimodal LLMs and torchao for the latest in quantization techniques. You should install these dependencies as well.

Install stable release

# Install stable PyTorch, torchvision, torchao stable releases
pip install torch torchvision torchao
pip install torchtune

Install nightly release

# Install PyTorch, torchvision, torchao nightlies.
pip install --pre --upgrade torch torchvision torchao --index-url https://download.pytorch.org/whl/nightly/cu126 # full options are cpu/cu118/cu124/cu126/xpu/rocm6.2/rocm6.3/rocm6.4
pip install --pre --upgrade torchtune --extra-index-url https://download.pytorch.org/whl/nightly/cpu

To confirm that the package is installed correctly, you can run the following command:

tune --help

And should see output similar to:

usage: tune [-h] {ls,cp,download,run,validate} ...

Welcome to the torchtune CLI!

options:
  -h, --help            show this help message and exit

...

Examples

To get started with torchtune, you can follow these common steps:

Downloading a model

Follow the instructions on the official meta-llama repository to ensure you have access to the official Llama model weights. Once access is confirmed, you can download the weights to your local machine, along with the tokenizer model and a responsible use guide. For Llama3.1, you can run:

tune download meta-llama/Meta-Llama-3.1-8B-Instruct \
--output-dir /tmp/Meta-Llama-3.1-8B-Instruct \
--ignore-patterns "original/consolidated.00.pth" \
--hf-token <HF_TOKEN>

Running finetuning recipes

You can finetune Llama3.1 8B with LoRA on a single GPU using the following command:

tune run lora_finetune_single_device --config llama3_1/8B_lora_single_device

For distributed training, the tune CLI integrates with torchrun. To run a full finetune of Llama3.1 8B on two GPUs:

tune run --nproc_per_node 2 full_finetune_distributed --config llama3_1/8B_full

Modify Configs

There are two ways to modify configurations:

Config Overrides

You can directly overwrite config fields from the command line:

tune run lora_finetune_single_device \
--config llama2/7B_lora_single_device \
batch_size=8 \
enable_activation_checkpointing=True \
max_steps_per_epoch=128

Update a Local Copy

You can also copy the config to your local directory and modify the contents directly:

tune cp llama3_1/8B_full ./my_custom_config.yaml
Copied to ./my_custom_config.yaml

Then, run your custom recipe by directing the tune run command to your local files:

tune run full_finetune_distributed --config ./my_custom_config.yaml

torchtune also supports finetuning on a variety of custom datasets, including instruct-style, chat-style, and preference datasets. It also supports various devices, including NVIDIA GPU, Intel XPU, AMD ROCm, Apple MPS, and Ascend NPU.

Why Use torchtune

torchtune offers several compelling features for LLM development:

  • Comprehensive Post-Training Capabilities: Supports the entire post-training lifecycle with hackable recipes for Supervised Finetuning (SFT), Knowledge Distillation (KD), Reinforcement Learning from Human Feedback (RLHF) methods like DPO, PPO, GRPO, and Quantization-Aware Training (QAT).
  • Extensive Model Support: Includes simple PyTorch implementations of many state-of-the-art models available on Hugging Face Hub or Kaggle Hub, such as Llama (Llama4, Llama3.3, Llama3.2-Vision, Llama3.2, Llama3.1), Mistral, Gemma2, Microsoft Phi (Phi4, Phi3), and Qwen (Qwen3, Qwen2.5, Qwen2).
  • Optimized Performance and Memory Efficiency: Leverages the latest PyTorch APIs to provide best-in-class memory efficiency and performance improvements. It offers various optimization flags and techniques, such as packed datasets, torch.compile, chunked cross entropy, activation checkpointing, fused optimizer step into backward, activation offloading, and 8-bit AdamW, significantly reducing memory footprint and increasing tokens per second.
  • Robust Ecosystem Integration: Focuses on integrating with popular tools and libraries, including Hugging Face Hub for model weights, EleutherAI's LM Eval Harness for evaluation, Hugging Face Datasets, PyTorch FSDP2 for distributed training, torchao for quantization, Weights & Biases and Comet for logging, ExecuTorch for on-device inference, bitsandbytes for low memory optimizers, and PEFT for continued finetuning.
  • Active Community Contributions: Values and highlights contributions from its user community, fostering a collaborative development environment.

Links

Related repositories

Similar repositories that may be relevant next.

awesome-cli-coding-agents: A Curated Directory of Terminal-Native AI Tools

awesome-cli-coding-agents: A Curated Directory of Terminal-Native AI Tools

August 9, 2026

The `awesome-cli-coding-agents` repository offers a comprehensive, curated directory of over 100 terminal-native AI coding agents. These powerful tools operate directly within your command line, enabling autonomous code reading, editing, and execution. The list also covers various harnesses and orchestration solutions for managing these agents.

AICLICoding Agents
QwenPaw: Your Personal AI Assistant for Local and Cloud Deployment

QwenPaw: Your Personal AI Assistant for Local and Cloud Deployment

August 7, 2026

QwenPaw is a powerful personal AI assistant designed for easy installation and deployment, either on your local machine or in the cloud. It supports multiple chat applications and offers highly extensible capabilities, making it a versatile tool for various AI-driven tasks. With its robust memory system and security features, QwenPaw aims to be an intuitive and private partner in your digital life.

agentai-agentchatbot
DeepTutor: Lifelong Personalized Tutoring with AI Agents

DeepTutor: Lifelong Personalized Tutoring with AI Agents

August 7, 2026

DeepTutor is an advanced AI-powered platform designed for lifelong personalized tutoring, integrating various learning modes into a single, extensible system. It leverages large language models and multi-agent systems to offer features like interactive chat, quiz generation, and skill development. This project provides a comprehensive environment for learners and educators seeking intelligent, adaptive educational tools.

AITutoringLLM
Memori: Agent-Native Memory Infrastructure for LLM Production Systems

Memori: Agent-Native Memory Infrastructure for LLM Production Systems

August 6, 2026

Memori provides agent-native memory infrastructure, offering an LLM-agnostic layer that transforms agent execution and conversations into structured, persistent state. Designed for enterprise use, it seamlessly integrates with existing data infrastructure and supports various deployment environments, ensuring robust memory management for AI agents.

agent-memoryLLMAI

Source repository

Open the original repository on GitHub.

12 counted GitHub visits

View on GitHub
OS
OSRepos

Analysis and discovery of open source repositories. Find interesting projects and follow their updates.

Monitor your website with YourWebsiteScore

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of third-party repository code is at your own risk. Always review source code, dependencies, licenses, and security implications before running anything.

© 2025 OSRepos. Built with Nuxt 3 and lots of ❤️