Unsloth

The single-GPU speed & memory optimizer · Deep-Dive FTDD-03 · Course 3

45 minutes · Hand-written Triton kernels, manual autograd, 4-bit optimizers

The tool that made 7B QLoRA viable on a $1,500 RTX 4090 — and why it's pure systems engineering, not a new algorithm.

Deep-Dives

What Unsloth is — and isn't

~2x
training speed
~60%
less VRAM
0
algorithmic changes
Same fine-tuning, faster and cheaper. Unsloth does not change WHAT fine-tuning does (same LoRA/QLoRA, same result). It changes HOW FAST and HOW CHEAPLY the same fine-tuning runs.

How Unsloth achieves the win

1
Triton kernels

Hand-written GPU kernels replace PyTorch's generic forward/backward. Specialized for the exact ops fine-tuning performs.

2
Manual autograd

Gradients computed by hand for custom kernels. Bypasses PyTorch's graph construction and intermediate-tensor overhead.

3
4-bit optimizers

Optimizer state at 4-bit (not 32-bit). 8x memory reduction with negligible convergence impact.

All three are engineering wins, not algorithmic changes. The math is identical; the implementation is faster.

The consumer-GPU enabler

Before Unsloth

7B QLoRA needed 24GB+ VRAM ($2,000–$5,000 tier), or aggressive compromises (tiny batch, CPU offload, slow).

After Unsloth

$1,500 RTX 4090 (24GB). Reasonable batch + seq length. ~2x speed, ~60% less memory.

The threshold: fine-tuning moves from "labs do it" to "I do it, on my desk, today." For a course built on students RUNNING experiments (FT00), this is what makes the curriculum executable on a budget.

CUDA focus — the Apple Silicon caveat

NVIDIA GPU (CUDA)

Unsloth — the hand-written Triton kernels target NVIDIA. This is the platform Unsloth optimizes.

Apple Silicon (Metal)

MLX — Apple's framework for Metal/unified-memory. The Apple Silicon path for fine-tuning and inference (FT20).

Not a defect — a scope boundary. Unsloth's CUDA kernels don't apply on M-series Macs. Don't install Unsloth on Apple Silicon expecting a speedup. Use MLX instead.

Dynamic 4.0 — intelligent GGUF quants

Unsloth's recent feature extends its value from training (Layers 2–3) into export (Layer 4).

QuantizationHow it worksResult
UniformSame precision (e.g., 4-bit) on every layerOver-quantizes sensitive layers, under-quantizes robust ones
Dynamic 4.0Per-layer analysis; sensitive layers get more bits, robust get fewerSame average size, better quality
Matters for GGUF export to Ollama (FT19/FT20) and constrained edge devices — more quality per byte.

Unsloth vs Axolotl vs TRL

FrameworkBest forMulti-GPU?Control
UnslothSingle-GPU, speed/memory, GGUF exportNo (single-GPU)Optimized, opinionated
AxolotlMulti-GPU, production configsYesConfig-driven, broad
TRLFull control, custom loops, researchYes (Accelerate)Maximum (it IS the library)
Heuristic: one GPU, go fast → Unsloth. Multiple GPUs, configs → Axolotl. Custom loop → TRL. Common pattern: prototype in Unsloth → scale in Axolotl.

Anti-patterns

Expecting Unsloth on Apple Silicon. Unsloth is CUDA-focused. On an M-series Mac, its kernels don't apply. Use MLX (FT20) instead. Scope boundary, not a bug.
Assuming the speedup changes the result. Unsloth is faster, not different. Same LoRA, same adapter. If the result is better, the cause is your data/hyperparameters (the actual steering wheel), not the kernel.
Picking Unsloth for a multi-GPU job. Unsloth is single-GPU. With multiple GPUs you leave compute on the table — Axolotl or TRL (Accelerate) will use them.

What you can now do

  1. Explain how Unsloth achieves ~2x speed / ~60% memory (Triton kernels, manual autograd, 4-bit optimizers) — and why it's engineering, not algorithm.
  2. Defend Unsloth's role as the consumer-GPU enabler (7B QLoRA on a $1,500 RTX 4090).
  3. Identify the CUDA focus and route Apple Silicon users to MLX (FT20).
  4. Describe Dynamic 4.0 GGUF quants and when per-layer intelligence matters.
  5. Choose between Unsloth, Axolotl, and TRL for a given job.
The lab: run the same QLoRA through Unsloth and a TRL baseline, measure the speed and memory difference. The Unsloth win, felt on your own GPU.

Next: FTDD-04 — TRL