The 22 Laws of ML Systems in Plain English
What each equation says, why it matters, and how to explain it in 30 seconds
Every equation in mlsysim answers one question. Here is what each one says, why it matters, and how to explain it to anyone in 30 seconds.
Looking for the full textbook treatment? See the Textbook & Chapter Map for chapter, lab, and slide links across every domain.
Domain 1: Node—What One Chip Can Do
Textbook chapters: Vol I, Ch 5: Neural Computation · Vol I, Ch 11: Hardware Acceleration · Vol I, Ch 13: Model Serving · Vol II, Ch 10: Serving at Scale· Vol III, Ch 5: KV Cache Management
Wall 1: The Compute Wall
Equation: Time = Operations / (Peak_FLOPS × Efficiency)
Plain English: The compute wall sets how long the math takes. Divide the total number of multiply-adds a model needs by how fast the chip can do math (adjusted for real-world inefficiency), and the result is the compute time.
30-second version: “If a 8B-parameter model needs 16 billion operations and the GPU can do 989 trillion per second at 50% efficiency, the math takes 0.03 milliseconds.”
Why it matters: This is the speed limit for any workload. No software optimization can make a model run faster than the hardware can crunch numbers.
Wall 2: The Memory Wall
Equation: Time = Weight_Bytes / Memory_Bandwidth
Plain English: The memory wall sets how long it takes to load the model from memory. A model’s weights sit in HBM (the GPU’s memory). To use them, the GPU must read them through a pipe with a fixed width (bandwidth). Bigger model = longer loading time.
30-second version: “A 16 GB model on a GPU with 3.35 TB/s bandwidth takes 4.8 ms to load the weights, before any computation starts.”
Why it matters: For most LLM inference at batch size 1, this is the bottleneck. The GPU finishes the math long before it finishes reading the weights (the ridge point is 153 FLOP/byte on an A100 at 312 TFLOP/s and 2.04 TB/s, and 295 FLOP/byte on an H100 at 989 TFLOP/s and 3.35 TB/s). This is why memory bandwidth matters more than FLOPS for serving chatbots.
Wall 3: The Software Wall
Equation: MFU = Achieved_FLOPS / Peak_FLOPS; η = min(η_compute, I_kernel / I*)
Plain English: MFU (Model FLOPs Utilization) measures how much of the chip’s power a workload actually uses: the gap between what the hardware could do and what the software actually achieves. EfficiencyModel bounds \(\eta\) from first principles by comparing kernel arithmetic intensity \(I_{\text{kernel}}\) (e.g., SRAM-tiled FlashAttention vs. HBM-bound unfused attention) against the hardware ridge point \(I^*\). Low MFU means wasted silicon.
30-second version: “If a GPU can do 989 TFLOP/s but training only achieves 450 TFLOP/s, the MFU is 45%. The other 55% is lost to kernel launches, memory stalls, and framework overhead.”
Why it matters: A 50% MFU means paying for twice the hardware actually in use. Improving MFU is often cheaper than buying more GPUs.
Wall 4: The Serving Wall
Equation: TTFT = max(OPs_prefill / (Peak × η), (Weights + KV_Bytes) / Bandwidth) + Layer_Tax; ITL = max(OPs_decode / (Peak × η), (Weights + KV_Bytes) / Bandwidth) + Layer_Tax
Plain English: LLM serving has two phases with completely different bottlenecks. Prefill (processing the prompt, including quadratic self-attention) is compute-bound, because it does a large amount of math. Decode (generating each token while streaming weights and KV cache) is memory-bound, because it loads the weights again for every single token. These two phases need different optimizations.
30-second version: “Prefill is like reading a book fast (compute-intensive). Decode is like looking up one word at a time in a dictionary (memory-intensive). That is why the first token takes tens of milliseconds while each subsequent token takes a few milliseconds.”
Wall 5: The Batching Wall
Equation: KV_cache = 2 × Layers × KV_Heads × Head_Dim × SeqLen × Batch × BytesPerElem
Plain English: Each active request in an LLM server needs its own “memory” of the conversation (the KV cache). This memory grows with sequence length and eats into the GPU’s finite HBM. More concurrent requests = more KV cache = less room for new requests.
30-second version: “Each Llama-3-8B request at 4K context needs 537 MB (512 MiB) of KV cache. An 80 GiB GPU can only serve 130 concurrent requests before running out of memory.”
Wall 6: The Streaming Wall
Equation: Time_per_layer = max(Weight_Injection_Time, Compute_Time)
Plain English: Wafer-scale chips (like Cerebras) flip the normal GPU bottleneck. Instead of weights sitting in memory and being read by compute, weights are streamed from external memory nodes while activations live on-chip in SRAM. The bottleneck shifts from memory bandwidth to the injection interconnect speed.
Wall 7: The Tail Latency Wall
Equation: Erlang C queueing model (M/M/c)
Plain English: When servers are busy, new requests have to wait in line. The waiting time grows non-linearly. At 80% load, the P99 latency might be 2x the average; at 95% load, it can be 10x. This is why servers cannot run at 100%: the tail latency destroys the SLA.
30-second version: “It is like a highway. At 70% capacity, traffic flows. At 95% capacity, everyone is stuck. Servers work the same way.”
Domain 2: Data—Whether Storage Can Feed the Pipeline
Textbook chapters: Vol I, Ch 4: Data Engineering · Vol II, Ch 3: Network Fabrics · Vol II, Ch 4: Data Storage· Vol IV, Ch 5: Physical Data
Wall 8: The Ingestion Wall
Equation: Utilization = Data_Demand / Storage_Supply
Plain English: Storage has to deliver data as fast as the GPU consumes it. If the GPU consumes data faster than the disk can supply it, the GPU sits idle waiting for input. This ratio shows whether the data pipeline is the bottleneck.
Wall 9: The Transformation Wall
Equation: Time = Batch × Sequence / CPU_Throughput
Plain English: Before data reaches the GPU, CPUs must decode images, tokenize text, and apply augmentations. If these CPU operations cannot keep up with GPU consumption, the GPU starves. This is why training pipelines often need 10-100x more CPU cores than one might expect.
Wall 10: The Locality Wall
Equation: Effective_BW = Link_BW × Bisection_Fraction / Oversubscription
Plain English: Not all network bandwidth is created equal. A fat-tree network gives full bisection bandwidth (any node can talk to any other at full speed). A ring or torus does not, because distant nodes communicate through intermediate hops, which reduces effective bandwidth. The topology determines how much of the raw link speed collective communication actually gets.
Domain 3: Algorithm—How Much Compute a Model Needs
Textbook chapters: Vol I, Ch 8: Model Training · Vol I, Ch 10: Model Compression · Vol II, Ch 11: Edge Intelligence· Vol III, Ch 3: Test-Time Compute
Wall 11: The Complexity Wall (Chinchilla Scaling)
Equation: Compute = 6 × Parameters × Tokens; Optimal_Params = √(Budget/120)
Plain English: For a fixed compute budget, model size and training data must be balanced. The Chinchilla scaling law says that, for a fixed compute budget, the optimal model size is proportional to the square root of the budget, and training should use 20 tokens per parameter. Train a too-big model on too-little data = waste. Train a too-small model on too-much data = also waste.
30-second version: “With a \(10^{24}\)-FLOP compute budget, the right choice is a ~91B parameter model trained on ~1.8T tokens. Going bigger without more data wastes compute.”
Wall 12: The Reasoning Wall [Emerging]
Equation: Time = Steps × Time_per_Step
Plain English: Chain-of-thought reasoning makes models think longer before answering. Each reasoning step costs compute. More steps = better answers but higher cost. This is inference-time scaling: spending more compute at serving time instead of training time.
Wall 13: The Fidelity Wall (Compression)
Equation: b_eff = b_target + b_scale / g; Compression = baseline_bits / b_eff (quantization); 1 / (1 - sparsity) (pruning)
Plain English: A model shrinks when it uses fewer bits than a baseline precision (quantization) or when weights are removed (pruning: 50% sparse = 2× smaller). With group quantization (such as GPTQ or AWQ at group size \(g = 128\) and FP16 scales), effective bitwidth is \(b_{\text{eff}} = 4 + 16/128 = 4.125\) bits/weight, yielding 3.88× compression against an "fp16" baseline (4.14 GB for Llama-3 8B). Because accuracy loss depends on model architecture, calibration data, and task metric, CompressionModel accepts accuracy_delta as an explicit empirical input rather than assuming a universal curve.
Key insight: Storage shrinks for all compression, but inference speedup depends on the regime and hardware support. Unstructured pruning saves storage without accelerating dense GPU GEMMs; only structured pruning, hardware N:M sparsity, or memory-bound byte reduction accelerate execution.
Domain 4: Fleet—What Happens at Scale
Textbook chapters: Vol II, Ch 5: Collective Communication · Vol II, Ch 6: Distributed Training · Vol II, Ch 7: Fault Tolerance · Vol II, Ch 8: Fleet Orchestration
Wall 14: The Communication Wall (AllReduce)
Equation: Time = 2(N-1)/N × Message/Bandwidth + 2(N-1) × Latency
Plain English: Distributed training means every GPU must share its gradients with every other GPU after each training step. This “AllReduce” operation moves data through the network. The time depends on how much data (gradient size) and how fast the network (bandwidth). As more GPUs are added, the communication cost grows, eventually dominating over the compute savings.
30-second version: “1 GB of gradients across 8 nodes at 50 GB/s InfiniBand NDR takes 35 ms. That is time the GPUs spend waiting instead of computing.”
Wall 15: The Fragility Wall (Reliability)
Equation: Cluster_MTBF = Component_MTBF / N_components
Plain English: If one GPU fails every 50,000 hours, a 1000-GPU cluster has a failure every 50 hours. At 10,000 GPUs, a failure arrives every 5 hours. This is why large training runs need checkpointing; without it, a single GPU failure wastes days of compute.
30-second version: “At 1000 GPUs, something breaks roughly every 2 days (50 hours). At 100,000 GPUs, something breaks every 30 minutes.”
Wall 16: The Multi-tenant Wall (Queueing)
Equation: Wait_Time = Utilization / [2 × Service_Rate × (1 - Utilization)]
Plain English: When multiple teams share a cluster, jobs wait in line. The wait time grows non-linearly with cluster load. At 80% cluster load, the average wait is 2x the job duration. This is why shared research clusters feel slow even when they are “only” 80% busy.
Domain 5: Operations—What It Costs
Textbook chapters: Vol I, Ch 15: Responsible Engineering · Vol II, Ch 2: Compute Infrastructure · Vol II, Ch 7: Fault Tolerance · Vol II, Ch 15: Sustainable AI· Vol III, Ch 19: Agent Economics
Wall 17: The Capital Wall (TCO)
Equation: TCO = CapEx + OpEx_energy + OpEx_maintenance
Plain English: The total cost of running ML infrastructure is hardware purchase (CapEx, amortized over 3-5 years) plus electricity plus maintenance. A 1024-GPU H100 cluster costs ~$31M in hardware. Electricity is a small share (~8% of total). The dominant cost lever is occupancy, because idle GPUs cost the same as busy ones.
Wall 18: The Sustainability Wall
Equation: Carbon_kg = (IT_Energy × PUE × Carbon_Intensity) / 1000; Water_L = IT_Energy × WUE_site
Plain English: Every GPU-hour converts electricity into carbon emissions. How much depends on three things: how much energy (determined by power and time), how efficiently the datacenter uses it (PUE, where a 1.4 PUE adds 40% facility overhead on top of IT compute energy — 28.6% of total electricity), and how dirty the grid is (Quebec hydro = 20 gCO₂/kWh and France nuclear = 50 gCO₂/kWh vs Iowa coal/gas = 680 gCO₂/kWh and Poland coal = 820 gCO₂/kWh).
30-second version: “Training the same model in Quebec produces 41x less carbon than training it in Poland (and 34x less than in Iowa). Geography is the biggest lever for sustainable AI.”
Wall 19: The Checkpoint Wall
Equation: Waste = δ / τ + τ / (2 × MTBF)
Plain English: Long training runs must periodically save their state to disk in case of failure. This I/O burst interrupts training (δ / τ) while failures lose work since the last save (τ / (2 × MTBF)). Balancing those two Young-Daly loss terms yields the optimal checkpoint interval \(\tau_{\text{opt}} = \sqrt{2 \delta \cdot \text{MTBF}}\).
Wall 20: The Safety Wall (Privacy)
Equation: σ = q × √(2T ln(1.25/δ)) / ε; Step_Time = Base_Step × (1 + clipping_overhead)
Plain English: Differential privacy (DP-SGD) enforces two distinct physical costs: per-sample gradient clipping adds a fixed per-step compute/memory overhead (clipping_step_overhead, e.g., 15% → 1.15× step time), while stronger privacy (\(\varepsilon\), \(\delta\)) under subsampling rate \(q\) over \(T\) steps raises the Gaussian noise multiplier \(\sigma\) (0.48 at \(\varepsilon=1.0, \delta=10^{-5}, q=10^{-3}, T=10^4\)), trading utility or requiring larger batch sizes to preserve signal-to-noise ratio.
Domain 6: Meta-Analysis—Cross-Cutting Tools
Textbook chapters: Vol I, Ch 12: Benchmarking · Vol II, Ch 9: Fleet Efficiency· Vol IV, Ch 13: Workload Placement
Wall 21: Sensitivity Analysis
Equation: ∂Time/∂parameter (partial derivatives)
Plain English: Sensitivity analysis finds which constraint is actually binding. It perturbs each parameter (bandwidth, FLOPS, network speed) by a small amount and measures how much the total time changes. The parameter with the largest derivative is the bottleneck, and that is where to invest next.
Wall 22: Synthesis (Inverse Roofline)
Equation: Required_BW = Weights / Target_Latency
Plain English: Synthesis starts from a latency target (e.g., “50 ms per token”) and derives the hardware specs needed to meet it. This flips the Roofline model backwards: instead of predicting performance from hardware, it derives the minimum hardware specs from a performance requirement.
30-second version: “A 50 ms decode latency for a 141.2 GB model (70.6B parameters in FP16) requires at least 2.82 TB/s of memory bandwidth. That is more than one A100 provides (2.04 TB/s). One H100 has the bandwidth (3.35 TB/s) but only 80 GiB of memory, so the 141.2 GB model needs tensor parallelism across two H100s.”
The Iron Law (The Master Equation)
Equation: Time = FLOPs / (N × Peak × MFU × η_scaling × Goodput)
Plain English: This one equation governs all of ML systems. Training time equals the total compute divided by how much useful compute the system can actually deliver. Each term in the denominator represents a different loss:
| Term | What it means | What reduces it |
|---|---|---|
| N | Number of devices | Budget |
| Peak | Raw hardware speed | GPU generation |
| MFU | Software efficiency | Kernel optimization, FlashAttention |
| η_scaling | Communication overhead | Network bandwidth, gradient compression |
| Goodput | Time lost to failures | Checkpointing, fault tolerance |
Every wall in the taxonomy maps to one of these five terms, and together they make up the framework.