Vibe Engines
YouTube

Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path

Fine-Tuning Cost Estimator

Pick a method (QLoRA / LoRA / full AdamW), model size, dataset and GPU, and get the napkin answer: training memory, how many cards you need to fit, GPU-hours from the 6·P·tokens FLOPs rule, wall-clock time and the rental bill — with the QLoRA-vs-full memory gap made painfully visible.

Estimates use 6·P·tokens training FLOPs at 35% utilization and rental list prices. Real runs vary with sequence length, parallelism and luck — treat as ±40% napkin math.
$46Estimated cost18.3 GPU-hours × $2.5/hr
1×GPUs to fitfits on a single card
5.6 GBTraining memory8B × 0.75 bytes/param
18.3 hWall-clock (ideal)150M tokens trained
Why QLoRA is the default: at 8B parameters, full fine-tuning wants 128 GB of training memory; QLoRA wants 6 GB — same FLOPs, a fraction of the hardware.

A fine-tuning budget has two separate questions in it: what hardware can hold the job, and how long that hardware runs. This estimator answers both from five inputs, the method, model size, dataset size, epochs and GPU, and shows that the method mostly changes the first answer while the dataset drives the second.

What it computes

memory     = P × bytes per parameter / 1,024³        GB
GPUs       = ⌈ memory / (VRAM × 0.85) ⌉
tokens     = dataset × epochs
GPU-hours  = 6 × P × tokens / (TFLOPs × 10¹² × 0.35) / 3,600
wall-clock = GPU-hours / GPUs
cost       = GPU-hours × price per GPU-hour
  • P is the parameter count. Bytes per parameter is 16 for full fine-tuning with AdamW, 2.5 for LoRA on a 16-bit base and 0.75 for QLoRA on a 4-bit base.
  • 6 × P × tokens is the standard estimate of training FLOPs: about 2 per parameter per token forward and 4 backward.
  • 0.35 is the assumed utilization: real fine-tuning jobs reach a fraction of a GPU’s peak.
  • The GPU table uses dense BF16 throughput, 165, 121, 312 and 989 TFLOPs for the RTX 4090, L4, A100 and H100, with illustrative rental prices of $0.50, $0.70, $2.50 and $3.50 per hour.

A worked example

The defaults are QLoRA on an 8B model, 50 million tokens, 3 epochs, on an A100 80 GB.

  1. Memory: 8 × 10⁹ × 0.75 = 6.0 billion bytes = 5.6 GB. One card offers 80 × 0.85 = 68 GB, so 1×, fits on a single card.
  2. Tokens: 50M × 3 = 150M trained.
  3. FLOPs: 6 × 8 × 10⁹ × 1.5 × 10⁸ = 7.2 × 10¹⁸.
  4. Throughput: 312 × 10¹² × 0.35 = 1.09 × 10¹⁴ FLOPs per second, so 7.2 × 10¹⁸ / 1.09 × 10¹⁴ = 65,934 s = 18.3 GPU-hours.
  5. Cost: 18.3 × $2.50 = $45.79, shown as $46, and the ideal wall-clock is 18.3 h.
Same job, 8BMemoryGPUsWall-clockCost
QLoRA, A1005.6 GB118.3 h$46
LoRA, A10018.6 GB118.3 h$46
Full, A100119.2 GB29.2 h$46
QLoRA, H1005.6 GB15.8 h$20
QLoRA, RTX 40905.6 GB134.6 h$17

On one GPU type the bill does not change with the method; only the card count and the clock do. At 70B the gap becomes decisive: a full fine-tune needs 1,043 GB and 16 A100s, while QLoRA needs 48.9 GB and one.

Assumptions and limits

  • Activations are not counted. Long sequences and large batches add memory beyond the bytes-per-parameter figures, sometimes a lot, so a job shown as fitting can still run out of memory.
  • Perfect scaling. Multi-GPU runs lose time to communication, often 10 to 30%, and the tool ignores it.
  • One FLOP formula for every method. Adapter methods can save some backward-pass compute and QLoRA adds dequantization work; neither is modeled.
  • Fixed utilization and prices. 35% and the hourly rates are planning defaults. Real utilization and market prices vary widely by provider.
  • One run. Experiments, failed runs and evaluation are not included.

How to use the result

  • Pick the method by memory: use the cheapest card class the job fits on, then compare cost and wall-clock across GPUs.
  • Faster cards can be cheaper. A higher hourly rate can still win if throughput rises faster, as the H100 row shows.
  • Budget three to five times the single-run cost for hyperparameter trials and reruns.
  • Spend on data before epochs. Cost is linear in tokens trained; doubling epochs doubles the bill and rarely fixes weak data.

When to use it, and when not

Use it to choose a method and a card before you write a training script. Memory settles the method: QLoRA, LoRA or full. Then cost and wall-clock settle the card. It is also a quick check on a quote: if a provider’s price is ten times this estimate, ask what you are paying for.

Run a pilot instead once you have the data and a script. Fifty steps at your real sequence length and batch size tell you the peak memory, activations included, and the tokens per second. Divide the tokens you will train by that rate and you have GPU-hours that no utilization constant can match. Also measure for multi-node jobs, where the network sets the pace.

Trade-offs and limits

Each method is one bytes-per-parameter number. Here is what those numbers contain:

MethodBytes per parameterMade of8B model
Full (AdamW)162 BF16 weights + 2 gradients + 12 for FP32 master weights and two Adam moments119.2 GB
LoRA2.52 for the frozen BF16 base + 0.5 allowance18.6 GB
QLoRA0.750.5 for the 4-bit base + 0.25 allowance5.6 GB

The adapters themselves are tiny. Rank 16 on the query and value projections of a Llama-3-8B-shaped model (32 layers, 4,096 wide, a 1,024-wide value projection) is 6.8M parameters, 0.085% of the model. Even at 16 bytes each that is 104 MB, well inside the 3.7 GB LoRA allowance. The allowance is really slack for what the tool leaves out: activations.

Activations can outgrow everything else. A rough published estimate for a GPT-style layer is 34 bytes per token per hidden unit in 16-bit, before attention scores. One 2,048-token sequence through 32 layers 4,096 wide is then about 8.5 GB, more than QLoRA’s whole 5.6 GB, and it doubles with sequence length. Gradient checkpointing keeps only each layer’s input, about 0.5 GB here, and pays for it with an extra forward pass: 8 × P × tokens instead of 6, a third more time.

Common mistakes

  • Entering words, not tokens. English text runs at roughly 0.75 words per token, so a 37.5M-word dataset is about 50M tokens. Entering the word count understates time and cost by a quarter.
  • Forgetting padding. Batches padded to the longest example compute the padding too. Twenty thousand examples averaging 600 tokens but padded to 2,048 make 41.0M processed tokens per epoch, not 12M. Packing several examples into each sequence recovers the difference.
  • Trusting “fits” at long sequence lengths. The memory figure has no activations in it. If a job that fits runs out of memory on its first step, shorten the sequences, shrink the micro-batch or turn on gradient checkpointing before you rent a bigger card.
  • Expecting more cards to cost less. Cards divide the wall-clock, not the GPU-hours. A full fine-tune of 8B needs six RTX 4090s for memory and finishes in 5.8 hours, but still costs $17, before the 10 to 30% that multi-GPU communication adds.

Check yourself

QLoRA on a 70B model with the default 50M tokens and 3 epochs: how many H100s, and what does it cost?

Memory is 48.9 GB, under one card’s 68 GB, so one. GPU-hours are 6 × 70 × 10⁹ × 1.5 × 10⁸ / (989 × 10¹² × 0.35) / 3,600 = 50.6, so about $177 at $3.50. The same job on an A100 takes 160.3 hours and costs $401.

What is the largest model each method fits on a single 80 GB card here?

Usable memory is 80 × 0.85 = 68 GB, or 73.0 billion bytes. Divide by bytes per parameter: about 4.6B for full fine-tuning, 29.2B for LoRA and 97.4B for QLoRA, before activations.

A full fine-tune of 8B on RTX 4090s: how many cards, how long and how much?

Each card offers 24 × 0.85 = 20.4 GB, and 119.2 GB needs ⌈5.84⌉ = 6. GPU-hours are 7.2 × 10¹⁸ / (165 × 10¹² × 0.35) / 3,600 = 34.6, so 5.8 hours on six cards and $17, the same bill as one card running QLoRA.

Those 20,000 examples (600 tokens average, padded to 2,048) train 8B for 3 epochs on an A100. What does packing save?

Padded, the run processes 20,000 × 2,048 × 3 = 122.9M tokens: 15.0 GPU-hours, $37.51. Packed, it is 20,000 × 600 × 3 = 36M: 4.4 GPU-hours, $10.99. Packing saves about 71%, more than switching GPUs would.

68 GB usable 2 × 68 GB QLoRA 5.6 GB · 1 card LoRA 18.6 GB · 1 card Full 119.2 GB · 2 cards 0 40 80 120 GB same compute for all three: 18.3 GPU-hours, $46
Training memory for 8B at the tool’s bytes per parameter, against the 68 GB usable on one A100. The method decides the card count; the compute, and so the bill, does not change.

How it works

  • GPU-hours = 6 · params · tokens ÷ (TFLOPs × 35% utilization).
  • Memory: full ≈ 16 B/param, LoRA ≈ 2.5, QLoRA ≈ 0.75 (activations excluded).
  • GPUs-to-fit uses 85% usable VRAM; parallelism overhead not included.
  • GPU prices are illustrative rental rates; substitute your own.

Frequently asked questions

How are GPU-hours estimated?

From the standard training-compute rule: total FLOPs are about 6 times the parameter count times the tokens trained, covering the forward and backward passes. The tool divides that by the GPU’s dense BF16 throughput at 35% realized utilization and converts seconds to hours. Tokens trained are the dataset size times the number of epochs. It is napkin math, since sequence length, batch size, parallelism and data loading all move real runs, so treat it as roughly plus or minus 40%.

How much does it cost to fine-tune an 8B model?

With the tool’s defaults, QLoRA on 50 million tokens for 3 epochs, the run is 150 million trained tokens and about 18.3 GPU-hours on an A100, or about $46 at the illustrative $2.50 per hour rate. The same run is about $20 on an H100 at $3.50 per hour, because the H100 is roughly three times faster, and about $17 on an RTX 4090 at $0.50 per hour, though it takes 34.6 hours there. Substitute the rates you can actually rent at.

Why does QLoRA need so much less memory than full fine-tuning?

Full fine-tuning with AdamW holds the weights, the gradients and two optimizer moments for every parameter, roughly 16 bytes per parameter in mixed precision. QLoRA freezes the base model in 4-bit, about half a byte per parameter, and trains only small 16-bit adapters, which this tool models as 0.75 bytes per parameter overall. That is over 20 times less memory: a 70B model needs about 1,043 GB for a full fine-tune but about 49 GB for QLoRA, before activations.

Does LoRA or QLoRA train faster than full fine-tuning?

Not by much per token. Adapter methods still run the full forward pass and backpropagate through every layer of the frozen base, so they need most of the compute of full fine-tuning. They skip the gradients for the frozen weights, which can save up to about a third, but QLoRA spends some of that back dequantizing 4-bit weights. This tool charges all three methods the same 6 times parameters times tokens, so the method changes the GPUs you need, not the bill.

How many epochs should I plan for?

Instruction fine-tunes typically converge in one to three epochs, and more passes usually overfit a small dataset, memorizing examples instead of learning the pattern. For budgeting, three epochs is a sensible default, and the tool scales cost linearly with it. If quality is not there after that, the fix is almost always better or more varied data, not more passes over the same examples, so hold back an evaluation set to check.