Notes

Last updated
On this page
  1. Training Basics
  2. Collective Communication Primitives

A perpetual, ever-growing dump of everything I read, learn, and (mis)understand about AI

Note

this page is a permanent work in progress. notes will get added, rewritten, and corrected as my understanding shifts. anything wrong here is a wip on the way of being less wrong.

Training Basics

  • MFU - Model FLOPS Utilization

    • MFU = useful FLOPs per sec / peak FLOPs per sec
    • More precisely, MFU = (model FLOPs per token × tokens/sec) / (num_GPUs × peak FLOP/s per GPU)
    • For a dense transformer model with N parameters, roughly, MFU = (6 × N × tokens per second per GPU) / peak FLOP/s per GPU
  • MFU vs HFU

    • HFU (Hardware FLOPS Utilization) counts all operations actually performed including recompute
    • MFU counts only the forward+backward ops required by the model, excluding recompute (implementation-agnostic). A GPU with enough memory to skip recompute does fewer ops (lower HFU) but may train faster — MFU rewards that, HFU punishes it. What ultimately matters is wall-clock-to-train, so MFU is the more honest cross-system metric.
  • Arithmetic Intensity (AI)

    • Ratio of arithmetic operations to memory operations in a kernel (FLOPs/byte)
    • AI = FLOPs / bytes
  • Roofline model

    • Plots attainable FLOP/s against arithmetic intensity on log-log axes: below the ridge point (peak FLOP/s ÷ memory bandwidth) a kernel is memory-bound (perf = bandwidth × AI); above it, compute-bound (perf = peak FLOP/s)

The explorer below is deliberately simplified: each preset pairs theoretical dense FP16 Tensor Core throughput with FP32 accumulation and peak memory bandwidth. It is useful for intuition, not hardware benchmarking; real kernels and non-Tensor-Core paths can run below the line.

The word dense matters here. NVIDIA's spec tables sometimes also show a 2x rate "with sparsity": that assumes a supported structured pattern lets Tensor Cores skip zeros. It does not make every sparse-looking model twice as fast, and it does not change memory bandwidth. This explorer uses the non-sparse rate, so turning on a genuinely supported sparse path would raise the flat compute ceiling and move the ridge point to the right.

GPU roofline · dense FP16

Roofline explorer

Move the operating point to see where memory traffic gives way to compute.
GPU preset
Compute ceiling
2250 TFLOP/s
Memory bandwidth
8,000 GB/s
Ridge point
281 FLOPs/byte
Swipe horizontally to inspect the full plot.
Scrollable roofline plot
B200 SXM simplified theoretical dense FP16 Tensor Core rooflineDense FP16 Tensor Core compute ceiling with FP32 accumulation of 2250 TFLOP/s, 8,000 GB/s memory bandwidth, ridge point 281 FLOPs per byte, and current arithmetic intensity 10.0 FLOPs per byte. 80.0 TFLOP/s · memory-bound.0.11101001k10k0.010.11101001k10karithmetic intensity (FLOPs/byte)attainable TFLOP/smemory-boundcompute-bound
10.0 FLOPs/byte
Attainable ceiling
80.0 TFLOP/s · memory-bound
Simplified theoretical roofline using dense FP16 Tensor Core throughput with FP32 accumulation and peak memory bandwidth; real kernels and non-Tensor-Core paths can run below this ceiling.

Preset sources: NVIDIA's HGX B200 specifications and DGX B200 specifications, H100 specifications, A100 specifications, and Ada GPU architecture whitepaper for the RTX 4090. The data-centre tables mark structured-sparsity figures separately; the dense values plotted here leave that multiplier out. The B200 preset converts NVIDIA's eight-GPU system totals to per-GPU values: 2.25 PFLOP/s dense FP16/BF16 and 8 TB/s of HBM3e bandwidth.

Collective Communication Primitives

  • All-reduce - Sum everyone's tensor, give the full sum to everyone.
  • Reduce - Sum everyone's tensor, give the full sum to one root rank.
  • Reduce-scatter - Sum everyone's tensor, but give each rank only its shard of the result.
  • All-gather - Collect everyone's shard, give the full tensor to everyone.
  • Broadcast - One rank holds the tensor; copy it out so everyone ends up with the same full tensor.
  • Scatter - One rank holds the full tensor; split it into shards and send each rank only its shard.
  • All-to-all - Every rank splits its tensor into shards and sends shard j to rank j — a distributed transpose.

These are conceptual state transitions across four ranks, not literal message schedules, network topologies, or performance models. Real implementations choose algorithms such as rings or trees based on the hardware and payload.

The frames show logical collective outputs, not physical buffer lifetime. A source chunk staying on screen during a transfer is a teaching aid: real libraries may use in-place or out-of-place buffers, and bytes can still exist locally even when they are no longer part of that rank's defined collective output.

conceptual four-rank model

Collective communication, step by step

All-reduce. Sum every vector, then give the complete result back to every rank.
step 1 of 6
Each rank holds its own full vector

Logical message routes

idle
All-reduce. No messages move between ranks in this step.ABCD

No messages move between ranks in this step.

Data held by each rank

shards 0–3
All-reduce data state across four ranks. Each rank holds its own full vector.shard0123ABCDA0A1A2A3B0B1B2B3C0C1C2C3D0D1D2D3
ABCDΣⱼArrows show rank-to-rank messages. Xⱼ is rank X's j-th shard; Σⱼ is shard j summed across ranks.
Conceptual state walkthrough only: final frames show defined logical outputs, not whether input or temporary buffers still exist. The diagram does not prescribe an algorithm, network topology, buffer strategy, or timing model.