Why training needs more than the download
Running a model needs little more than its weights: a 7B model in 16-bit is about 14 GB. Training needs more, because every weight that learns also needs a gradient (which way to move it) and optimizer state (Adam's running averages that set how far). On top come the activations from the forward pass, which grow with batch size and example length. Which of these exist for which weights is what separates full fine-tuning from LoRA.
The rule of thumb
LoRA ≈ 2 GB per billion parameters + ~3 GB
frozen 16-bit weights adapter, activations, overhead
full ≈ 12 GB per billion parameters + ~4 GB
16-bit weight 2 bytes
16-bit gradient 2 bytes
Adam moment 1 (fp32) 4 bytes
Adam moment 2 (fp32) 4 bytes
─────────
12 bytes per weight
(+ 4 bytes for a 32-bit master copy = 16)- LoRA keeps the base frozen in 16-bit: 2 bytes per weight, so 2 GB per billion parameters. The adapter is tiny, and the ~3 GB covers it, its optimizer state, activations at moderate lengths and the framework itself.
- Full fine-tuning trains every weight: a 16-bit weight and gradient plus Adam's two 32-bit moment estimates, 12 bytes per weight in all.
- QLoRA stores the frozen base in 4 bits, which brings memory down to roughly a third of LoRA's: an 8B model needs about 9 GB instead of 19.
The full fine-tuning page counts 16 bytes per weight, not 12. The difference is the 32-bit master copy of the weights that the classic mixed-precision recipe keeps alongside the 16-bit ones. This rule of thumb assumes training without that extra copy; a setup that keeps one needs about 16 GB per billion parameters. Both are estimates before long examples: activations come on top and grow with max length and batch size.
| Model size | LoRA | Full fine-tuning |
|---|---|---|
| 0.5B | ~4 GB | ~10 GB |
| 1.5B | ~6 GB | ~22 GB |
| 3B | ~9 GB | ~40 GB |
| 7B | ~17 GB | ~88 GB |
| 14B | ~31 GB | ~172 GB |
Activations are the part the rule can only approximate. They grow with the number of tokens held at once, batch size times example length, so doubling the max length roughly doubles them, and attention can add more on top for very long examples. The fixed overhead in the rule assumes moderate lengths. If your examples are long, leave extra headroom rather than planning to the last gigabyte.
How much memory you really have
On laptops with unified memory, such as Apple silicon Macs, the GPU shares the main memory, so a 36 GB laptop can give a model more room than a typical gaming GPU. But the operating system and your other apps need their share, so plan on roughly three-quarters of it being free for training. On a PC with a separate graphics card, the limit is the GPU's own memory, not the computer's RAM.
- Usable memory: after the operating system and apps, about 27 GB.
- 1.5B model: LoRA 2 × 1.5 + 3 ≈ 6 GB, full fine-tuning 12 × 1.5 + 4 ≈ 22 GB. Both fit.
- LoRA, larger models: a 7B model needs about 17 GB and fits; a 14B model needs over 30 GB and doesn't. In practice LoRA fits models up to about 10B.
- Full fine-tuning, larger models: a 3B model needs about 40 GB, so about 1.5B is the ceiling.
- QLoRA: a 27–32B model needs about 22–26 GB, which fits.
1.5B · LoRA 2 × 1.5 + 3 ≈ 6 GB
1.5B · full 12 × 1.5 + 4 ≈ 22 GBOn a 16 GB NVIDIA GPU, the same rule says an 8B model needs about 19 GB with LoRA, too much, but about 9 GB with QLoRA, which fits with room for longer examples.
If a run runs out of memory
- Lower the max length. Memory grows with example length, so this gives the most back. Check first that your typical examples still fit.
- Lower the batch size. Fewer examples per step means fewer activations held at once.
- Switch to QLoRA. The 4-bit base takes about a quarter of the memory of a 16-bit one.
- Use gradient checkpointing. It trades about 20–30% speed for much less activation memory, and many recipes already turn it on.
- Choose a smaller model, or use LoRA instead of full fine-tuning.
Common mistakes
- Judging by download size. Full fine-tuning needs six to eight times the 16-bit weights, plus activations.
- Counting all of a shared-memory laptop's RAM as available. The operating system and other apps need their share.
- Counting a PC's RAM instead of its graphics card's memory.
- Raising max length or batch size after a run fit, and expecting the next run to fit too.
- Cutting max length below the length of your typical examples, so the model never sees the end of the replies it should learn.
References and further reading
External sources open in a new tab.
- 01ZeRO: Memory Optimizations Toward Training Trillion Parameter ModelsRajbhandari et al., 2019 · arXiv · arxiv.orgThe standard accounting of weights, gradients and optimizer state per parameter.
- 02GPU memory usageHugging Face Transformers docs · huggingface.co
- 03Model memory estimatorHugging Face Accelerate docs · huggingface.coA tool to estimate a specific Hugging Face model's memory for running and training.
- 04Unified MemoryMLX docs · ml-explore.github.ioHow Apple silicon's CPU and GPU share one pool of memory.