Paged optimizer in QLoRA, what gets paged, and to where?
The paged optimizer keeps Adam's first- and second-moment buffers in CPU RAM and migrates them to GPU only during the optimizer step, using CUDA unified memory to avoid OOM crashes from transient VRAM spikes.
Picture your GPU as a small workshop with limited bench space. Three things compete for that bench: the materials you are working on, the tools you are using, and the spare parts shelf you only need once an hour. The paged optimizer is like keeping the spare parts shelf in the storage room next door (CPU RAM). When you finally need a spare part, you wheel the shelf into the workshop briefly, then push it back out so the bench is free for the actual work. The optimizer state is the spare parts: large, only needed at update time, fine to live elsewhere most of the run. The CUDA driver handles the wheeling in and out automatically. The benefit is that a brief surge in activation memory does not crash the whole job; there is breathing room because the shelf is not blocking the bench.
Detailed answer & concept explanation~11 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
4 min: name Adam's m and v buffers, place the paging between CPU RAM and GPU VRAM via CUDA unified memory, explain why optimizer state is the right tenant to page, and call out OOM safety as the win and PCIe bandwidth as the cost.
Real products, models, and research that use this idea.
- Hugging Face Transformers Trainer exposes paged_adamw_8bit and paged_adamw_32bit via the optim argument, the standard choice for QLoRA recipes on Llama 3.1 and Mistral.
- Unsloth tutorials demonstrate paged_adamw_8bit for fine-tuning Llama 3.1 8B on a single 24GB consumer GPU, leaning on the paging to survive long-sequence batches.
- Axolotl QLoRA configs for DeepSeek V4 and Gemma 4 default to paged_adamw_32bit to combine bitsandbytes optimizer paging with the rest of the QLoRA recipe.
- Tim Dettmers's bitsandbytes documentation walks through the unified memory mechanism that backs the paged variants and how it interacts with CUDA allocator behavior.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhat is the throughput cost of using a paged optimizer compared to an unpaged one, and where does that cost come from?
QHow does the paged optimizer differ from CPU offloading approaches like DeepSpeed ZeRO-Offload?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Believing the paged optimizer reduces total memory consumption. It actually only shifts where Adam's state lives; the win is OOM safety during transient spikes, not absolute footprint reduction.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.