Unsloth: Fine-Tune LLMs 2x Faster on a Single GPU
Tech Tips 6 min read intermediate

Unsloth: Fine-Tune LLMs 2x Faster on a Single GPU

Unsloth is an open-source library that fine-tunes open LLMs (Llama, Qwen, Mistral, Gemma, gpt-oss) roughly 2x faster and with up to 70% less VRAM than a stock Hugging Face setup, without sacrificing accuracy. It achieves this with custom OpenAI Triton kernels and a manual backpropagation engine, and fuses LoRA with 4-bit quantization. It runs on any NVIDIA GPU with CUDA Capability 7.0+, including the free Colab T4. Install with 'pip install unsloth' and use FastLanguageModel.from_pretrained plus get_peft_model to attach LoRA adapters before training with trl's SFTTrainer.

Marcus Rivera
Marcus Rivera
Jul 10, 2026

Fine-tuning used to be a rich-lab sport. If you wanted to adapt a 7B or 8B model to your own data, you needed a small pile of A100s, a patient DevOps person, and a weekend to burn. Unsloth quietly killed that assumption. It lets you fine-tune modern open models like Llama, Qwen, Mistral, Gemma, and gpt-oss on a single consumer GPU — often the free T4 you get in a Colab notebook — while running roughly 2x faster and using up to 70% less VRAM than a stock Hugging Face setup.

This isn't a wrapper that calls the same slow code with a nicer API. Unsloth rewrites the parts of the training loop that actually hurt, and it does it without touching your model's accuracy. Here's how it works and how to get a fine-tune running today.

Why Unsloth is fast (the honest version)

Most "faster training" libraries win by lowering precision or approximating gradients. Unsloth doesn't. Its speedups come from three real engineering decisions.

First, the hot paths are rewritten as custom Triton kernels. Triton is OpenAI's language for writing GPU kernels in Python-like syntax, and Unsloth uses it to hand-optimize the operations PyTorch's autograd handles generically — RoPE embeddings, MLP blocks, attention, and cross-entropy. Because these kernels are purpose-built for the fine-tuning case, they move less data and launch fewer operations.

Second, Unsloth ships a manual backpropagation engine. Instead of letting PyTorch's automatic differentiation build a generic backward graph, Unsloth derives the gradients by hand for the supported architectures. That removes redundant intermediate tensors, which is where a lot of your VRAM quietly disappears.

Third, it fuses LoRA and quantization directly into those kernels. You load the base model in 4-bit, attach low-rank adapters, and train only the adapters — but the quantization/dequantization and the LoRA math happen inside the optimized kernel rather than as separate PyTorch calls.

The key claim worth repeating: Unsloth's speedup is exact, not approximate. There's no lossy trick in the training path — the resulting weights match what you'd get from a slower vanilla run.

What you need

Unsloth supports NVIDIA GPUs with CUDA Capability 7.0 or higher. In practice that means anything from a Tesla V100 or T4 up through the RTX 20/30/40 series, A100, and H100. The free T4 in Google Colab clears that bar, which is why so many of Unsloth's official notebooks target it.

The rough memory picture: a 7–8B model that would normally need 30+ GB to fine-tune fits comfortably in the ~16 GB a T4 provides once Unsloth's 4-bit loading and memory savings kick in. Bigger cards (24 GB RTX 4090, 40/80 GB A100/H100) let you push to larger models, longer context, or bigger batches.

Installation

For most modern setups, the stable package installs cleanly from PyPI:

pip install unsloth

If you're on the newest GPUs (RTX 50-series, B200, RTX 6000) and want Unsloth to pull the matching PyTorch backend automatically, use the uv path from the docs:

uv pip install unsloth --torch-backend=auto

That's the whole setup. No custom CUDA compilation, no manual Triton install — the kernels ship with the package.

A minimal fine-tune, end to end

The API is built around two calls: FastLanguageModel.from_pretrained to load a quantized base model, and get_peft_model to attach LoRA adapters. Everything after that is standard Hugging Face trl training.

from unsloth import FastLanguageModel
from datasets import load_dataset
from trl import SFTTrainer
from transformers import TrainingArguments

max_seq_length = 2048

# 1. Load a 4-bit base model
model, tokenizer = FastLanguageModel.from_pretrained(
    model_name    = "unsloth/mistral-7b-bnb-4bit",
    max_seq_length = max_seq_length,
    dtype          = None,          # auto-detect (bf16 on Ampere+)
    load_in_4bit   = True,
)

# 2. Attach LoRA adapters — you train only these
model = FastLanguageModel.get_peft_model(
    model,
    r = 16,                         # LoRA rank
    target_modules = ["q_proj", "k_proj", "v_proj", "o_proj",
                      "gate_proj", "up_proj", "down_proj"],
    lora_alpha = 16,
    lora_dropout = 0,               # 0 is the optimized path
    bias = "none",                  # "none" is the optimized path
    use_gradient_checkpointing = True,
)

# 3. Train with a standard SFTTrainer
dataset = load_dataset("imdb", split="train")

trainer = SFTTrainer(
    model = model,
    tokenizer = tokenizer,
    train_dataset = dataset,
    dataset_text_field = "text",
    max_seq_length = max_seq_length,
    args = TrainingArguments(
        per_device_train_batch_size = 2,
        gradient_accumulation_steps = 4,
        warmup_steps = 10,
        max_steps = 60,
    ),
)

trainer.train()

A few things worth calling out for anyone coming from a vanilla PEFT workflow:

  • The unsloth/mistral-7b-bnb-4bit name points at a pre-quantized checkpoint Unsloth hosts, so you skip the on-the-fly quantization step at load time.
  • target_modules covers both the attention projections and the MLP (gate/up/down). Targeting the MLP as well as attention is what tends to give LoRA its quality on instruction data.
  • lora_dropout = 0 and bias = "none" aren't just defaults — Unsloth has a fused fast path for exactly these settings, so deviating can cost you speed.

Where Unsloth fits (and where it doesn't)

Unsloth is the right tool when you want speed on a single box. For YAML-driven, multi-config pipelines many teams still reach for Axolotl, and for exotic training objectives Hugging Face's TRL gives you more knobs. Unsloth's sweet spot is the common case: take a strong open model, adapt it to your domain data with LoRA or QLoRA, and do it on the hardware you already have.

It's also worth knowing the project has moved beyond a pure library. Unsloth Studio, launched in March 2026, is an open-source no-code web UI for fine-tuning and running open models locally, with support for hundreds of models including recent Gemma and Qwen releases. If you'd rather click than script, that path now exists.

The Bottom Line

Unsloth's pitch is refreshingly concrete: same model quality, roughly half the training time, a fraction of the memory, and no exotic hardware. It gets there through real kernel engineering — hand-written Triton and manual backprop — rather than accuracy-shaving shortcuts. If you've been putting off a fine-tune because you assumed it needed a cluster, spin up a free Colab T4 and the code above. The barrier you were imagining is mostly gone.