Topic 41 of 62 · Training at scale
MFU and estimating training time
MediumHow do you estimate how long a pretraining run will take, and what is MFU?
1 · Start with the intuition
Training a dense Transformer costs about 6 FLOPs per parameter per token: 2 for the forward pass and about 4 for backward. Multiply by parameters and tokens for the total work. Divide by the GPUs’ peak throughput times the fraction you actually achieve, the model FLOPs utilization, to get wall-clock time.
2 · How the mechanism works
Mechanism step 1 of 3 · no question to answer
Total FLOPs
C ≈ 6 · N · D for N parameters and D training tokens.
Next, we will look at: Achieved throughput. Move on when this operation makes sense.
Visualizing the behavior
7B × 2T tokens on 1,024 GPUs (989 TFLOP/s peak): time vs MFU
Derived3 · The governing equation
C ≈ 6 N D MFU = (6 N · tokens/s) / (GPUs · peak FLOP/s) Time ≈ C / (GPUs · peak · MFU)
Notation: 6ND ignores the attention score FLOPs, which add about 12 · layers · d · seq per token and matter at long context. Hardware FLOPs utilization (HFU) also counts recomputation; MFU does not.
MFU, introduced in the PaLM paper, is comparable across systems because it counts only the FLOPs the model needs, not extra work like activation recomputation. Typical large-scale runs report MFU of roughly 30–50% in dense BF16; communication, pipeline bubbles, memory-bound ops, data stalls and failures consume the rest. Use dense peak numbers, not sparsity-accelerated ones, and include restart and checkpoint overhead in the schedule.
4 · Put concrete numbers on it
Worked numbers (from stated assumptions)5 · Common misconception to avoid
“Our MFU is 60% because profiling shows the GPUs are busy.” Busy time includes recomputation and non-model work; MFU counts only the model’s necessary FLOPs against dense peak.
In practice · implementation & engineering rule of thumb
Log achieved tokens/sec/GPU and convert it directly to MFU on every step; a drop in MFU without a code change immediately flags a straggler node, thermal throttling, or network degradation.
def compute_mfu(num_params, tokens_per_sec_per_gpu, gpu_peak_tflops=989.0):
# 6 FLOPs per parameter per token (2 forward + 4 backward)
achieved_tflops = (6.0 * num_params * tokens_per_sec_per_gpu) / 1e12
return achieved_tflops / gpu_peak_tflopsGo one level deeper
Follow-ups that often come after a correct first answer.
- Where MFU goes
- Common losses: exposed communication (TP all-reduces, unoverlapped DP), pipeline bubbles, memory-bound kernels (norms, activations, softmax), small matmuls from high TP, data-loader stalls and straggler GPUs. Profile one step and attribute time before tuning.
- Inference-aware training budgets
- Chinchilla optimizes loss for a fixed training budget. If a model will serve many tokens, total cost includes inference, so training a smaller model on more tokens than compute-optimal can minimize lifetime cost.
6 · Self-check & interview synthesis
Explain it in your own words first
Before revealing the reference answer, try answering the opening question aloud in four beats: what it is → how the math works → what trade-off it makes → a concrete number or failure mode.
Follow-up question interviewers often ask next
MediumUsing the Chinchilla rule of thumb, how many tokens for a 7B model?
Show follow-up reasoning
About 20 tokens per parameter, so roughly 140B tokens for compute-optimal training. Many modern models train far longer (trillions of tokens) because they optimize for inference cost, where a smaller, over-trained model is cheaper to serve.