Unit 1 of 14 · about 4 hours · derive, measure

Step time, token throughput and MFU versus HFU

Throughput numbers mean nothing without fixed workload semantics and stated FLOP counts. This unit fixes the definitions before any diagnosis.

You'll be able to

  • Define step time, tokens per second, MFU and HFU, stating the FLOP count and peak each ratio uses.
  • Derive tokens per second from step time and batch tokens, and MFU from model FLOPs over peak throughput.
  • Measure step time and tokens per second with warmup and synchronization, and label CPU timings as non-evidence for GPU interconnects.

Covers

Step time, samples per second and tokens per secondModel FLOPs utilization (MFU) and hardware FLOPs utilization (HFU)
1

Read

In this order, only the parts listed

0 of 3 done

  1. MFU versus HFU and FLOP countingMachine Learning Engineering Open Book - Network, Debug, Training Performance and Orchestration

    MFU vs HFU section with and the FlopCounterMode snippet; MFU is a very rough approximation subsection

  2. Rooflines and the H100 crossoverHow to Scale Your Model - Chapters 1, 5, 9 and 12

    Where Does the Time Go through A Few Problems to Work, with the intensity definition, the Q1 derivation and Q5 on the H100 SXM crossover near 295, all with answers

    Keep TPU ICI numbers labeled as TPU numbers. Re-parameterize the crossover for your hardware before quoting it.

  3. Roofline diagnosis and the MFU definitionMachine Learning Systems Volume II - Fleet Orchestration and Performance Engineering

    The Memory Wall and Roofline Diagnosis with the iron law and ridge table, and Measurement at Scale with the MFU bands (40 to 60 percent good, above 60 excellent)

2

Focus on

  • Step time is wall-clock per optimizer step at fixed global batch, sequence length and precision. Tokens per second is global-batch tokens divided by step time.
  • MFU uses model FLOPs, commonly for training, over peak. HFU uses actual FLOPs including recomputation and padding. State both before comparing.
  • MFU is rough under mixed precision because regions run in different formats while the peak assumes one. Compare before and after on the same setup, never across clusters.
Common mistakes · 3
  • Comparing MFUs built from different FLOP counts (with versus without attention terms, forward-only versus training) or different peaks (sparse versus dense, BF16 versus FP16).
  • Reading CPU gloo step times as evidence about GPU throughput or interconnects. They check semantics only.
  • Treating FlopCounterMode as exact. It has performance and memory problems and serves as a cross-check, not the answer.
3

Try it yourself

Closed-book, before checking anything

Closed-book, derive tokens per second and MFU for parameters, tokens and s at the H100 SXM dense BF16 peak of TFLOP/s: tokens/s is about 33,333, model FLOPs are , achieved about 200 TFLOP/s, MFU about 20 percent.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.How are step time, global-batch tokens and tokens per second related?Answer

    Tokens per second is at fixed batch, sequence and precision. Change any of the three and the ratio is incomparable.

  2. 2.Why can HFU exceed MFU on the same run?Answer

    HFU counts the FLOPs the hardware actually ran, including recomputation and padding. MFU counts model FLOPs only, so extra work raises HFU but not MFU. Waiting in collectives adds time, not FLOPs, and lowers both.

  3. 3.A paper reports 55.2 percent MFU on 12,288 GPUs. Can you compare your single-GPU MFU to it?Answer

    No. Different hardware, FLOP-count convention and workload. The 55.2 percent figure is MegaScale's own cluster result for a 175B model, not a transferable target.

  4. 4.Manual arithmetic and FlopCounterMode disagree. Which do you trust?Answer

    The manual count with stated assumptions. The counter is a cross-check with known performance and memory issues.

5

Practice

  • CS336 Assignment 2: benchmarking_script and benchmarking_mixed_precision

    Section 2.1.3 benchmarking_script and Section 2.1.5 benchmarking_mixed_precision in the Spring 2026 handout; produce warmup-controlled forward, backward and full-step timings with torch.cuda.synchronize

    Run the portable parts on your machine. GPU timing needs CUDA. Report step time, batch tokens, tokens/s, hardware, PyTorch version and precision.

You're done when

You can state tokens/s, the FLOP count and the peak for one run, and explain why its MFU cannot be compared to a published cluster MFU.

Only when you can do this without notes.

Leads to

Notes

Resources · 3 for this unit, 8 more in the section
  • Machine Learning Systems Volume II - Fleet Orchestration and Performance EngineeringML Systems Textbook · primary

    Read Scheduling Problem, Orchestration Paradigms, Topology-Aware Scheduling, Elastic Scheduling, Cost Optimization, Multi-Tenancy and Quotas and Debugging Cluster Utilization, then Memory Wall and Roofline Diagnosis, Graph Compilation, Communication-Computation Overlap, System Profiling and Measurement at Scale at https://mlsysbook.ai/vol2/performance_engineering/performance_engineering.html. Use the framework to choose one bottleneck-specific lab and one rollback metric.

  • Machine Learning Engineering Open Book - Network, Debug, Training Performance and OrchestrationStas Bekman · required

    Use network/debug/README.md, the hang, crash and OOM sections of debug/pytorch.md, training/performance/README.md, storage/README.md and orchestration/slurm/users.md as an incident-driven reference. Build one symptom-to-evidence-to-cause runbook rather than reading every page.

  • How to Scale Your Model - Chapters 1, 5, 9 and 12Google DeepMind · required

    Use rooflines, training cost models, profiling workflow and GPU topology to predict the dominant limit of one run. Compare the prediction with a trace and quantify the residual before proposing a change.

Also in this section

  • AI Systems Performance Engineering - Chapters 1 to 5, 13 and 14Chris Fregly (O'Reilly) · required

    Use Chapter 1 for goodput and reproducibility, Chapters 2 to 5 for topology, orchestration, communication, storage and the data pipeline, Chapter 13 for PyTorch profiling and scaling, and the Chapter 14 sections on graph breaks and recompilation. Run only the companion labs for the bottleneck you observe, preserve workload correctness and record hardware assumptions.

  • PyTorch Flight Recorder TutorialsPyTorch · support

    Read the environment-variable Flight Recorder tutorial (trace buffer, dump on timeout, fr_trace analysis), then the newer tutorial at https://docs.pytorch.org/tutorials/intermediate/debug_hangs_with_flight_recorder.html, which needs torchcomms and can run on CPU with Gloo. Diagnose one injected hang from per-rank dumps.

  • MegaScale: Scaling Large Language Model Training to More Than 10,000 GPUsJiang et al. (NSDI 2024) · support

    Read the efficiency optimizations, the fault-tolerance loop (heartbeats, diagnostics, fast restart) and the straggler and diagnosis tooling. Its MFU and scale numbers are its own cluster's results.

  • Revisiting Reliability in Large-Scale Machine Learning Research ClustersKokolis et al. (2024) · support

    Read the failure taxonomy, mean time to failure versus job size and the scheduler-side metrics. Use them to model goodput with failures for one job size.

  • CS336 Assignment 2 (Spring 2026) - Profiling and Parallelism AnalysisStanford University · required

    Revisit Section 2 profiling and Section 8 communication analysis. Produce warmup-controlled timing, Nsight or PyTorch traces, memory evidence and analytic DP, FSDP, TP and 2D comparisons on configurations you can execute honestly.

  • Ultra-Scale Playbook - Benchmarking ConfigurationsHugging Face · support

    Study the configuration-search experiments and Lessons learned on benchmarking as method. Its heatmaps are its own H100 cluster's results; reproduce the method on a tiny legal search space, separating analytic predictions, simulations and measurements.

  • TorchTitanPyTorch · depth

    Read docs/debugging.md (memory snapshots, fake-backend modes, Flight Recorder dumps) and the CPU unit tests under tests/unit_tests/cpu/, then the configuration, metrics, profiling, checkpoint and parallelization seams at a pinned commit. Select one bounded issue or measurable improvement and follow the contribution standards; do not attempt a wholesale rewrite.

  • Distributed Training Systems LaboratoryRoadmap-Final · support

    Complete the capstone with a fixed workload, correctness oracle, analytic plan, fault campaign, aligned traces and one real-code extension. Label CPU simulation, single-GPU evidence and multi-GPU evidence separately.