Introduction
"Train gpt-oss, DeepSeek, Gemma, Qwen & Llama 2x faster with 70% less VRAM!"
This is Part 57 of the "One Open Source Project a Day" series. Today's project is Unsloth (GitHub).
Want to fine-tune large models on your own GPU but struggling with VRAM limits and slow training? Unsloth is an open-source LLM fine-tuning and reinforcement learning library: ~2x training speed, ~70% VRAM savings, 0% accuracy loss. Supports gpt-oss, DeepSeek, Qwen, Llama, Gemma, TTS, and more, with free Colab notebooks, Docker images, and compatibility with Hugging Face transformers and TRL.
What You'll Learn
- Unsloth's core capabilities and positioning
- Fine-tuning and RL support (GRPO, GSPO, etc.)
- Supported models and training paradigms
- Quick start: pip, Docker, Colab
- Comparison with Hugging Face + FA2
Prerequisites
- Basic understanding of LLM fine-tuning
- Familiarity with LoRA, QLoRA (optional)
Project Background
Project Overview
Unsloth is an open-source LLM fine-tuning and reinforcement learning library built on PyTorch and Triton kernels. Through memory optimization and efficient operators, it achieves ~2x training speed and ~70% VRAM savings. Supports full fine-tuning, pretraining, 4-bit, 16-bit, FP8, and models including TTS, multimodal, and embedding. Reinforcement learning (GRPO, GSPO, DAPO, etc.) uses ~80% less VRAM.
Team
- Team: Unsloth AI (unsloth.ai)
- Philosophy: Efficient, easy to use, 0% accuracy loss, support for all major models
Project Data
- ⭐ GitHub Stars: 54.1k+
- 🍴 Forks: 4.5k+
- 📄 License: Apache-2.0 / AGPL-3.0
- 🌐 Website: unsloth.ai
- 📚 Docs: unsloth.ai/docs
- 💬 Community: r/unsloth, Twitter
Core Features
Main Capabilities
| Capability | Description |
|---|---|
| Efficient fine-tuning | ~2x speed, ~70% VRAM savings, 0% accuracy loss |
| Full paradigm support | Full fine-tuning, pretraining, 4-bit, 16-bit, FP8 |
| Model coverage | LLM, TTS, multimodal, embedding, transformers-compatible |
| Reinforcement learning | GRPO, GSPO, DrGRPO, DAPO, PPO, etc., ~80% VRAM savings |
| Export & deploy | GGUF, vLLM, SGLang, Hugging Face |
| Hardware support | NVIDIA, AMD, Intel GPUs, Linux/WSL/Windows |
Use Cases
- Personal/small-team fine-tuning: Fine-tune 7B, 8B models on consumer GPUs
- Reinforcement learning: GRPO, GSPO for chain-of-thought and alignment
- Long context: Longer context fine-tuning (e.g., Llama 3.1 8B up to 342K on 80GB)
- Free Colab: Users without GPUs can use Colab notebooks for free training
Quick Start
Linux / WSL:
pip install unslothWindows: Install PyTorch first; see Windows Guide.
Docker:
docker run -d -e JUPYTER_PASSWORD="mypassword" \
-p 8888:8888 -p 2222:22 \
-v $(pwd)/work:/workspace/work \
--gpus all \
unsloth/unslothAccess Jupyter Lab at http://localhost:8888.
Free Colab training: In Unsloth Notebooks, pick a notebook for your model (Qwen3.5, gpt-oss, Llama 3.1, etc.) and run.
Minimal example:
from unsloth import FastLanguageModel
import torch
model, tokenizer = FastLanguageModel.from_pretrained(
model_name="unsloth/llama-3.1-8b-instruct",
max_seq_length=2048,
load_in_4bit=True,
)
model = FastLanguageModel.get_peft_model(
model,
r=16,
target_modules=["q_proj", "k_proj", "v_proj", "o_proj",
"gate_proj", "up_proj", "down_proj"],
lora_alpha=16,
lora_dropout=0,
bias="none",
use_gradient_checkpointing="unsloth",
)
# Train with SFTTrainer...Supported Models
LLM: Llama 3.1/3.2/3.3/4, Qwen2.5/Qwen3/Qwen3.5, DeepSeek, Gemma 2/3, gpt-oss, Mistral, Phi, etc.
Multimodal: Llama 3.2 Vision, Qwen2.5-VL, Pixtral, Gemma 3 Vision, etc.
TTS: Orpheus, sesame/csm-1b, etc.
Embedding: EmbeddingGemma, etc.
Project Advantages
| Comparison | Unsloth | Hugging Face + FA2 |
|---|---|---|
| Training speed | ~2x | 1x |
| VRAM usage | ~70% less | Baseline |
| Long context | e.g., Llama 3.1 8B 342K (80GB) | 28K |
| Accuracy | 0% loss | 0% loss |
| RL VRAM | ~80% less | Baseline |
Deep Dive
Technical Highlights
- Triton kernels: Core operators written in OpenAI Triton, manual backprop engine
- No approximation: No approximation methods, all exact computation
- RoPE & MLP: Triton kernels + Padding Free + Packing, ~3x training speedup, 30% VRAM savings
- MoE support: MoE model training ~12x faster, 35% VRAM savings
Performance Benchmarks (examples)
| Model | GPU | Unsloth speed | Unsloth VRAM | Unsloth context | HF+FA2 context |
|---|---|---|---|---|---|
| Llama 3.3 (70B) | 80GB | 2x | >75% less | 13x longer | 1x |
| Llama 3.1 (8B) | 80GB | 2x | >70% less | 12x longer | 1x |
Directory Structure
unsloth/
├── unsloth/ # Core library
├── cli/ # CLI tools
├── studio/ # Studio
├── scripts/ # Scripts
├── tests/ # Tests
└── cli.py # Entry pointProject Links and Resources
Official Resources
- 🌟 GitHub: https://github.com/unslothai/unsloth
- 🌐 Website: unsloth.ai
- 📚 Docs: unsloth.ai/docs
- 📓 Notebooks: unslothai/notebooks
- 🐳 Docker: unsloth/unsloth
- 💬 Reddit: r/unsloth
- 🐛 Issues: GitHub Issues
Target Audience
- Developers fine-tuning LLMs on limited GPU
- Teams doing reinforcement learning, alignment, chain-of-thought training
- Learners wanting free Colab fine-tuning
- Users of Llama, Qwen, DeepSeek, Gemma, and other open-source models
Visit my homepage for more useful knowledge and interesting products