Everyday Tools

Planning a Transformer Training Run: FLOPs, GPU-Hours and Learning Rate

A practical guide to estimating model size, training compute, GPU-hours, compute-optimal data, batch sizes and warmup plus cosine learning-rate schedules.

Saizul Amin
Saizul Amin30 Oct 2026 · 3 min read
Planning a Transformer Training Run: FLOPs, GPU-Hours and Learning Rate

Planning a Transformer Training Run: FLOPs, GPU-Hours and Learning Rate

Training even a modest language model can cost thousands in compute, so it pays to estimate before you launch. Published research gives formulas that land within a reasonable margin of real runs. The training planner combines them; here is how each piece works.

Step 1: count the parameters

A decoder-only transformer layer has four attention projection matrices of size d × d and a feed-forward block that expands to 4d and back, about 8d². That gives roughly 12d² weights per layer. Add the embedding table, vocabulary × d:

N ≈ 12 × L × d² + V × d

With 24 layers, width 2,048 and a 50,000-token vocabulary, N is about 1.31 billion.

Step 2: total compute

Kaplan and colleagues showed that training needs about 6 floating-point operations per parameter per token: two for the forward pass and four for the backward pass. For 50 billion tokens:

C ≈ 6 × 1.31 × 10⁹ × 50 × 10⁹ ≈ 3.9 × 10²⁰ FLOPs

Step 3: convert to time

Hardware never reaches its advertised peak. Model FLOPs utilisation (MFU) measures the share you actually get; 35% to 50% is typical for a well-tuned setup. At 312 TFLOPS peak and 40% MFU, each GPU delivers about 125 TFLOPS, so the run needs about 875 GPU-hours. On eight GPUs that is under five days of wall-clock time, before restarts and evaluation.

Step 4: is that much data sensible?

The Chinchilla study by Hoffmann and colleagues found that, for a fixed compute budget, the best results come from about 20 tokens per parameter. For our 1.3 B model that is about 26 B tokens. Training on 50 B tokens costs more than the compute-optimal plan, but many teams do this on purpose: a smaller model trained longer is cheaper to run afterwards.

Step 5: batches and steps

Large global batches stabilise training, but each GPU can only hold a few sequences. Gradient accumulation sums gradients over several micro-batches before updating:

global batch = micro-batch × GPUs × accumulation steps

With 8 sequences per GPU on 8 GPUs and a target of 256, accumulate 4 times. With 2,048-token sequences, 50 B tokens make about 95,000 optimiser steps.

Step 6: the learning-rate schedule

Two parts are standard. A linear warmup over the first few hundred or thousand steps prevents large, unstable updates while the optimiser's statistics settle. A cosine decay then lowers the rate smoothly toward about a tenth of the peak by the end. The planner prints the rate at milestones so you can paste them into a config or check a scheduler's output.

Fine-tuning instead of pre-training

Most teams never pre-train from scratch; they fine-tune an existing model on a few thousand examples. The same planner helps. Enter the number of examples to see steps per epoch for your global batch, then multiply by the epochs you intend to run. Compute is tiny compared with pre-training, so the useful outputs become the schedule and the batch arithmetic. Keep warmup short, around 3% to 10% of the total steps, and use a lower peak learning rate than pre-training; values a tenth of the original are a common starting point. Watch validation loss each epoch, since small datasets overfit quickly.

What the estimates leave out

  • Attention-score compute, which grows with sequence length.
  • Communication between GPUs and nodes.
  • Checkpointing, evaluation and failed runs.
  • Data preparation time.

Add a margin of 20% or more for a first run, and measure real throughput in a short trial before committing a large budget. The output is a planning aid, not a guarantee.

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages