Skip to content

What is MFU, and how do you measure GPU efficiency?

MFU is achieved model FLOPs divided by the GPU's peak dense FLOPs. The formula, PyTorch logging code, published numbers and what MFU does to cost.

Model FLOPs utilization (MFU) is the share of a GPU’s peak dense math that your training run turns into model arithmetic: tokens per second, times FLOPs per token, divided by peak FLOPs. On Nodus, where an NVIDIA H100 SXM is listed at $2.60/hr on the pricing page, raising MFU from 30% to 40% cuts the cost of a billion trained tokens by a quarter. It is the most honest efficiency number you can log, because it counts work done, not time the GPU looked busy.

MFU comes from Google’s PaLM paper, and its Appendix B gives the exact formula. A dense decoder-only model with N parameters needs 6N matmul FLOPs per training token: 2N for the forward pass and 4N for the backward pass. Self-attention adds 12 × L × H × Q × T per token, where L is layers, H is attention heads, Q is head dimension and T is sequence length.

So the per-token cost is 6N + 12LHQT, and MFU is:

MFU = tokens_per_second * (6N + 12*L*H*Q*T) / peak_flops_per_second

The paper calls the attention term “a much smaller value for large models”. That stops being true at long context. H × Q equals the model dimension, and Meta’s Llama 3 8B has 32 layers and a model dimension of 4,096, per the Llama 3 paper.

At 8,192 tokens of context, attention for that shape adds 12 × 32 × 4,096 × 8,192 = 12.88 GFLOPs per token. Against 6 × 8 billion = 48 GFLOPs, that is 27% more work. Leave it out and you understate MFU by the same ratio.

For inference, a forward pass is one third of the training cost: 2N + 4LHQT per token. N should count parameters that do matrix multiplies. An input embedding table is a lookup, so leave it out; keep the output projection.

Which peak FLOPs number goes in the denominator?

Section titled “Which peak FLOPs number goes in the denominator?”

Use the dense BF16 Tensor Core figure for the exact card, and check for an asterisk. NVIDIA’s H100 page lists 1,979 teraFLOPS of BF16 for the H100 SXM, marked “With sparsity”. Dense is half, so 989 teraFLOPS. The HGX page lists 36 petaFLOPS of BF16 for an 8-GPU B200 board and says “Dense is ½ sparse spec shown”, which gives 2,250 teraFLOPS per B200.

Plugging the sparse figure in is the most common MFU mistake. It halves your reported number and makes a healthy run look broken. Match the precision too: if you train in FP8, say so and use the FP8 peak, because a BF16 MFU and an FP8 MFU are not comparable.

How is MFU different from HFU and nvidia-smi utilization?

Section titled “How is MFU different from HFU and nvidia-smi utilization?”

The three numbers answer different questions, and only MFU is comparable across codebases.

Hardware FLOPs utilization (HFU) counts every FLOP the GPU executes, including recomputation. With activation checkpointing, the forward pass runs twice, so HFU is higher than MFU for the same run. PaLM 540B reported 46.2% MFU and 57.8% HFU. The paper prefers MFU because it depends only on observed tokens per second, the architecture and the published peak, so runs on different systems compare fairly.

nvidia-smi’s “GPU utilization” is a time measure. NVIDIA’s nvidia-smi documentation defines it as the “percent of time over the past sample period during which one or more kernels was executing”. A run can show 95% there and still have low MFU, because a small kernel counts as busy. Low nvidia-smi utilization usually means a starved input pipeline, which our post on low GPU utilization in PyTorch walks through.

How do you log MFU in a PyTorch training loop?

Section titled “How do you log MFU in a PyTorch training loop?”

Count tokens per GPU, time a window of steps, and synchronize the GPU only when you log. CUDA launches are asynchronous, so a timer without a sync measures how fast Python queued work, not how fast the GPU did it. We ran this code on a toy model on CPU to check that it executes; the numbers it prints on your GPU are yours to measure.

import time
import torch
# Dense BF16 Tensor Core peak per GPU. NVIDIA lists sparse figures; dense is half.
PEAK_BF16 = {"H100 SXM": 989e12, "B200": 2250e12}
def flops_per_token(n_params, n_layers, d_model, seq_len, training=True):
"""PaLM (Appendix B): 6N + 12*L*H*Q*T per trained token, with H*Q = d_model.
A forward pass alone is one third of that: 2N + 4*L*H*Q*T."""
attn = 12 * n_layers * d_model * seq_len
return 6 * n_params + attn if training else 2 * n_params + attn / 3
class MFUMeter:
"""Call step(tokens) once per optimizer step with this GPU's tokens."""
def __init__(self, fpt, peak, usd_per_gpu_hr=None, every=50, skip=1):
self.fpt, self.peak, self.rate = fpt, peak, usd_per_gpu_hr
self.every, self.skip = every, skip # skip=1 drops the warm-up window
self.n, self.tokens, self.t0 = 0, 0, None
def step(self, tokens):
self.n += 1
if self.t0 is None: # start the clock after step 1
self._sync(); self.t0 = time.perf_counter(); return
self.tokens += tokens
if self.n % self.every:
return
self._sync() # sync only when logging
dt = time.perf_counter() - self.t0
tps = self.tokens / dt
mfu = tps * self.fpt / self.peak
msg = f"step {self.n} tok/s/GPU {tps:,.0f} MFU {mfu:.1%}"
if self.rate:
msg += f" $/B tok {self.rate / (tps * 3600) * 1e9:,.2f}"
if self.skip > 0:
self.skip -= 1 # first window includes compile/warm-up
else:
print(msg, flush=True)
self.tokens, self.t0 = 0, time.perf_counter()
@staticmethod
def _sync():
if torch.cuda.is_available():
torch.cuda.synchronize()

Create the meter once, then call it after each optimizer step:

fpt = flops_per_token(n_params=8e9, n_layers=32, d_model=4096, seq_len=8192)
meter = MFUMeter(fpt, PEAK_BF16["H100 SXM"], usd_per_gpu_hr=2.60)
# inside the loop, after optimizer.step():
meter.step(batch_size * seq_len) # this rank's tokens only

With data parallelism, each rank logs its own per-GPU MFU, which equals cluster MFU when ranks are balanced. Count real tokens, not padding: if you pad sequences, padded positions inflate the token count. On Nodus, anything the job prints to stdout is kept as its log and stays readable with nodus logs -f job/NAME after the run finishes, as the logs and metrics docs describe.

What does a tokens-per-second reading cost on Nodus at different MFU?

Section titled “What does a tokens-per-second reading cost on Nodus at different MFU?”

Take one illustrative reading, not a benchmark we ran: an 8-billion-parameter model shaped like Llama 3 8B, 8,192-token sequences, 6,000 tokens per second per H100 SXM. We round N to 8 billion so the arithmetic stays readable.

  • FLOPs per token: 48 + 12.88 = 60.88 GFLOPs.
  • Achieved: 6,000 × 60.88 GFLOPs = 365.3 teraFLOPS per GPU.
  • MFU: 365.3 / 989 = 36.9%. With the 6N term alone it would be 288 / 989 = 29.1%. Divide by the sparse 1,979 by mistake and it reads 18.5%.
  • Cost: 6,000 × 3,600 = 21.6 million tokens per GPU-hour. At $2.60/hr, a billion tokens costs $2.60 / 21.6 × 1,000 = $120.37.

The same run of 6,000 tokens per second per H100 SXM reads 36.9% MFU with PaLM’s full formula, 29.1% with the 6N term only, and 18.5% if divided by the sparse peak. One measurement, three answers: always say which formula and which peak you used.

Now hold the model fixed and vary MFU. Tokens per second is MFU × peak / 60.88 GFLOPs, and cost per billion tokens is the hourly rate divided by tokens per hour. At Nodus list rates for the H100 SXM ($2.60/hr) and B200 ($5.50/hr):

MFU H100 SXM tok/s/GPU H100 SXM $/B tokens B200 tok/s/GPU B200 $/B tokens
20% 3,249 $222.31 7,391 $206.71
30% 4,873 $148.21 11,087 $137.81
40% 6,498 $111.15 14,782 $103.35
50% 8,122 $88.92 18,478 $82.68

Prices checked December 5, 2026 on the Nodus pricing page. Peaks from NVIDIA’s H100 and HGX pages.

Cost per billion training tokens for an 8B model at 8,192 context: on H100 SXM at $2.60/hr, $222.31 at 20% MFU, $148.21 at 30%, $111.15 at 40% and $88.92 at 50%; on B200 at $5.50/hr, $206.71, $137.81, $103.35 and $82.68. Going from 20% to 40% MFU halves the bill on either card; changing cards at the same MFU moves it about 7%.

Cost scales with 1 / MFU, so the move from 20% to 40% saves more than any GPU swap in the table.

At equal MFU the B200 is about 7% cheaper per token, because $5.50 buys 2,250 dense teraFLOPS per hour against $2.60 for 989. Real MFU differs between generations, so measure both before you switch. To turn a cost per token into a whole-run budget and a spend cap, use our LLM training cost calculator.

What MFU is good, and what should you fix first?

Section titled “What MFU is good, and what should you fix first?”

Published large runs land between about 20% and 46%. PaLM’s Table 3 lists GPT-3 at 21.3%, Gopher at 32.5%, Megatron-Turing NLG 530B at 30.2% and PaLM 540B at 46.2%. The Llama 3 paper reports 38% to 43% BF16 MFU for the 405B model: 43% on 8,192 H100s, then 41% and 38% on 16,384, the lowest at 131,072-token context.

Published model FLOPs utilization: GPT-3 21.3%, Megatron-Turing NLG 30.2%, Gopher 32.5%, Llama 3 405B 38% (lowest stage) and 43% (highest), PaLM 540B 46.2%. The best published runs reach 38% to 46%; 30% is a realistic plan for a dense model.

Our rule of thumb for a dense transformer of 1 billion parameters or more, trained in BF16, is set from those published figures rather than from a benchmark of ours:

  1. Below 20%: something is broken. Check nvidia-smi utilization first. If it is low, fix the input pipeline before anything else.
  2. 20% to 30%: the GPU is busy but inefficient. Raise the per-GPU batch, pack sequences instead of padding, and use a fused attention kernel.
  3. 30% to 40%: good. Profile before changing anything; communication and optimizer steps are the usual remaining costs.
  4. Above 40%: you are in published large-run territory. Spend your time on the data, not the kernels.

Smaller models and small batches score lower for structural reasons, so compare against your own baseline as well as these bands.

MFU is the wrong yardstick for small-batch decoding. At batch size 1, each new token reads every weight once.

An 8B model holds 16 GB of BF16 weights, and NVIDIA’s H100 page lists 3.35 TB/s of memory bandwidth for the SXM card, so decode tops out near 209 tokens per second. That is 2 × 8 billion × 209 = 3.34 teraFLOPS, or 0.3% MFU. For inference, track tokens per second per dollar and latency instead.

PaLM’s definition does, through the 12LHQT term. Some codebases report the 6N version only, so state which one you used before comparing numbers.

It usually lowers MFU and raises HFU, because recomputed forward passes take time but do not count as model FLOPs. It can still pay off: PaLM used rematerialization because the larger batch it allowed gave higher training throughput.

Not if the inputs are right. A value above 100% usually means padded tokens were counted, tokens from all GPUs were divided by one GPU’s peak, or N was overstated.

MFU depends on your model and token count, so compute it in your training loop and print it. Nodus keeps that output in the job log, and nodus top shows GPU use and $/H for running jobs beside it.

More from the blog