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 35 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.

Measuring and fixing our C++ BPE tokenizer
We measure episode eleven's C++ tokenizer on web pages, its memory, its time, its threads and its long chunks, and fix what we find with an LRU cache, a GIL-free encoder, a cache per call and a heap.

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.
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
- Performance6Measuring and fixing our C++ BPE tokenizerSpeculative decoding from scratchFlash attention from scratch in PyTorch and Triton
- Agents5Structured LLM output with constrained decodingAI agent with a graph database and a calculatorOur GPT writes Cypher to ask a graph database