
QLoRA on a Free T4: Fine-Tune Any Open-Weight LLM in an Hour With Unsloth
Chris Harper
2 min read
Jul 7, 2026 · 20:07 UTC
Unsloth QLoRA fine-tunes Llama 3.1 8B on a free Colab T4 in about an hour — 2x faster and 60% less VRAM than standard HuggingFace LoRA.
What you'll be able to do after this:
- Load a quantized 8B model onto a free Colab T4 using Unsloth's
FastLanguageModel - Attach LoRA adapters and train on your own 1–5k examples in 15–60 minutes
- Push the adapter (or a merged model) to HuggingFace Hub ready for inference
The gap between "uses LLMs" and "builds custom LLMs" often comes down to one step: running your first fine-tune. Unsloth closes that gap — what previously required an expensive A100 now runs comfortably on the free T4 in Google Colab.
Open the Llama 3.1 (8B) Alpaca notebook and run these four steps:
# 1. Install
!pip install "unsloth[colab-new]" -q
# 2. Load the 4-bit quantized base model (this is QLoRA)
from unsloth import FastLanguageModel
model, tokenizer = FastLanguageModel.from_pretrained(
model_name="unsloth/Meta-Llama-3.1-8B",
max_seq_length=2048,
load_in_4bit=True, # 4-bit quantization = QLoRA
)
# 3. Attach trainable LoRA adapters
model = FastLanguageModel.get_peft_model(
model,
r=32,
target_modules=["q_proj","k_proj","v_proj","o_proj",
"gate_proj","up_proj","down_proj"],
lora_alpha=32,
lora_dropout=0,
use_gradient_checkpointing="unsloth",
)
# 4. Fine-tune with HuggingFace TRL
from trl import SFTTrainer
from transformers import TrainingArguments
trainer = SFTTrainer(
model=model,
train_dataset=your_dataset, # HF Dataset with a "text" column
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=200, # smoke test; scale up for real runs
learning_rate=2e-4,
fp16=True,
output_dir="outputs",
),
)
trainer.train()
# Save adapter and optionally push to HuggingFace Hub
model.save_pretrained("my-llama-adapter")
# model.push_to_hub("your-username/my-llama-ft")
How QLoRA makes this possible. Standard LoRA loads the base model in FP16 — ~16 GB for Llama 8B, which overflows a T4's 15 GB. QLoRA quantizes the frozen base weights to 4-bit first (~5 GB), then trains only the tiny LoRA adapters in full precision. Unsloth's custom CUDA kernels run those quantized forward passes 2x faster than the standard bitsandbytes path with 60% less peak VRAM.
Realistic training time. Don't try to fine-tune on the full 52k-example Alpaca dataset on a T4 — that would take ~47 hours. The practical approach: use 1k–5k high-quality examples from your own domain. At that scale, expect 15–60 minutes of training on a free T4. The adapter captures the behavior shift; you're not training from scratch, just steering.
Sources: Llama 3.1 (8B) Alpaca Colab notebook — run it now | Unsloth fine-tuning guide | HuggingFace + Unsloth TRL benchmark post | Unsloth blog: Finetune Llama 3.1 | GitHub: unslothai/unsloth (67.9k stars)