Custom AI models for the enterprise · New York · LondonSecurityResearchContact sales
Finetune the World
Research · Calculator

How much GPU memory does it take to fine-tune an LLM?

Exact parameter counts from eight real model configurations, a memory model you can check line by line, and the answer to the question every project starts with: which GPUs do we need?

The answer, first#

For a sequence length of 4,096 tokens, micro-batch 1 and full activation checkpointing, our model gives these training-memory requirements (weights, gradients, optimizer state and activations; no framework overhead):

ModelParamsFull fine-tuneLoRA r=16QLoRA r=16
Qwen2.5-0.5B0.49B9.8 GB3.5 GB2.9 GB
Qwen2.5-1.5B1.54B26 GB5.8 GB3.7 GB
Qwen2.5-3B3.09B49 GB9.1 GB4.8 GB
Mistral-7B-v0.17.24B109 GB16 GB5.6 GB
Qwen2.5-7B7.62B117 GB18 GB7.3 GB
Qwen2.5-14B14.77B224 GB33 GB12 GB
Qwen2.5-32B32.76B493 GB68 GB23 GB
Qwen2.5-72B72.71B1,091 GB146 GB45 GB

Three things stand out. Full fine-tuning of a 7B model needs about 117 GB, which means at least two 80 GB GPUs with sharded optimizer state. LoRA brings the same model to 18 GB, a single 24 GB card. And QLoRA puts a 72B model at 45 GB, inside one 80 GB GPU. Add 1–3 GB for the CUDA context, allocator fragmentation and framework buffers before you buy.

110100100011010024 GB80 GBFull FTLoRA r=16QLoRA r=16Parameters (billions, log scale)Training memory, GB (log scale)
Training memory versus model size for the Qwen2.5 family (log–log), including activations at 4,096 tokens with checkpointing. Dashed lines mark 24 GB and 80 GB GPUs. Source: research/e2_memory/memory.py.

Counting parameters from a config file#

Every number above starts from the model’s config.json. For a decoder with hidden size , layers, MLP width , query heads, key/value heads (grouped-query attention), head dimension and vocabulary :

The SwiGLU MLP has three matrices (gate, up, down), which is why the MLP term is rather than the of older GPT-style models; at 7B it is roughly two-thirds of all parameters. Grouped-query attention shrinks k and v by (7× for Qwen2.5-7B). Embedding tying matters for small models: in Qwen2.5-0.5B the 136M-parameter embedding is shared with the output head; untying it would add 28% to the model.

Our counter reproduces the published sizes: 0.49B for Qwen2.5-0.5B, 7.62B for 7B, 72.71B for 72B and 7.24B for Mistral-7B, which is our check that the formula and the configs agree.

What each byte is for#

Training with mixed-precision AdamW keeps four things per trainable parameter. Following the accounting in the ZeRO paper:

TensorPrecisionBytes / param
Weights (used in forward/backward)bf162
Gradientsbf162
Master copy of weightsfp324
Adam first moment mfp324
Adam second moment vfp324
Total, full fine-tuning16

LoRA freezes the base weights, so they need only their bf16 copy (2 bytes) and no gradients or optimizer state. Each adapted matrix gains trainable parameters, which carry the full 16 bytes:

QLoRA stores the frozen base in 4-bit NormalFloat with double-quantized scaling constants, about 4.127 bits (0.516 bytes) per parameter according to the QLoRA paper’s accounting:

Two refinements change these figures in practice. An 8-bit optimizer stores Adam moments in one byte each, cutting the 12-byte optimizer term to roughly 6. ZeRO stage 3 or FSDP shards the 16 bytes across GPUs, so each holds . Full fine-tuning of 72B — 1,083 GB of states — therefore needs at least 14 GPUs of 80 GB before activations; in practice two 8-GPU nodes.

How big is a LoRA adapter?#

Adapter size is linear in rank. For Qwen2.5-7B with adapters on all seven linear projections in every layer:

Rank rTrainable params (all linear)% of modelTrainable params (q, v only)
12.5M0.03%0.32M
25.0M0.07%0.63M
410.1M0.13%1.26M
820.2M0.27%2.52M
1640.4M0.53%5.05M
3280.7M1.06%10.09M
64161.5M2.12%20.19M
128323.0M4.24%40.37M
256645.9M8.48%80.74M

Even at rank 256 the adapter is under a tenth of the model, so the optimizer state is never the problem with LoRA: the frozen base weights and the activations are. That is why rank is a quality decision rather than a memory decision. We measured how much rank actually buys on a real task in our LoRA rank experiment.

Activations: the term that grows with sequence length#

Weights scale with the model; activations scale with the batch. Korthikanti et al. derive the activation memory of one transformer layer, in bytes, for sequence length , micro-batch , hidden size and attention heads, with 16-bit activations:

The term is the attention score matrix, quadratic in sequence length. Memory-efficient attention kernels such as FlashAttention never materialize it, leaving . Full activation checkpointing stores only each layer’s input, , and recomputes the rest during the backward pass at the cost of one extra forward pass (see our compute model).

The constant 34 was derived for GPT-style layers; SwiGLU MLPs and grouped-query attention move it somewhat, so treat the no-checkpointing column as an estimate. One term is easy to forget: the output logits, bytes in fp32. With a 152k vocabulary and 4,096 tokens that alone is 2.3 GB per sequence — for Qwen2.5-0.5B it is most of the activation budget. Chunked cross-entropy implementations avoid materializing it.

ModelActivations, checkpointedActivations, not checkpointed
Qwen2.5-0.5B2.5 GB5.1 GB
Qwen2.5-1.5B2.6 GB7.9 GB
Qwen2.5-3B2.9 GB12 GB
Mistral-7B-v0.11.5 GB17 GB
Qwen2.5-7B3.1 GB15 GB
Qwen2.5-14B4.2 GB34 GB
Qwen2.5-32B4.8 GB45 GB
Qwen2.5-72B7.3 GB87 GB

Which GPU do you need?#

Mapping the totals onto common cards, with ~2 GB of headroom for framework overhead:

GPU memoryFull fine-tuningLoRA (bf16 base)QLoRA
24 GBup to ~1Bup to ~7Bup to ~14B (32B with short sequences)
48 GBup to ~2Bup to ~14Bup to ~32B
80 GBup to ~3Bup to ~32B (tight)up to ~72B
8 × 80 GB, shardedup to ~32B72B—

Our default for enterprise work: LoRA on bf16 weights when it fits, because QLoRA trades memory for slower steps (de-quantization on every forward pass) and a small quality cost from training against a quantized base. Full fine-tuning when the evaluation shows a gap LoRA cannot close — usually for larger distribution shifts.

Worked example: sizing a 14B QLoRA job#

A client wants to fine-tune Qwen2.5-14B on contracts averaging 8,000 tokens, on a single 48 GB GPU.

  1. Frozen base in NF4: ≈ 7.1 GB.
  2. Adapters, rank 16, all linear layers: 68.8M parameters × 16 bytes ≈ 1.0 GB.
  3. Activations at 8,192 tokens with checkpointing: roughly double the 4,096-token figure, ≈ 8.4 GB, of which logits are 4.6 GB.
  4. Overhead: 2–3 GB.

Total ≈ 19 GB: it fits on 48 GB with room for a micro-batch of 2. Chunked cross-entropy would recover most of the logits term; switching to bf16 LoRA (39 GB) would need an 80 GB card.

Six ways to cut training memory#

TechniqueWhat it reducesTypical savingCost
Activation checkpointingactivations≈ 17× per layer (34 → 2 sbh)+33% compute
8-bit Adamoptimizer state12 → ~6 bytes/paramnegligible quality impact in most reports
ZeRO-3 / FSDP shardingweights, grads, optimizer÷ number of GPUscommunication
Chunked cross-entropylogits4sbV → smallminor compute
Gradient accumulationactivations (via smaller micro-batch)linear in micro-batchmore steps, same tokens
CPU offload of optimizeroptimizer state on GPUup to 12 bytes/paramslow steps

Sequence packing (concatenating short examples to fill the context) does not lower peak memory, but it removes padding waste, which raises useful tokens per step at the same memory.

Limitations#

This is an analytical model, not a profiler trace. It excludes CUDA context and allocator fragmentation, assumes bf16 compute, ignores MoE routing buffers, and uses the GPT-derived activation constant for all architectures. Microsoft, PyTorch and Hugging Face tooling also allocate temporary buffers during optimizer steps and gradient all-reduce. Treat the tables as the floor you design against, then confirm with one short profiling run on target hardware.

Method and reproducibility

Model configurations downloaded from the official Hugging Face repositories (Qwen2.5 0.5B–72B, Mistral-7B-v0.1). Script: research/e2_memory/memory.py; output: research/results/e2_memory.json. Run with python memory.py; no GPU needed.

References#

  1. Rajbhandari, S. et al. (2020). ZeRO: Memory Optimizations Toward Training Trillion Parameter Models. SC20. arXiv:1910.02054.
  2. Dettmers, T. et al. (2023). QLoRA: Efficient Finetuning of Quantized LLMs. NeurIPS 2023. arXiv:2305.14314.
  3. Hu, E. J. et al. (2021). LoRA: Low-Rank Adaptation of Large Language Models. arXiv:2106.09685.
  4. Korthikanti, V. et al. (2023). Reducing Activation Recomputation in Large Transformer Models. MLSys 2023. arXiv:2205.05198.
  5. Dao, T. et al. (2022). FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness. NeurIPS 2022. arXiv:2205.14135.
  6. Qwen Team (2024). Qwen2.5 Technical Report. arXiv:2412.15115. Model configurations from the official Hugging Face repositories.

Frequently asked

Can’t find your question? Ask a senior engineer.

How much VRAM do I need to fine-tune a 7B model?

About 117 GB for full fine-tuning with AdamW (two or more 80 GB GPUs with sharding), about 18 GB for LoRA and about 7.3 GB for QLoRA, at 4,096-token sequences with activation checkpointing.

Can I fine-tune a 70B model on one GPU?

With QLoRA, yes: our model gives about 45 GB for a 72B model at 4,096 tokens, which fits on a single 80 GB GPU. Full fine-tuning needs over a terabyte of optimizer and weight state.

Why does full fine-tuning need 16 bytes per parameter?

Mixed-precision AdamW stores bf16 weights (2 bytes), bf16 gradients (2), an fp32 master copy of the weights (4) and two fp32 Adam moments (8).

Bring us one task. We’ll show you what a specialist model can do.

A 45-minute briefing with a senior research engineer. You leave with a feasibility read, a data plan and a fixed quote, whether or not you hire us.

Book a briefing →