Start here
Watch the first episode
A small GPT written from scratch in PyTorch, from its parameters to how a prompt flows through it to the next token.
Watch episode 01 · 32 minFollow the code
Each step of an episode is a tag in the code's repository, so you can check out the code as it was at that point in the video.
git checkout ep001/step-1Browse the codeRead about the series
What it covers, who it's for, and where it's heading.
About the series
Latest episodes
All 34 episodes
Our GPT's own GPU kernels in Mojo on a Mac
We write our GPT's writing path as GPU kernels in Mojo, call them from Python, check them against PyTorch, and make them faster in three versions, racing PyTorch and MLX on this Mac.

Sparse autoencoder features inside our GPT
We train a sparse autoencoder on the residual stream of our web model, read what its features fire on, measure what it costs the model, and steer the model's writing with a feature.

Our GPT in Apple's MLX vs PyTorch on a Mac
We port our GPT from PyTorch to MLX, Apple's array library for its own chips, check that it gives the same numbers, and race the two on this Mac at writing and at training.

Mixture of experts from scratch in PyTorch
We replace each block's MLP in our GPT with a mixture of eight experts and a router, write it as a loop and then as one batched multiply, balance it three ways, and train it next to the dense model at the same compute per token.
Explore by topic
- Architecture8Hyena, a GPT without attention, measuredAttention heads in our GPT, seen and testedLong context LLM by stretching RoPE with YaRN
- Pretraining5Muon vs AdamW, Lion and Sophia in a fair racePretraining a GPT on the web overnightDistributed training in PyTorch on 4 GPUs with DDP
- Fine-tuning3LLM tool calling from scratch with a calculatorLoRA fine-tuning a GPT with 2% of its weightsFine-tuning a GPT to follow instructions with SFT
- Reinforcement learning4GRPO in Hugging Face TRL on our own small GPTReinforcement learning without a critic using GRPOReinforcement learning for a GPT with PPO
- Inference7Speculative decoding from scratchStructured LLM output with constrained decodingLong context LLM by stretching RoPE with YaRN
- Performance5Speculative decoding from scratchFlash attention from scratch in PyTorch and TritonDistributed training in PyTorch on 4 GPUs with DDP
- Agents5Structured LLM output with constrained decodingAI agent with a graph database and a calculatorOur GPT writes Cypher to ask a graph database

