Why LLMs Need GPUs: Scaling Laws & Parallel Training Explained | LLM Course #25
How big should an LLM be, and how much data does it need? In Lecture 25 of the LLM Masterclass we count training compute with the rule C ≈ 6 × N × D, meet the scaling laws of Kaplan et al. (2020) and the Chinchilla result of Hoffmann et al. (2022), work out GPU memory at about 16 bytes per parameter, and see how data, tensor and pipeline parallelism split training across many GPUs. Then we compare ChotuGPT with a hypothetical 7-billion-parameter model, using real arithmetic from the lecture's script. 💻 Code for this lecture (branch lecture-25): https://github.com/programmingline/chotugpt/tree/lecture-25 Lecture 25 of 32 — LLM Masterclass · Module 5: Training an LLM ⚠️ ChotuGPT is a simplified teaching model. The 7B model, the 16-bytes-per-parameter memory rule, the 80 GB GPU and the 100 TFLOP/s per GPU are stated assumptions for teaching, not measurements of any specific model or product. In this lecture: • Training compute ≈ 6 × parameters × tokens (2 FLOPs forward + 4 backward, per parameter per token) • ChotuGPT: 891,648 parameters × 3,072,000 tokens → 1.64e13 FLOPs; our CPU did about 77 billion FLOPs per second • Kaplan et al. (2020): loss falls as a smooth power law in parameters, data and compute, so small runs predict big ones • Chinchilla (Hoffmann et al., 2022): 400+ models; grow model size and tokens in equal proportion (≈ 20 tokens per parameter) • Chinchilla 70B on 1.4T tokens vs Gopher 280B on 300B tokens, same compute; GPT-3 175B saw 300B tokens; Llama 2 7B saw 2T • GPU memory: ≈ 16 bytes per parameter for training with Adam (2 + 2 + 4 + 4 + 4), ≈ 2 bytes per parameter to run • Data parallelism, tensor parallelism and pipeline parallelism, and why big runs combine all three • A hypothetical 7B model: 140B tokens, 5.88e21 FLOPs, 112 GB of training state, ≈ 681 GPU-days at an assumed 100 TFLOP/s Chapters: 00:00 Lecture 24 quiz answer 00:15 Scaling laws, GPUs and parallelism 00:31 Counting the compute 01:07 Making everything bigger 01:15 Scaling laws (Kaplan et al., 2020) 01:51 Chinchilla (Hoffmann et al., 2022) 02:50 GPU memory 03:22 Data, tensor and pipeline parallelism 04:07 The arithmetic in Python 04:41 Quiz 05:03 A 7B model, by the numbers 05:45 Recap & next lecture ✅ Lecture 24 quiz answer: C, overfitting: the model memorises its training text instead of learning patterns that work on new text. ❓ Quiz: Chinchilla found that for a fixed compute budget you should… A) Only make the model bigger B) Grow model size and training tokens together C) Use fewer tokens. Comment your answer. I reveal it in Lecture 26! 👍 Like, subscribe and comment your quiz answer. ⏮ Previous: Lecture 24 — The training loop ⏭ Next: Lecture 26 — From base model to assistant: SFT Sources: J. Kaplan et al., "Scaling Laws for Neural Language Models", OpenAI, arXiv:2001.08361 (2020). J. Hoffmann et al., "Training Compute-Optimal Large Language Models" (Chinchilla), DeepMind, arXiv:2203.15556 (2022) — 400+ models from 70M to 16B+ parameters; Chinchilla 70B on 1.4T tokens; Gopher 280B and GPT-3 175B on 300B tokens (Table 1); Kaplan's 10× compute → 5.5× model, 1.8× data. H. Touvron et al., "Llama 2: Open Foundation and Fine-Tuned Chat Models", arXiv:2307.09288 (2023) — 2 trillion training tokens. S. Rajbhandari et al., "ZeRO: Memory Optimizations Toward Training Trillion Parameter Models", arXiv:1910.02054 (16 bytes per parameter with mixed-precision Adam). M. Shoeybi et al., "Megatron-LM", arXiv:1909.08053 (tensor parallelism). Y. Huang et al., "GPipe", arXiv:1811.06965 (pipeline parallelism). #LLM #ScalingLaws #GPU…more
How big should an LLM be, and how much data does it need? In Lecture 25 of the LLM Masterclass we count training compute with the rule C ≈ 6 × N × D, meet the scaling laws of Kaplan et al. (2020) and the Chinchilla result of Hoffmann et al. (2022), work out GPU memory at about 16 bytes per parameter, and see how data, tensor and pipeline parallelism split training across many GPUs. Then we compare ChotuGPT with a hypothetical 7-billion-parameter model, using real arithmetic from the lecture's script. 💻 Code for this lecture (branch lecture-25): https://github.com/programmingline/chotugpt/tree/lecture-25 Lecture 25 of 32 — LLM Masterclass · Module 5: Training an LLM ⚠️ ChotuGPT is a simplified teaching model. The 7B model, the 16-bytes-per-parameter memory rule, the 80 GB GPU and the 100 TFLOP/s per GPU are stated assumptions for teaching, not measurements of any specific model or product. In this lecture: • Training compute ≈ 6 × parameters × tokens (2 FLOPs forward + 4 backward, per parameter per token) • ChotuGPT: 891,648 parameters × 3,072,000 tokens → 1.64e13 FLOPs; our CPU did about 77 billion FLOPs per second • Kaplan et al. (2020): loss falls as a smooth power law in parameters, data and compute, so small runs predict big ones • Chinchilla (Hoffmann et al., 2022): 400+ models; grow model size and tokens in equal proportion (≈ 20 tokens per parameter) • Chinchilla 70B on 1.4T tokens vs Gopher 280B on 300B tokens, same compute; GPT-3 175B saw 300B tokens; Llama 2 7B saw 2T • GPU memory: ≈ 16 bytes per parameter for training with Adam (2 + 2 + 4 + 4 + 4), ≈ 2 bytes per parameter to run • Data parallelism, tensor parallelism and pipeline parallelism, and why big runs combine all three • A hypothetical 7B model: 140B tokens, 5.88e21 FLOPs, 112 GB of training state, ≈ 681 GPU-days at an assumed 100 TFLOP/s Chapters: 00:00 Lecture 24 quiz answer 00:15 Scaling laws, GPUs and parallelism 00:31 Counting the compute 01:07 Making everything bigger 01:15 Scaling laws (Kaplan et al., 2020) 01:51 Chinchilla (Hoffmann et al., 2022) 02:50 GPU memory 03:22 Data, tensor and pipeline parallelism 04:07 The arithmetic in Python 04:41 Quiz 05:03 A 7B model, by the numbers 05:45 Recap & next lecture ✅ Lecture 24 quiz answer: C, overfitting: the model memorises its training text instead of learning patterns that work on new text. ❓ Quiz: Chinchilla found that for a fixed compute budget you should… A) Only make the model bigger B) Grow model size and training tokens together C) Use fewer tokens. Comment your answer. I reveal it in Lecture 26! 👍 Like, subscribe and comment your quiz answer. ⏮ Previous: Lecture 24 — The training loop ⏭ Next: Lecture 26 — From base model to assistant: SFT Sources: J. Kaplan et al., "Scaling Laws for Neural Language Models", OpenAI, arXiv:2001.08361 (2020). J. Hoffmann et al., "Training Compute-Optimal Large Language Models" (Chinchilla), DeepMind, arXiv:2203.15556 (2022) — 400+ models from 70M to 16B+ parameters; Chinchilla 70B on 1.4T tokens; Gopher 280B and GPT-3 175B on 300B tokens (Table 1); Kaplan's 10× compute → 5.5× model, 1.8× data. H. Touvron et al., "Llama 2: Open Foundation and Fine-Tuned Chat Models", arXiv:2307.09288 (2023) — 2 trillion training tokens. S. Rajbhandari et al., "ZeRO: Memory Optimizations Toward Training Trillion Parameter Models", arXiv:1910.02054 (16 bytes per parameter with mixed-precision Adam). M. Shoeybi et al., "Megatron-LM", arXiv:1909.08053 (tensor parallelism). Y. Huang et al., "GPipe", arXiv:1811.06965 (pipeline parallelism). #LLM #ScalingLaws #GPU