LLM fine-tuning cost calculator
Calculate exact training FLOPs, VRAM, minimum GPU count, wall-clock duration, and total cloud bill for fine-tuning open LLMs. Compare Full Fine-Tuning, BF16 LoRA, and 4-bit QLoRA side by side before renting a cluster.
Interactive calculator
| Metric | Full Fine-Tuning | BF16 LoRA | 4-bit QLoRA |
|---|
Memory & compute formulas used
- Full Fine-Tuning:
6 × N × DFLOPs (plus+25%if gradient checkpointing recomputes activations). Memory is~16 bytes/param(BF16 weights + BF16 grads + FP32 AdamW master/m/v) plus activations. - BF16 LoRA:
~4.2 × N × DFLOPs (frozen base skips weight-gradient GEMMs). Memory is~2.25 bytes/paramplus activations. - 4-bit QLoRA:
~4.2 × N × DFLOPs at ~0.72x effective MFU due to NF4→BF16 on-the-fly dequantization. Memory is~0.75 bytes/paramplus activations.
Frequently asked questions
How are LLM fine-tuning FLOPs calculated?
Full fine-tuning uses approximately 6 × N × D FLOPs (2N for forward pass, 4N for backward pass over activations and weights), where N is parameter count and D is total training tokens (dataset tokens × epochs). LoRA skips base weight gradients and uses roughly 4.2 × N × D FLOPs, while QLoRA adds ~25–35% dequantization overhead on top of LoRA.
How much VRAM does Full Fine-Tuning require vs LoRA and QLoRA?
Full BF16 fine-tuning with AdamW requires ~16–18 bytes per parameter (2B weights + 2B grads + 12B FP32 master weights and optimizer states) plus activations, or ~1,200 GB for a 70B model. BF16 LoRA needs ~2.3 bytes/param (~165 GB for 70B), and 4-bit QLoRA needs ~0.75 bytes/param (~52 GB for 70B), fitting on a single 80 GB GPU.
Why is QLoRA sometimes slower per token than BF16 LoRA?
QLoRA must dequantize 4-bit NF4 base weights to BF16 during every forward and backward pass, reducing effective MFU by roughly 25–35%. However, because QLoRA requires far fewer GPUs, it often costs less in total cloud dollars when you would otherwise have to rent an 8× GPU node.
What Model FLOPs Utilization (MFU) should I expect in practice?
Well-tuned frameworks like Unsloth, Axolotl with FlashAttention-2/3, or Megatron-LM achieve 35%–48% MFU for full fine-tuning on H100/H200, 30%–40% for BF16 LoRA, and 22%–30% for 4-bit QLoRA. Unoptimized PyTorch loops often sit around 15%–25%.
How many epochs should I fine-tune an LLM?
For instruction or chat SFT, 2–3 epochs is standard; beyond 3–4 epochs, models rapidly overfit and lose general reasoning. For continued pretraining on domain corpora, 1 epoch is usually optimal.
All calculations run locally in your browser. Actual training cost depends on sequence packing efficiency, DataLoader bottlenecks, ZeRO/FSDP communication overhead, and spot vs on-demand pricing.