Skip to content
Stanford CME295 Transformers & LLMs | Autumn 2025 | Lecture 4 - LLM Training
This video isn’t embeddableWatch on YouTube →
Stanford OnlineStanford Online

Stanford CME295 Transformers & LLMs | Autumn 2025 | Lecture 4 - LLM Training

October 17, 2025

Oct 21, 20251h 47mWatch on YouTube

Summaries, chapters, transcripts, and FAQs on this page are made by uListen, not YouTube.

At a glance

WHAT IT’S REALLY ABOUT

How LLMs are pretrained, optimized, and fine-tuned at scale

  1. The lecture outlines the LLM training pipeline as pretraining on vast next-token data followed by smaller fine-tuning stages that shape the model into a helpful assistant or task-specific system.
  2. Pretraining is described as the most expensive stage, involving internet-scale corpora and compute measured using FLOPs (total operations) and FLOPS (operations per second).
  3. Scaling laws and the compute-optimal “Chinchilla law” are used to explain how, under a fixed compute budget, model size and token count should be balanced to avoid under-training.
  4. Training systems challenges are motivated by GPU memory limits, leading to data parallelism, ZeRO sharding, and model-parallel approaches to distribute parameters, gradients, optimizer states, and computation.
  5. FlashAttention, mixed precision, quantization, and post-training methods (SFT/instruction tuning, LoRA, QLoRA) are presented as practical optimizations for speed, memory, and efficient adaptation.

IDEAS WORTH REMEMBERING

5 ideas

LLM training is presented as transfer learning: pretrain broadly, then tune for specific behavior or tasks.

The lecture frames modern LLM development as a two-stage process: a costly pretraining phase on massive corpora followed by a smaller, task- or behavior-focused tuning phase. This is contrasted with older workflows that trained separate models from scratch for each task.

Pretraining is the dominant cost driver because it uses huge token counts and large models.

Pretraining is described as next-token prediction over extremely large, heterogeneous datasets (web pages, encyclopedic text, social media, and code). The speakers emphasize that dataset size is commonly discussed in tokens and can reach hundreds of billions to trillions of tokens.

Compute discussions hinge on separating compute required (FLOPs) from compute speed (FLOPS).

The lecture distinguishes total floating-point operations (FLOPs) from floating-point operations per second (FLOPS), using them to separate “how much compute” from “how fast hardware runs.” FLOPs are described as depending mainly on token count and parameter count, with architecture also influencing the total.

Given fixed compute, there is a compute-optimal tradeoff between model size and dataset size (Chinchilla-style guidance).

A 2020 scaling-laws result is described as showing performance improves with more compute, larger datasets, and larger models, and that larger models can be more sample-efficient. A compute-optimal “sweet spot” is described via the Chinchilla law: roughly 20× more training tokens than parameters, with GPT-3 cited as under-trained relative to that rule-of-thumb.

Memory constraints drive distributed training; ZeRO trades communication for large memory savings by sharding duplicated states.

To fit training into limited GPU memory, the lecture explains that training must store activations, gradients, parameters, and optimizer states, motivating parallelism. Data parallelism splits the batch across GPUs; ZeRO reduces redundancy by sharding optimizer states, gradients, and optionally parameters at the cost of added communication.

WORDS WORTH SAVING

5 quotes

So the goal of transfer learning is to not always start from scratch if you have a new task. It's to start with some pre-trained model, and we're going to see what pre-trained is, and then tune it for your task instead of starting from scratch.

— Unattributed

Pre-training is by far the most expensive, both in terms of compute cost, you know, everything, part of the training.

— Unattributed

Memory is not unlimited. Memory is limited.

— Unattributed

So what we want is to somehow leverage the strength of these kinds of memories in order to speed up the attention computation in a, in an exact way.

— Unattributed

So it has been trained on next token prediction, not being an assistant or someone that is helpful to you.

— Shervin

Read the available transcript
Transfer learning paradigmPretraining data sources and token scaleFLOPs vs FLOPS compute measuresScaling laws and Chinchilla lawGPU memory bottlenecks (activations, gradients, optimizer states)Data parallelism, ZeRO, and model parallelism variantsFlashAttention tiling and recomputation idea (HBM vs SRAM)

High quality AI-generated summary created from speaker-labeled transcript.

Get more out of YouTube videos.

Read along on your phone, search it beside the video, or ask your favorite AI app what was said.