One Open Source Project a Day (Part 57): Unsloth - 2x Faster, 70% Less VRAM for LLM Fine-Tuning

Deep dive into Unsloth, the open-source LLM fine-tuning and reinforcement learning library supporting gpt-oss, DeepSeek, Qwen, Llama, Gemma, and more — 2x training speed, 70% VRAM savings, 0% accuracy loss, with free Colab notebooks

·4 min read·AI & Machine Learning

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


Core Features

Main Capabilities

CapabilityDescription
Efficient fine-tuning~2x speed, ~70% VRAM savings, 0% accuracy loss
Full paradigm supportFull fine-tuning, pretraining, 4-bit, 16-bit, FP8
Model coverageLLM, TTS, multimodal, embedding, transformers-compatible
Reinforcement learningGRPO, GSPO, DrGRPO, DAPO, PPO, etc., ~80% VRAM savings
Export & deployGGUF, vLLM, SGLang, Hugging Face
Hardware supportNVIDIA, AMD, Intel GPUs, Linux/WSL/Windows

Use Cases

  1. Personal/small-team fine-tuning: Fine-tune 7B, 8B models on consumer GPUs
  2. Reinforcement learning: GRPO, GSPO for chain-of-thought and alignment
  3. Long context: Longer context fine-tuning (e.g., Llama 3.1 8B up to 342K on 80GB)
  4. Free Colab: Users without GPUs can use Colab notebooks for free training

Quick Start

Linux / WSL:

pip install unsloth

Windows: 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/unsloth

Access 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

ComparisonUnslothHugging Face + FA2
Training speed~2x1x
VRAM usage~70% lessBaseline
Long contexte.g., Llama 3.1 8B 342K (80GB)28K
Accuracy0% loss0% loss
RL VRAM~80% lessBaseline

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)

ModelGPUUnsloth speedUnsloth VRAMUnsloth contextHF+FA2 context
Llama 3.3 (70B)80GB2x>75% less13x longer1x
Llama 3.1 (8B)80GB2x>70% less12x longer1x

Directory Structure

unsloth/
├── unsloth/          # Core library
├── cli/              # CLI tools
├── studio/           # Studio
├── scripts/          # Scripts
├── tests/            # Tests
└── cli.py            # Entry point

Official Resources

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