Back to Study Plans
62 Problems

Language Modeling from Scratch

62 PyTorch, NumPy, CUDA, and Triton problems covering the modern language-model stack.

15 Easy30 Medium17 Hard
17 sections

What you will learn

This plan follows the modern language-model stack end to end, in 62 PyTorch, NumPy, CUDA and Triton problems across 17 sections. You go from training a tokenizer through model architecture, GPU kernels, parallel training and scaling laws, to inference, evaluation, data processing and post-training.

Prerequisites

You should be comfortable with Python, PyTorch and the basics of how a Transformer works. The PyTorch study plan and the attention mechanism are good preparation. Some sections involve GPU kernels; the Triton study plan helps there.

The sections, in order

  1. Tokenization: train a byte-pair encoding vocabulary and apply its merges.
  2. PyTorch, architectures and attention alternatives: einops-style attention scores, memory and FLOP accounting, RMSNorm, SwiGLU, rotary embeddings, grouped-query attention, linear attention, state-space scans and mixture-of-experts routing.
  3. GPUs, TPUs and kernels: occupancy, bank conflicts, memory coalescing, online softmax and Triton kernels.
  4. Parallelism: collectives, data and tensor parallelism, ZeRO memory, pipeline bubbles and choosing a parallel plan.
  5. Scaling laws: power-law fits, data mixtures, critical batch size, compute-optimal frontiers, learning-rate schedules, Muon and muP.
  6. Inference and evaluation: KV-cache decoding and capacity planning, speculative sampling, perplexity, multiple-choice scoring, Elo ratings and judge bias.
  7. Data and post-training: deduplication, MinHash, data mixtures, SFT loss masks, preference data, KL-regularized policies, DPO and GRPO.
  8. Multimodality and systems: image patches, CLIP and SigLIP losses, multimodal RoPE, and serving problems from a guest lecture on batching, prefix caching and kernel utilization.

Where to go next

For the serving side in more depth, continue with the Inference Engineering study plan. To read about the ideas behind the problems, see GPT pretraining, the KV cache and GRPO.