Umar Jamil: paper-to-code video lectures
TL;DR. Umar Jamil’s channel has long lectures that take one paper or system at a time. Each one explains the math on a whiteboard, then codes it in PyTorch (or Triton). The code and slides are on GitHub. The videos run from under an hour to about twenty hours, and all have chapter markers.
Key idea
Section titled “Key idea”Use these videos as companions to papers. Read the paper page here first. Then watch the chapter that derives the hard step. Lengths below are estimates from the last chapter marker.
| Video (upload date) | What it covers | Read on this site |
|---|---|---|
| Attention is all you need (May 2023, ~1 h) | Embeddings, sinusoidal positions, single- and multi-head attention, layer norm, masked decoder, training vs inference | Attention, Illustrated Transformer |
| LoRA explained + code (Jul 2023, ~0.5 h) | Fine-tuning, low-rank updates, PyTorch implementation | LoRA, QLoRA |
| Coding LLaMA 2 from scratch (Sep 2023, ~2.7 h) | RoPE with step-by-step proofs, RMSNorm, KV cache, GQA, SwiGLU, greedy, beam, top-k and top-p decoding | RoPE, GQA |
| Quantization explained (Dec 2023, ~0.8 h) | Integer and float formats, symmetric vs asymmetric, calibration, post-training vs quantisation-aware training | QLoRA, FP8 training |
| Distributed Data Parallel (Dec 2023, ~1.2 h) | Gradient accumulation, all-reduce, torchrun, no_sync, bucketing and compute-communication overlap | Stanford CS336 (Lectures 7–8) |
| Mistral / Mixtral explained (Dec 2023, ~1.4 h) | Sliding-window attention, rolling buffer cache, chunked pre-fill, sparse MoE, pipeline parallelism | Mixtral |
| Mamba and S4 explained (Jan 2024, ~1.2 h) | State-space models, discretisation, recurrent vs convolutional view, HiPPO, selective and parallel scan, kernel fusion | Mamba, Gated DeltaNet |
| Coding a multimodal (vision) LM (Aug 2024, ~5.8 h) | CLIP and SigLIP, ViT, PaliGemma, KV cache, RMSNorm, GQA, weight tying | ColPali, Gemma 3 |
| Flash Attention with Triton (Nov 2024, ~7.6 h) | Safe and online softmax, block matmul, CUDA and Triton basics, forward and backward passes, autotuning | FlashAttention, FlashAttention-2 |
| Distributed training framework from first principles (Aug 2026, ~20 h) | Training FLOPs, RoPE and YaRN, KV cache and arithmetic intensity, MLA with decoupled RoPE and weight absorption, DDP, FSDP, pipeline, tensor, context and expert parallelism | MLA, YaRN, DeepSeek-V3 |
Key results
Section titled “Key results”These are lectures, so there are no benchmark results. The useful output is code. The LLaMA 2 video loads Meta’s released weights into the from-scratch model and runs several decoding strategies on them. The FlashAttention video ends with a Triton kernel for both the forward and backward pass, plus autotuning and software pipelining. The Mistral video takes its facts from the Mistral 7B paper. That paper reports a theoretical span of about 131K tokens with a 4,096-token window over 32 layers. It also reports an 8x cache saving at 32K tokens.
Connections
Section titled “Connections”- Stanford CS336 assigns the same builds as homework: Triton FlashAttention-2 in Assignment 2 and DDP-style training. These videos are a good way to get unstuck.
- Karpathy: Let’s build GPT is the shorter starting point before the LLaMA 2 video.
- Raschka’s architecture comparison gives the wide view across models. These videos go deep on one model at a time.
Questions to think through
These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.
- Derive / compute
The FlashAttention video derives online softmax before writing any kernel. Derive the update for the running maximum and the running normaliser when a new score arrives, and show that the final result equals the ordinary softmax.
What a strong answer covers
- Safe softmax subtracts the maximum m before exponentiating, so no term overflows; this needs m before the sum, which naively costs an extra pass.
- Online version: on a new score x, set m' = max(m, x) and l' = l · exp(m − m') + exp(x − m').
- By induction l equals the sum of exp(x_i − m) over all scores seen so far, so after the last score each weight exp(x_i − m) / l is the exact softmax.
- The same rescaling factor exp(m − m') is applied to the running output block, which is what lets FlashAttention process keys in tiles without storing the full score matrix.
- Mechanism
The Mistral video covers sliding-window attention and the rolling buffer KV cache. Explain how information reaches tokens beyond the window, how the buffer is indexed, and what memory it saves.
What a strong answer covers
- Each layer lets a token attend to at most W previous positions, but stacking k layers lets information move forward by up to k × W tokens.
- Mistral 7B uses W = 4096 and 32 layers, for a theoretical span of about 131K tokens.
- Keys and values for position i go into slot i mod W, so old entries are overwritten and the cache stops growing at W.
- The Mistral paper reports an 8x cache-memory saving at 32K tokens without hurting quality; the prompt can be pre-filled in chunks of size W.
- Connect
Pick the three Umar Jamil videos that best prepare you to read the RoPE, MLA and FlashAttention-2 pages on this site, and say what each video adds that the paper alone does not.
What a strong answer covers
- LLaMA 2 from scratch: a step-by-step proof of the rotary embedding and its use with the KV cache and GQA, ahead of the RoPE page.
- The distributed-training build: chapters derive MLA, decoupled RoPE and weight absorption, plus YaRN, ahead of the MLA and YaRN pages.
- Flash Attention in Triton: online softmax, the forward and backward passes by hand, then working Triton code, ahead of FlashAttention-2.
- The added value is the worked derivation and runnable code; the cost is length, so the chapters should be used to jump to sections.