Fine-Tuning Llama 3.2 on Consumer GPUs With Unsloth

Generative AI
Date:October 31, 2026
Topic:
Fine-Tuning Llama 3.2 on Consumer GPUs With Unsloth
⏱ 2 min read

You don't need a cluster to own your model. In 2026, a single 8GB consumer GPU is enough to fine-tune Llama 3.2 on your data, in your garage, without asking permission from a cloud provider. The bottleneck was never the math—it was the memory overhead. Unsloth removed that bottleneck.

Why Unsloth Changes the Game

Standard Hugging Face Trainer + PEFT loads the base model, optimizer states, gradients, and activations in FP32/BF16. On an 8GB card, a 3B parameter model OOMs before the first step. Unsloth rewrites the Triton kernels for the forward and backward pass, fuses the LoRA adapters into the base weights during training, and keeps optimizer states in 8-bit via bitsandbytes. The result: a 3.2B model trains in ~6.2GB VRAM with 2x throughput versus stock FSDP.

bash
pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git" --quiet

VRAM Budget Cheat Sheet

ModelQuantizationSeq LenBatchEst. VRAM
Llama 3.2 1B4-bit QLoRA204844.1 GB
Llama 3.2 3B4-bit QLoRA204826.2 GB
Llama 3.2 3B4-bit QLoRA409617.8 GB
💡
TipIf you hit OOM, drop sequence length before dropping batch size. Gradient accumulation preserves effective batch size without VRAM penalty.

Data Format That Actually Works

Unsloth expects a conversational dataset mapped to the tokenizer's chat template. Skip the raw text concatenation—it kills instruction following. Use the standardize_sharegpt helper to convert any JSONL into the correct role/turn structure, then apply the chat template with tokenizer.apply_chat_template inside a map function. Keep max_seq_length at 2048 for 8GB cards; 4096 only if you have 12GB+.

python
from unsloth import FastLanguageModel
from datasets import load_dataset

model, tokenizer = FastLanguageModel.from_pretrained(
    model_name="unsloth/Llama-3.2-3B-Instruct-bnb-4bit",
    max_seq_length=2048,
    dtype=None,
    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=32,
    lora_dropout=0,
    bias="none",
    use_gradient_checkpointing="unsloth",
    random_state=3407,
)

Training Loop: 30 Minutes to a Custom Model

Unsloth's SFTTrainer wraps the standard Trainer but injects the fused kernels automatically. Set per_device_train_batch_size=2, gradient_accumulation_steps=4, learning_rate=2e-4, warmup_steps=10, max_steps=60 for a quick sanity run. On an RTX 3060 12GB, 60 steps on 1k samples finishes in ~18 minutes. Loss drops from ~2.1 to ~0.8. That's enough to verify the pipeline before a full epoch run.

python
from trl import SFTTrainer
from transformers import TrainingArguments

trainer = SFTTrainer(
    model=model,
    tokenizer=tokenizer,
    train_dataset=dataset["train"],
    dataset_text_field="text",
    max_seq_length=2048,
    args=TrainingArguments(
        per_device_train_batch_size=2,
        gradient_accumulation_steps=4,
        warmup_steps=10,
        max_steps=60,
        learning_rate=2e-4,
        fp16=not torch.cuda.is_bf16_supported(),
        bf16=torch.cuda.is_bf16_supported(),
        logging_steps=1,
        optim="adamw_8bit",
        weight_decay=0.01,
        lr_scheduler_type="linear",
        seed=3407,
        output_dir="outputs",
    ),
)
trainer.train()

Export & Deploy Locally

Don't push to Hub. Save merged 16-bit weights for llama.cpp or ollama inference on the same machine. model.save_pretrained_merged("llama-3.2-3b-custom", tokenizer, save_method="merged_16bit") produces a standard safetensors folder. Convert to GGUF with llama.cpp/convert_hf_to_gguf.py, quantize to Q4_K_M, and you're running 30 tok/s on CPU or 80+ tok/s on that same GPU via llama-server.

⚠️
WarningMerging LoRA into base weights is one-way. Keep the adapter checkpoint separate if you plan iterative training cycles.

Your Next Weekend Project

Grab a domain-specific dataset—legal clauses, medical notes, your company's Slack export. Run the pipeline above. Measure perplexity on a held-out set. If it beats the base model, you just built a specialist model that lives on your hardware, costs $0/inference, and never logs your prompts. That's the point.


✦
Share𝕏 Twitterin LinkedInin Whatsapp