Inside a Modern LLM: From Tokens to KV Cache
LLM
Transformer
Systems
From Scratch
A bottom-up guide to decoder-only language models, with derivations, PyTorch implementations, ablations, and systems measurements.
Thesis. A language model stops being mysterious once every boundary—tokens, tensors, weights, logits, loss, cache, and samples—can be traced and measured.
Note
This is a living essay under active development. Each chapter is backed by a reproducible notebook and will be expanded during the 18-day sprint.
1 What the reader will build
- A tokenizer and input/output embedding path
- Multi-head causal self-attention from tensor operations
- A modern decoder block with RMSNorm, RoPE, GQA, and SwiGLU
- A trainable Tiny GPT
- Cached autoregressive decoding and a latency/memory benchmark
- A model-anatomy script for inspecting real open-source checkpoints