Unit 13 of 14 · about 3 hours · derive

Cost per useful token and performance per watt

Throughput without price picks pretty configurations. Cost per useful token picks the one the budget can actually train on.

You'll be able to

  • Derive cost per useful token from goodput, price and overhead.
  • Compare throughput and latency designs in cost terms at fixed quality.
  • Explain performance per watt and where power dominates cost.

Covers

Cost per useful token and performance per watt
1

Read

In this order, only the parts listed

0 of 3 done

  1. Fleet cost optimizationMachine Learning Systems Volume II - Fleet Orchestration and Performance Engineering

    Cost Optimization with idle-cost math, spot versus reserved tiers and checkpoint-on-preemption strategy

  2. Goodput, power and upgrade ROIAI Systems Performance Engineering - Chapters 1 to 5, 13 and 14

    Chapter 1, Measuring Goodput Useful Throughput, and Chapter 2, Compute Density and Power Requirements with ROI of Upgrading Your Hardware

  3. End-to-end time and cost estimateHow to Scale Your Model - Chapters 1, 5, 9 and 12

    The LLaMA 70B case study on a TPU v5p pod with the training time estimate worked from the parallelism plan (44 days at 40 percent MFU, a TPU number)

2

Focus on

  • Cost per useful token is price per hour divided by goodput tokens per hour: . Goodput, not raw throughput, belongs in the denominator because failures and idle raise cost per finished token.
  • For training the trade is time to result against cost: more accelerators finish sooner at lower scaling efficiency, so each useful token costs more. Fix the quality target, a loss or eval score, before comparing configurations.
  • Performance per watt is useful tokens per joule, or . Idle and cooling watts count; an allocated but stalled fleet still bills and burns.
Common mistakes · 3
  • Pricing raw throughput instead of goodput. Restarts, retries and queue idle are paid for but produce no finished tokens.
  • Comparing an FP8 run with a BF16 run on dollars per token without a quality gate. Cheaper tokens that hurt convergence are not cheaper training.
  • Counting only compute watts. Idle draw, cooling and stalled-but-allocated hours dominate at fleet scale.
3

Try it yourself

Closed-book, before checking anything

Closed-book, derive dollars per 1k tokens for dollars per hour at tokens/s: hourly tokens are , so dollars per token, about 0.00044 dollars per 1k and 0.44 dollars per 1M.
4

Quiz yourself

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

0 got · 0 missed

  1. 1.Write the cost-per-useful-token formula and name each term.Answer

    with the all-in price per hour and the goodput in finished tokens per hour, including failure and idle effects.

  2. 2.Why can the cheapest dollars-per-token config be the wrong choice?Answer

    It may miss the latency, quality or deadline constraint. Cost compares only among configs that meet quality and schedule gates.

  3. 3.How does spot pricing change the math?Answer

    Spot lowers but adds preemption tax in : checkpoint, lost work and restart. The switch wins only when the price cut exceeds the goodput cut.

You're done when

You can derive dollars per useful token for one scenario from stated price and goodput, and name which overhead dominates it.

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.

  • 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.

  • 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

  • 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.

  • 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.