Phase 6 of 7 · 9 topics
Systems and scale
Make models fast and cheap. Understand what limits speed and memory on a GPU, and how training works across many GPUs.
Same car, less fuel, more speed. Most of this phase is about moving data efficiently, not about doing more maths.
Core resources for this phase
-
Blog
Making Deep Learning Go Brrrr From First Principles (Horace He) Free
Compute, memory bandwidth and overhead: the three limits on speed.
-
Video
Karpathy: Let’s reproduce GPT-2 (the speed-up parts) Free
Mixed precision, torch.compile and multi-GPU, applied to a real model.
-
Book
The Ultra-Scale Playbook (Hugging Face) Free
Training on many GPUs, explained with diagrams.
Topics, in order
-
6.1 How a GPU works: compute vs memory
-
Watch
GPU MODE
-
Read
Making Deep Learning Go Brrrr From First Principles
Horace He
Worth it: The clearest explanation of compute-bound, memory-bound and overhead-bound code, with memorable pictures. After it you will know where your training time goes.
-
Read
Modal
-
Watch
-
6.2 Mixed precision: fp16 and bf16
-
Watch
Let's reproduce GPT-2 (124M): the mixed-precision section
Andrej Karpathy
-
Read
Automatic Mixed Precision recipe
PyTorch tutorials
-
Paper
Mixed Precision Training (2017)
Micikevicius et al. · arXiv · optional
-
Watch
-
6.3 Training memory: weights, gradients, optimiser states, activations
-
Read
EleutherAI blog
Worth it: All the back-of-the-envelope formulas for compute and memory in one short page: weights, optimiser states, activations, and how to estimate them for any model.
-
Read
The Ultra-Scale Playbook (memory usage section)
Hugging Face
-
Paper
ZeRO: Memory Optimizations Toward Training Trillion Parameter Models (2019)
Rajbhandari et al. · arXiv · optional
-
Read
-
6.4 Parallelism: data, tensor and pipeline (the ideas)
-
Read
Hugging Face · interactive diagrams
Worth it: A long but beautifully illustrated guide to every kind of parallelism, with interactive memory and speed calculators, from people who train large models.
-
Read
Getting Started with Distributed Data Parallel
PyTorch tutorials
-
Paper
Shoeybi et al. · arXiv · optional
-
Read
-
6.5 Inference speed: batching, quantisation, FlashAttention
-
Read
A Visual Guide to Quantization
Maarten Grootendorst · many diagrams
Worth it: Dozens of clear diagrams of number formats, scales, outliers and the main quantisation methods. Makes a fiddly topic visual and intuitive.
-
Paper
Dao et al. · arXiv · optional
-
Paper
Kwon et al. · arXiv · optional
-
Read
-
6.6 Profiling PyTorch code
-
Read
PyTorch tutorials
-
Read
PyTorch tutorials
-
Read
-
6.7 GPU kernels with Triton
-
Watch
GPU MODE
-
Code
Sasha Rush · GitHub · interactive notebook
Worth it: Small, visual puzzles that teach how GPU kernels index data, one idea at a time, in a notebook. The friendliest way into thinking like a GPU.
- Code
-
Watch
-
6.8 Pruning and distillation
-
Read
PyTorch tutorials
-
Paper
Distilling the Knowledge in a Neural Network (2015)
Hinton, Vinyals, Dean · arXiv · optional
-
Paper
The Lottery Ticket Hypothesis (2018)
Frankle and Carbin · arXiv · optional
-
Read
-
6.9 Speculative decoding
-
Read
Assisted Generation: a new direction toward low-latency text generation
Hugging Face blog · with animations
Worth it: Animated diagrams of a draft model proposing and a big model checking, plus measured speed-ups. Makes the idea click quickly.
-
Paper
Fast Inference from Transformers via Speculative Decoding (2022)
Leviathan, Kalman, Matias · arXiv · optional
-
Read
Go deeper (optional)
-
Tutorial
Measure before you optimise.