// training
Fine-tuning VRAM Calculator — Full vs LoRA vs QLoRA
Estimate the GPU memory to fine-tune an LLM, broken down into base weights, gradients, optimizer state and activations.
Total training VRAM
4.2GB
Base weights
3.7GB
Gradients
0.1GB
Optimizer
0.1GB
Activations
0.4GB
qlora · Llama 3.1 8B · bs1 · seq 2048 · ckpt → 4.2 GB
Fits on a single GPU (108 of 108)
Presets verified 2026-09. A first-order estimate. Full fine-tune keeps an fp32 master copy plus bf16 grads plus optimizer state — that's why it needs ~4–5× the inference footprint. LoRA/QLoRA train <1% of the parameters, so grads and optimizer state almost vanish and activations dominate. DeepSpeed ZeRO-3 / FSDP shard base+grads+optimizer across GPUs; CPU/NVMe offload trades speed for memory — neither is modelled here.
Where training memory goes
Four buckets, shown as a stacked bar:
- Base weights. The model itself.
params × 2for a bf16 full fine-tune,params × 0.5for a 4-bit QLoRA base. - Gradients. One per trainable parameter, in bf16. For full tuning that is every parameter; for LoRA/QLoRA it is well under 1% of them.
- Optimizer state. AdamW keeps two moments per trainable parameter (~8 bytes). 8-bit AdamW cuts that to ~2. Full tuning also keeps an fp32 master copy of the weights (~4 bytes/param).
- Activations. Intermediate tensors held for the backward pass. Scales with
batch × sequence length × hidden size × layers. Gradient checkpointing knocks this down to roughly√layers.
The rule of thumb
- Full fine-tune: ≈ 16 bytes/param before activations. A 7B model wants ~110–150 GB — multi-GPU territory. A 70B is a small cluster.
- LoRA: frozen bf16 base (2 B/param) + tiny trainable set. A 7B fits on a single 24 GB card; a 70B on 2× 48 GB.
- QLoRA: frozen 4-bit base (0.5 B/param) + tiny trainable set. A 7B fits in ~6–8 GB; a 70B on one 48 GB card, sometimes on 24 GB with a short sequence.
Worked example
Llama 3.1 8B, QLoRA, rank 16, batch 1, sequence 2048, 8-bit AdamW, gradient checkpointing on:
- Base (4-bit): 8.03e9 × 0.5 ≈ 4.0 GB
- Gradients + optimizer (adapters only): well under 0.5 GB
- Activations (checkpointed): ~2–3 GB
- Total ≈ 7–8 GB — comfortable on a 12 GB card.
Switch to a full fine-tune of the same model and the total jumps past 120 GB.
Notes
Presets carry a verified date; every field accepts custom values. This is a planning estimate — DeepSpeed ZeRO-3 and FSDP shard the base, gradients and optimizer across GPUs, and CPU/NVMe offload trades speed for memory. Neither is modelled here.
- Why does full fine-tuning need so much more memory than running the model?
- Inference stores one copy of the weights. Training stores four things — the weights, a gradient for every weight, the optimizer state (AdamW keeps two running averages, about 8 bytes per parameter), and usually an fp32 master copy of the weights for mixed precision. That is roughly 16 bytes per parameter before activations, versus 2 bytes for fp16 inference.
- How much does QLoRA actually save?
- A lot. The base model is frozen in 4-bit, so it costs about 0.5 bytes per parameter and has no gradient or optimizer state. Only the small LoRA adapters are trained. A 70B model that needs ~1.5 TB for a full fine-tune drops to something that fits on a single 24 to 48 GB card with QLoRA, at some speed and quality cost.
- What does gradient checkpointing change?
- It trades compute for memory. Instead of keeping every layer's activations for the backward pass, it keeps a few checkpoints and recomputes the rest. Activation memory drops from roughly linear in layer count to roughly the square root of it, at the cost of about 20 to 30 percent more compute per step.
- The estimate seems off for my exact setup.
- It is a first-order model. It does not account for the framework (DeepSpeed, FSDP, Unsloth), CPU or NVMe offload, flash-attention's activation savings, packing, or your exact LoRA target modules. Use it to pick a method and a batch size, then confirm with a real run.