---
title: "Make LLM Fine-tuning 2x faster with Unsloth and 🤗 TRL"
description: "Unsloth speeds up QLoRA fine-tuning of Llama and Mistral-family models by rewriting PyTorch modules as Triton kernels with manually derived backpropagation."
url: "https://swe.quest/articles/make-llm-fine-tuning-2x-faster-with-unsloth-and-trl-5db8c0b6a40cf74e"
canonical: "https://huggingface.co/blog/unsloth-trl"
source: "Hugging Face"
published: "2024-01-10"
difficulty: "medium"
kind: "How-to"
reading_minutes: 5
tags: ["model-training","llms","performance","python"]
---

# Make LLM Fine-tuning 2x faster with Unsloth and 🤗 TRL

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2024-01-10, 5 min read, How-to. Original: [https://huggingface.co/blog/unsloth-trl](https://huggingface.co/blog/unsloth-trl)

## Summary

Unsloth speeds up QLoRA fine-tuning of Llama and Mistral-family models by rewriting PyTorch modules as Triton kernels with manually derived backpropagation. Because no approximations are made, it claims 0% accuracy loss relative to standard QLoRA. Across 59 benchmark runs on A100 and T4 GPUs, it ran 1.5–3.9x faster than Hugging Face transformers and used up to 74% less VRAM. Code examples show loading pre-quantized 4-bit models with FastLanguageModel, attaching LoRA adapters, and training with TRL's SFTTrainer or DPOTrainer.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Model training](https://swe.quest/tags/model-training.md) (AI & ML)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- LoRA/QLoRA fine-tuning ([easy posts on Model training](https://swe.quest/tags/model-training.md?difficulty=easy))
- Hugging Face transformers
- PyTorch basics

## Keywords

Unsloth, TRL, QLoRA, Triton, PEFT, SFTTrainer, Mistral, Llama

## Related posts

- [Making LLMs even more accessible with bitsandbytes, 4-bit quantization and QLoRA](https://swe.quest/articles/making-llms-even-more-accessible-with-bitsandbytes-4-bit-quantization-and-qlora-7bc797d3e83b0ec6.md): Hugging Face · 2023-05-24 · Medium · 14 min read · Inference & serving, Model training, LLMs, Python
  bitsandbytes now integrates 4-bit quantization into Hugging Face transformers, letting most accelerate-loadable models (text, vision, multimodal) run in 4-bit and be fine-tuned via QLoRA, which backpropagates through a frozen 4-bit base model into LoRA adapters.
- [Fine-tuning 20B LLMs with RLHF on a 24GB consumer GPU](https://swe.quest/articles/fine-tuning-20b-llms-with-rlhf-on-a-24gb-consumer-gpu-7ad6c7bb6c14c3cf.md): Hugging Face · 2023-03-09 · Hard · 11 min read · Model training, LLMs, Machine learning, Python
  Combining trl with peft and bitsandbytes makes RLHF fine-tuning of a 20B-parameter LLM feasible on a single 24GB consumer GPU.
- [Parameter-Efficient Fine-Tuning using 🤗 PEFT](https://swe.quest/articles/parameter-efficient-fine-tuning-using-peft-5c28b9ec4e65b0a1.md): Hugging Face · 2023-02-10 · Medium · 5 min read · Model training, LLMs, Python
  Hugging Face's PEFT library brings parameter-efficient fine-tuning methods (LoRA, Prefix Tuning, Prompt Tuning, P-Tuning) to Transformers and Accelerate.
- [🐯 Liger GRPO meets TRL](https://swe.quest/articles/liger-grpo-meets-trl-4a551ec5e4d7e307.md): Hugging Face · 2025-05-25 · Hard · 13 min read · Model training, LLMs, Performance engineering
  Liger's chunked loss, extended to GRPO and integrated into TRL's GRPOTrainer, cuts peak training memory by up to 40% with no change in reward curves.
- [What is LLM fine-tuning?](https://swe.quest/articles/what-is-llm-fine-tuning-818b56b81ea17fe8.md): Modal · 2024-12-10 · Medium · 13 min read · Model training, LLMs
  Fine-tuning adjusts a pretrained LLM's weights for a specific task or domain, often matching larger models' quality at lower cost and latency.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
