Unsloth is an open-source Python library that dramatically accelerates LLM fine-tuning — delivering 2x faster training speed and 60% less memory usage compared to standard Hugging Face + PEFT approaches. It's become the default fine-tuning tool for developers who want to run LoRA or QLoRA training on consumer hardware without hitting VRAM limits.
Unsloth optimizes the core computational bottlenecks in transformer fine-tuning through three main techniques:
| Unsloth | Standard PEFT/LoRA | |
|---|---|---|
| Training speed | 2x faster | Baseline |
| VRAM usage | ~40% of baseline | Baseline |
| Model quality | Identical (no approximations) | Identical |
| Supported models | Llama, Qwen, Mistral, Gemma, Phi, DeepSeek, +more | All models |
| Hardware required | NVIDIA GPU (CUDA) | NVIDIA GPU (CUDA) |
| License | Apache 2.0 (core), AGPL (some extensions) | Apache 2.0 |
pip install unsloth
from unsloth import FastLanguageModel
import torch
model, tokenizer = FastLanguageModel.from_pretrained(
model_name="unsloth/llama-3.2-8b-bnb-4bit",
max_seq_length=2048,
dtype=None,
load_in_4bit=True,
)
# Add LoRA adapters
model = FastLanguageModel.get_peft_model(
model,
r=16,
target_modules=["q_proj", "v_proj", "k_proj", "o_proj"],
lora_alpha=16,
lora_dropout=0,
bias="none",
use_gradient_checkpointing="unsloth",
)
# Then train normally with SFTTrainer or your own loop
| Model | GPU needed (standard) | GPU needed (Unsloth) |
|---|---|---|
| Llama 3.2-8B | RTX 3090 (24GB) | RTX 3060 (12GB) |
| Llama 3.3-70B | 2x A100 80GB | 1x A100 80GB |
| Qwen2.5-32B | 2x RTX 4090 | 1x RTX 4090 |
| Mistral-7B | RTX 3080 (10GB) | RTX 3060 Ti (8GB) |
Unsloth also accelerates inference via its GGUF export pipeline. After fine-tuning, you can export directly to quantized GGUF for use with llama.cpp or Ollama:
model.save_pretrained_gguf("my-model", tokenizer, quantization_method="q4_k_m")
# Outputs my-model-unsloth.Q4_K_M.gguf — ready for Ollama or llama.cpp
Faster fine-tuning means lower cloud GPU costs. A fine-tuning run that takes 4 hours on standard LoRA takes ~2 hours with Unsloth — halving your GPU rental bill. For iterative fine-tuning workflows where you run many experiments, this compounds significantly.
And a well fine-tuned model can replace verbose system prompts — baking behavior into weights rather than injecting it as context tokens on every call. See our guide on LLM token waste for how this reduces per-call costs.
Tokoscope measures token costs before and after fine-tuning so you can quantify the actual savings. Free to start.
Get started free →