The LLM StackFrom Silicon to Agents
Navigate the book

Learning map

Guided reading tracks for specific goals, a topic index, and the prerequisite map for every chapter — so you can chart a path instead of reading front to back.

Guided reading tracks

Browse by topic

architecture (36)
1.1 Linear Algebra for Deep Learning 1.6 Neural Networks From Scratch: MLPs & Backprop 1.8 GPU Architecture & The Memory Hierarchy 1.10 The Accelerator Landscape: TPUs, Trainium, AMD/ROCm & Gaudi 2.1 Tokenization: BPE, WordPiece, Unigram & Byte-Level 2.2 Embeddings & The Input Pipeline 2.3 The Attention Mechanism From Scratch 2.4 Multi-Head Attention, MQA, GQA & MLA 2.5 Positional Encodings: Sinusoidal, Learned, RoPE & ALiBi 2.6 The Transformer Block: Norms, Residuals, MLPs & Activations 2.7 Building a GPT From Scratch (nanoGPT-style) 2.8 Architecture Variants: Encoder-Decoder, Decoder-Only & Prefix-LM 2.9 Mixture-of-Experts (MoE) Architectures 2.10 Modern Architecture Improvements & Design Choices 2.11 Beyond Attention: SSMs, Mamba, RWKV & Linear Attention 2.12 Diffusion & Non-Autoregressive Language Models 3.6 Distributed Training II: Tensor, Pipeline, Sequence & Expert Parallelism 3.13 Long-Context Pretraining & Context Extension 3.16 Continual & Domain-Adaptive Pretraining 4.5 CUDA Programming Essentials for ML Engineers 5.4 PEFT II: Prompt/Prefix Tuning, IA3, Model Merging & Soups 9.1 Embeddings & Representation Learning 10.1 Vision Transformers & Image Encoders 10.2 Vision-Language Models 10.3 Audio, Speech & Multimodal Fusion 10.4 Diffusion Models & Generative Modeling (Breadth) 10.5 Unified & Any-to-Any Models 13.1 Mechanistic Interpretability & Model Internals 14.1 The Capstone: Building Stack-100M, and the 2026 Small-Model Landscape 14.3 A Byte-Level BPE Tokenizer From Scratch (and Why Vocab Size Is a Design Lever at 100M) 14.4 The Stack-100M Architecture: SOTA Components, Cited and Assembled 14.8 Mid-Training: Quality Annealing, Long-Context Extension & Capability Injection Glossary of Terms The Math Reference Sheet Key Papers: An Annotated Reading List From-Scratch Code Index
evaluation (34)
1.2 Probability, Statistics & Information Theory 1.5 Machine Learning Fundamentals 3.2 Data Cleaning, Deduplication & Quality Filtering 3.15 Synthetic Data for Pre- and Post-Training 3.17 Training an LLM From Scratch: The End-to-End Recipe 5.5 The RLHF Pipeline & Reward Modeling 5.9 RL with Verifiable Rewards (RLVR) & The Reasoning Recipe 5.10 Reasoning, Chain-of-Thought & Test-Time Compute 5.13 Reward Hacking, Over-Optimization & Alignment Failures 6.8 Reward Engineering, Verifiers & Sandboxes 8.2 The Agentic Loop: ReAct, Plan-Execute & Reflection 8.3 Harness Engineering: Building a Coding Agent 8.8 Agent Evaluation & Benchmarks 8.9 Prompt Engineering as Engineering 9.1 Embeddings & Representation Learning 9.3 Retrieval-Augmented Generation Architectures 9.6 Multimodal & Visual-Document Retrieval: ColPali & Late Interaction 11.1 The Evaluation Problem & Benchmark Landscape 11.2 LLM-as-a-Judge & Automated Evaluation 11.3 Building Eval Harnesses 11.4 Reasoning, Coding & Agentic Evals 11.5 Red-Teaming, Safety & Robustness Evaluation 11.6 Statistical Rigor in Evaluation: Confidence Intervals & Significance 12.2 Observability, Logging & LLMOps 12.4 Safety, Guardrails & Content Moderation 12.5 Data Flywheels & Continuous Improvement 12.7 Online Evaluation: A/B Testing, Canaries & Guardrail Metrics 12.8 Reliability Engineering for LLM Systems: SLOs & Incident Response 13.1 Mechanistic Interpretability & Model Internals 13.3 Privacy, Memorization & Differential Privacy for LLMs 13.4 Watermarking, Provenance & AI-Content Detection 13.5 AI Safety: Scalable Oversight, Dangerous-Capability Evals & Frontier Safety 13.6 AI Governance, Compliance & Regulation 14.11 Evaluation & Serving: Honest Benchmarks, int4 Quantization, and Running on a Laptop
gpu (32)
1.4 Numerical Computing, Floating Point & Precision 1.7 Automatic Differentiation & PyTorch Internals 1.8 GPU Architecture & The Memory Hierarchy 1.9 Parallel Computing & Collective Communication 1.10 The Accelerator Landscape: TPUs, Trainium, AMD/ROCm & Gaudi 3.5 Distributed Training I: Data Parallelism, DDP, ZeRO & FSDP 3.6 Distributed Training II: Tensor, Pipeline, Sequence & Expert Parallelism 3.7 Megatron-LM, DeepSpeed & Parallelism in Practice 3.8 Mixed Precision, bf16 & FP8 Training 4.1 The Roofline Model & Performance Engineering 4.2 FlashAttention I: IO-Awareness & The Online Softmax 4.3 FlashAttention 2 & 3: Work Partitioning, Warp Specialization & FP8 4.4 Writing GPU Kernels with Triton 4.5 CUDA Programming Essentials for ML Engineers 4.6 PagedAttention & KV-Cache Memory Management 4.9 Kernel Fusion, torch.compile, CUDA Graphs & Compilers 4.10 Memory-Efficient Training: Checkpointing, Offloading & LoRA Math 6.3 TRL: HuggingFace's RL Library 6.4 veRL: HybridFlow & The Single-Controller Architecture 6.5 OpenRLHF, NeMo-Aligner & Ray-Based Systems 6.7 Colocated vs Disaggregated RL & Weight Synchronization 7.1 The Anatomy of LLM Inference: Prefill, Decode & The KV Cache 7.3 vLLM: Architecture, PagedAttention & Internals 7.4 SGLang: RadixAttention & Structured Programs 7.5 TensorRT-LLM, TGI & Other Serving Stacks 7.8 Disaggregated Prefill/Decode & Chunked Prefill 7.11 Multi-GPU & Multi-Node Inference 7.12 Inference Economics: Latency, Throughput & Cost 7.13 Serving Mixture-of-Experts: Expert Parallelism & All-to-All Inference 14.7 The Pretraining Run: A Complete Single-GPU Training Loop 14.12 Retrospective: Cost Accounting, Reproducibility, and the Path to 1B Tooling & Environment Setup Cheatsheet
inference (59)
1.10 The Accelerator Landscape: TPUs, Trainium, AMD/ROCm & Gaudi 2.3 The Attention Mechanism From Scratch 2.4 Multi-Head Attention, MQA, GQA & MLA 2.5 Positional Encodings: Sinusoidal, Learned, RoPE & ALiBi 2.7 Building a GPT From Scratch (nanoGPT-style) 2.8 Architecture Variants: Encoder-Decoder, Decoder-Only & Prefix-LM 2.10 Modern Architecture Improvements & Design Choices 2.11 Beyond Attention: SSMs, Mamba, RWKV & Linear Attention 2.12 Diffusion & Non-Autoregressive Language Models 3.13 Long-Context Pretraining & Context Extension 4.1 The Roofline Model & Performance Engineering 4.2 FlashAttention I: IO-Awareness & The Online Softmax 4.4 Writing GPU Kernels with Triton 4.6 PagedAttention & KV-Cache Memory Management 4.7 Quantization I: Post-Training Quantization (GPTQ, AWQ, SmoothQuant) 4.8 Quantization II: INT4/INT8/FP8, GGUF, bitsandbytes & QAT 4.9 Kernel Fusion, torch.compile, CUDA Graphs & Compilers 5.2 Chat Templates, Data Formatting & Sequence Packing 5.10 Reasoning, Chain-of-Thought & Test-Time Compute 5.12 Distillation, Model Compression & Knowledge Transfer 6.1 The Anatomy of an RL-for-LLM System 6.2 The Generation–Training Loop & Rollout Engines 6.7 Colocated vs Disaggregated RL & Weight Synchronization 6.10 Agentic & Multi-Turn RL 6.11 Scaling RL: Throughput, Load Balancing & The Latest Tricks 7.1 The Anatomy of LLM Inference: Prefill, Decode & The KV Cache 7.2 Continuous Batching & Request Scheduling 7.3 vLLM: Architecture, PagedAttention & Internals 7.4 SGLang: RadixAttention & Structured Programs 7.5 TensorRT-LLM, TGI & Other Serving Stacks 7.6 Speculative Decoding: Draft Models, Medusa, EAGLE & Lookahead 7.7 Prefix Caching & KV-Cache Reuse 7.8 Disaggregated Prefill/Decode & Chunked Prefill 7.9 Sampling Strategies & Decoding Algorithms 7.10 Structured & Constrained Generation 7.11 Multi-GPU & Multi-Node Inference 7.12 Inference Economics: Latency, Throughput & Cost 7.13 Serving Mixture-of-Experts: Expert Parallelism & All-to-All Inference 7.14 Multi-Tenant LoRA & Adapter Serving at Scale 8.1 Tool Use & Function Calling 8.2 The Agentic Loop: ReAct, Plan-Execute & Reflection 8.4 Context Engineering & Management 8.9 Prompt Engineering as Engineering 9.2 Vector Databases & Approximate Nearest Neighbor Search 9.6 Multimodal & Visual-Document Retrieval: ColPali & Late Interaction 10.2 Vision-Language Models 10.3 Audio, Speech & Multimodal Fusion 10.4 Diffusion Models & Generative Modeling (Breadth) 10.5 Unified & Any-to-Any Models 11.4 Reasoning, Coding & Agentic Evals 12.1 Designing an LLM Serving System 12.3 Caching, Routing & Cost Control in Production 14.4 The Stack-100M Architecture: SOTA Components, Cited and Assembled 14.5 Mini Scaling Laws: Fit Your Own Law Before Spending the Budget 14.11 Evaluation & Serving: Honest Benchmarks, int4 Quantization, and Running on a Laptop Glossary of Terms Key Papers: An Annotated Reading List Tooling & Environment Setup Cheatsheet From-Scratch Code Index
optimization (55)
1.1 Linear Algebra for Deep Learning 1.3 Calculus, Optimization & Convexity 1.4 Numerical Computing, Floating Point & Precision 1.5 Machine Learning Fundamentals 1.6 Neural Networks From Scratch: MLPs & Backprop 1.8 GPU Architecture & The Memory Hierarchy 1.9 Parallel Computing & Collective Communication 2.1 Tokenization: BPE, WordPiece, Unigram & Byte-Level 2.11 Beyond Attention: SSMs, Mamba, RWKV & Linear Attention 3.3 The Pretraining Objective & Loss 3.4 Scaling Laws: Kaplan, Chinchilla & Beyond 3.5 Distributed Training I: Data Parallelism, DDP, ZeRO & FSDP 3.7 Megatron-LM, DeepSpeed & Parallelism in Practice 3.8 Mixed Precision, bf16 & FP8 Training 3.9 Optimizers: SGD, Adam, Adafactor, Lion, Muon & Shampoo 3.10 Learning Rate Schedules, Warmup, Batch Size & Hyperparameters 3.11 Training Stability, Loss Spikes & Debugging Large Runs 3.14 Data Mixing, Domain Weighting & Curriculum 3.16 Continual & Domain-Adaptive Pretraining 3.17 Training an LLM From Scratch: The End-to-End Recipe 4.1 The Roofline Model & Performance Engineering 4.2 FlashAttention I: IO-Awareness & The Online Softmax 4.3 FlashAttention 2 & 3: Work Partitioning, Warp Specialization & FP8 4.4 Writing GPU Kernels with Triton 4.5 CUDA Programming Essentials for ML Engineers 4.6 PagedAttention & KV-Cache Memory Management 4.7 Quantization I: Post-Training Quantization (GPTQ, AWQ, SmoothQuant) 4.8 Quantization II: INT4/INT8/FP8, GGUF, bitsandbytes & QAT 4.9 Kernel Fusion, torch.compile, CUDA Graphs & Compilers 4.10 Memory-Efficient Training: Checkpointing, Offloading & LoRA Math 5.3 PEFT I: LoRA, QLoRA, DoRA & The Adapter Family 5.4 PEFT II: Prompt/Prefix Tuning, IA3, Model Merging & Soups 5.6 Policy Gradients & PPO for Language Models 5.7 Direct Preference Optimization & Its Variants 5.8 GRPO, RLOO & Critic-Free RL 5.12 Distillation, Model Compression & Knowledge Transfer 6.9 Advantage Estimation, KL Control & Stability Tricks 6.11 Scaling RL: Throughput, Load Balancing & The Latest Tricks 6.12 RL Data, Curriculum & Replay Management 7.1 The Anatomy of LLM Inference: Prefill, Decode & The KV Cache 7.2 Continuous Batching & Request Scheduling 7.3 vLLM: Architecture, PagedAttention & Internals 7.4 SGLang: RadixAttention & Structured Programs 7.6 Speculative Decoding: Draft Models, Medusa, EAGLE & Lookahead 7.7 Prefix Caching & KV-Cache Reuse 7.12 Inference Economics: Latency, Throughput & Cost 7.14 Multi-Tenant LoRA & Adapter Serving at Scale 8.4 Context Engineering & Management 12.3 Caching, Routing & Cost Control in Production 14.1 The Capstone: Building Stack-100M, and the 2026 Small-Model Landscape 14.5 Mini Scaling Laws: Fit Your Own Law Before Spending the Budget 14.6 Optimizer & Schedule: Muon + MuonClip and Warmup-Stable-Decay 14.7 The Pretraining Run: A Complete Single-GPU Training Loop 14.8 Mid-Training: Quality Annealing, Long-Context Extension & Capability Injection The Math Reference Sheet
scaling (35)
1.9 Parallel Computing & Collective Communication 1.10 The Accelerator Landscape: TPUs, Trainium, AMD/ROCm & Gaudi 2.5 Positional Encodings: Sinusoidal, Learned, RoPE & ALiBi 2.9 Mixture-of-Experts (MoE) Architectures 3.1 Pretraining Data: Sources, Crawling & The Data Pipeline 3.4 Scaling Laws: Kaplan, Chinchilla & Beyond 3.5 Distributed Training I: Data Parallelism, DDP, ZeRO & FSDP 3.6 Distributed Training II: Tensor, Pipeline, Sequence & Expert Parallelism 3.7 Megatron-LM, DeepSpeed & Parallelism in Practice 3.10 Learning Rate Schedules, Warmup, Batch Size & Hyperparameters 3.11 Training Stability, Loss Spikes & Debugging Large Runs 3.12 Checkpointing, Fault Tolerance & Long-Running Jobs 3.13 Long-Context Pretraining & Context Extension 3.14 Data Mixing, Domain Weighting & Curriculum 3.16 Continual & Domain-Adaptive Pretraining 3.17 Training an LLM From Scratch: The End-to-End Recipe 5.10 Reasoning, Chain-of-Thought & Test-Time Compute 6.1 The Anatomy of an RL-for-LLM System 6.4 veRL: HybridFlow & The Single-Controller Architecture 6.5 OpenRLHF, NeMo-Aligner & Ray-Based Systems 6.6 Prime-RL, Async RL & Decentralized Training 6.11 Scaling RL: Throughput, Load Balancing & The Latest Tricks 7.11 Multi-GPU & Multi-Node Inference 7.13 Serving Mixture-of-Experts: Expert Parallelism & All-to-All Inference 7.14 Multi-Tenant LoRA & Adapter Serving at Scale 10.1 Vision Transformers & Image Encoders 12.1 Designing an LLM Serving System 14.1 The Capstone: Building Stack-100M, and the 2026 Small-Model Landscape 14.2 Data: Sourcing, Filtering, Dedup, Tokenize & Pack ~20B Tokens 14.3 A Byte-Level BPE Tokenizer From Scratch (and Why Vocab Size Is a Design Lever at 100M) 14.4 The Stack-100M Architecture: SOTA Components, Cited and Assembled 14.5 Mini Scaling Laws: Fit Your Own Law Before Spending the Budget 14.8 Mid-Training: Quality Annealing, Long-Context Extension & Capability Injection 14.12 Retrospective: Cost Accounting, Reproducibility, and the Path to 1B The Math Reference Sheet
systems (90)
1.4 Numerical Computing, Floating Point & Precision 1.7 Automatic Differentiation & PyTorch Internals 1.8 GPU Architecture & The Memory Hierarchy 1.9 Parallel Computing & Collective Communication 1.10 The Accelerator Landscape: TPUs, Trainium, AMD/ROCm & Gaudi 2.1 Tokenization: BPE, WordPiece, Unigram & Byte-Level 2.2 Embeddings & The Input Pipeline 2.3 The Attention Mechanism From Scratch 2.4 Multi-Head Attention, MQA, GQA & MLA 2.7 Building a GPT From Scratch (nanoGPT-style) 2.9 Mixture-of-Experts (MoE) Architectures 2.10 Modern Architecture Improvements & Design Choices 2.11 Beyond Attention: SSMs, Mamba, RWKV & Linear Attention 2.12 Diffusion & Non-Autoregressive Language Models 3.1 Pretraining Data: Sources, Crawling & The Data Pipeline 3.2 Data Cleaning, Deduplication & Quality Filtering 3.5 Distributed Training I: Data Parallelism, DDP, ZeRO & FSDP 3.6 Distributed Training II: Tensor, Pipeline, Sequence & Expert Parallelism 3.7 Megatron-LM, DeepSpeed & Parallelism in Practice 3.8 Mixed Precision, bf16 & FP8 Training 3.9 Optimizers: SGD, Adam, Adafactor, Lion, Muon & Shampoo 3.10 Learning Rate Schedules, Warmup, Batch Size & Hyperparameters 3.11 Training Stability, Loss Spikes & Debugging Large Runs 3.12 Checkpointing, Fault Tolerance & Long-Running Jobs 3.13 Long-Context Pretraining & Context Extension 3.17 Training an LLM From Scratch: The End-to-End Recipe 4.1 The Roofline Model & Performance Engineering 4.2 FlashAttention I: IO-Awareness & The Online Softmax 4.3 FlashAttention 2 & 3: Work Partitioning, Warp Specialization & FP8 4.4 Writing GPU Kernels with Triton 4.5 CUDA Programming Essentials for ML Engineers 4.6 PagedAttention & KV-Cache Memory Management 4.7 Quantization I: Post-Training Quantization (GPTQ, AWQ, SmoothQuant) 4.8 Quantization II: INT4/INT8/FP8, GGUF, bitsandbytes & QAT 4.9 Kernel Fusion, torch.compile, CUDA Graphs & Compilers 4.10 Memory-Efficient Training: Checkpointing, Offloading & LoRA Math 5.2 Chat Templates, Data Formatting & Sequence Packing 5.3 PEFT I: LoRA, QLoRA, DoRA & The Adapter Family 5.12 Distillation, Model Compression & Knowledge Transfer 6.1 The Anatomy of an RL-for-LLM System 6.2 The Generation–Training Loop & Rollout Engines 6.3 TRL: HuggingFace's RL Library 6.4 veRL: HybridFlow & The Single-Controller Architecture 6.5 OpenRLHF, NeMo-Aligner & Ray-Based Systems 6.6 Prime-RL, Async RL & Decentralized Training 6.7 Colocated vs Disaggregated RL & Weight Synchronization 6.8 Reward Engineering, Verifiers & Sandboxes 6.10 Agentic & Multi-Turn RL 6.11 Scaling RL: Throughput, Load Balancing & The Latest Tricks 6.12 RL Data, Curriculum & Replay Management 7.1 The Anatomy of LLM Inference: Prefill, Decode & The KV Cache 7.2 Continuous Batching & Request Scheduling 7.3 vLLM: Architecture, PagedAttention & Internals 7.4 SGLang: RadixAttention & Structured Programs 7.5 TensorRT-LLM, TGI & Other Serving Stacks 7.6 Speculative Decoding: Draft Models, Medusa, EAGLE & Lookahead 7.7 Prefix Caching & KV-Cache Reuse 7.8 Disaggregated Prefill/Decode & Chunked Prefill 7.10 Structured & Constrained Generation 7.11 Multi-GPU & Multi-Node Inference 7.12 Inference Economics: Latency, Throughput & Cost 7.13 Serving Mixture-of-Experts: Expert Parallelism & All-to-All Inference 7.14 Multi-Tenant LoRA & Adapter Serving at Scale 8.1 Tool Use & Function Calling 8.3 Harness Engineering: Building a Coding Agent 8.4 Context Engineering & Management 8.5 Memory Systems for Agents 8.6 The Model Context Protocol (MCP) 8.7 Multi-Agent Systems & Orchestration 9.2 Vector Databases & Approximate Nearest Neighbor Search 9.3 Retrieval-Augmented Generation Architectures 9.4 Chunking, Reranking & Hybrid Search 9.5 Advanced RAG: GraphRAG, Agentic RAG & Long-Context vs RAG 9.6 Multimodal & Visual-Document Retrieval: ColPali & Late Interaction 11.3 Building Eval Harnesses 11.4 Reasoning, Coding & Agentic Evals 12.1 Designing an LLM Serving System 12.2 Observability, Logging & LLMOps 12.3 Caching, Routing & Cost Control in Production 12.7 Online Evaluation: A/B Testing, Canaries & Guardrail Metrics 12.8 Reliability Engineering for LLM Systems: SLOs & Incident Response 14.1 The Capstone: Building Stack-100M, and the 2026 Small-Model Landscape 14.2 Data: Sourcing, Filtering, Dedup, Tokenize & Pack ~20B Tokens 14.3 A Byte-Level BPE Tokenizer From Scratch (and Why Vocab Size Is a Design Lever at 100M) 14.6 Optimizer & Schedule: Muon + MuonClip and Warmup-Stable-Decay 14.7 The Pretraining Run: A Complete Single-GPU Training Loop 14.11 Evaluation & Serving: Honest Benchmarks, int4 Quantization, and Running on a Laptop 14.12 Retrospective: Cost Accounting, Reproducibility, and the Path to 1B Glossary of Terms Tooling & Environment Setup Cheatsheet
training (79)
1.1 Linear Algebra for Deep Learning 1.2 Probability, Statistics & Information Theory 1.3 Calculus, Optimization & Convexity 1.4 Numerical Computing, Floating Point & Precision 1.5 Machine Learning Fundamentals 1.6 Neural Networks From Scratch: MLPs & Backprop 1.7 Automatic Differentiation & PyTorch Internals 1.9 Parallel Computing & Collective Communication 2.2 Embeddings & The Input Pipeline 2.6 The Transformer Block: Norms, Residuals, MLPs & Activations 2.7 Building a GPT From Scratch (nanoGPT-style) 2.8 Architecture Variants: Encoder-Decoder, Decoder-Only & Prefix-LM 2.9 Mixture-of-Experts (MoE) Architectures 2.10 Modern Architecture Improvements & Design Choices 2.12 Diffusion & Non-Autoregressive Language Models 3.3 The Pretraining Objective & Loss 3.4 Scaling Laws: Kaplan, Chinchilla & Beyond 3.5 Distributed Training I: Data Parallelism, DDP, ZeRO & FSDP 3.6 Distributed Training II: Tensor, Pipeline, Sequence & Expert Parallelism 3.7 Megatron-LM, DeepSpeed & Parallelism in Practice 3.8 Mixed Precision, bf16 & FP8 Training 3.9 Optimizers: SGD, Adam, Adafactor, Lion, Muon & Shampoo 3.10 Learning Rate Schedules, Warmup, Batch Size & Hyperparameters 3.11 Training Stability, Loss Spikes & Debugging Large Runs 3.12 Checkpointing, Fault Tolerance & Long-Running Jobs 3.13 Long-Context Pretraining & Context Extension 3.14 Data Mixing, Domain Weighting & Curriculum 3.15 Synthetic Data for Pre- and Post-Training 3.16 Continual & Domain-Adaptive Pretraining 3.17 Training an LLM From Scratch: The End-to-End Recipe 4.1 The Roofline Model & Performance Engineering 4.8 Quantization II: INT4/INT8/FP8, GGUF, bitsandbytes & QAT 4.9 Kernel Fusion, torch.compile, CUDA Graphs & Compilers 4.10 Memory-Efficient Training: Checkpointing, Offloading & LoRA Math 5.1 Supervised Fine-Tuning & Instruction Tuning 5.2 Chat Templates, Data Formatting & Sequence Packing 5.3 PEFT I: LoRA, QLoRA, DoRA & The Adapter Family 5.4 PEFT II: Prompt/Prefix Tuning, IA3, Model Merging & Soups 5.5 The RLHF Pipeline & Reward Modeling 5.6 Policy Gradients & PPO for Language Models 5.7 Direct Preference Optimization & Its Variants 5.8 GRPO, RLOO & Critic-Free RL 5.9 RL with Verifiable Rewards (RLVR) & The Reasoning Recipe 5.10 Reasoning, Chain-of-Thought & Test-Time Compute 5.11 Constitutional AI, RLAIF & Self-Improvement 5.12 Distillation, Model Compression & Knowledge Transfer 6.1 The Anatomy of an RL-for-LLM System 6.2 The Generation–Training Loop & Rollout Engines 6.3 TRL: HuggingFace's RL Library 6.4 veRL: HybridFlow & The Single-Controller Architecture 6.6 Prime-RL, Async RL & Decentralized Training 6.8 Reward Engineering, Verifiers & Sandboxes 6.9 Advantage Estimation, KL Control & Stability Tricks 6.10 Agentic & Multi-Turn RL 6.12 RL Data, Curriculum & Replay Management 8.1 Tool Use & Function Calling 9.1 Embeddings & Representation Learning 10.1 Vision Transformers & Image Encoders 10.2 Vision-Language Models 10.4 Diffusion Models & Generative Modeling (Breadth) 10.5 Unified & Any-to-Any Models 12.5 Data Flywheels & Continuous Improvement 13.2 Knowledge Editing & Machine Unlearning 13.3 Privacy, Memorization & Differential Privacy for LLMs 14.1 The Capstone: Building Stack-100M, and the 2026 Small-Model Landscape 14.2 Data: Sourcing, Filtering, Dedup, Tokenize & Pack ~20B Tokens 14.4 The Stack-100M Architecture: SOTA Components, Cited and Assembled 14.5 Mini Scaling Laws: Fit Your Own Law Before Spending the Budget 14.6 Optimizer & Schedule: Muon + MuonClip and Warmup-Stable-Decay 14.7 The Pretraining Run: A Complete Single-GPU Training Loop 14.8 Mid-Training: Quality Annealing, Long-Context Extension & Capability Injection 14.9 Post-Training: SFT, DPO, and Narrow RLVR (GRPO) That Works at 100M 14.10 A Narrow Auto-Research Agent: ReAct, Tool-Use & Retrieval by Distillation 14.12 Retrospective: Cost Accounting, Reproducibility, and the Path to 1B Glossary of Terms The Math Reference Sheet Key Papers: An Annotated Reading List Tooling & Environment Setup Cheatsheet From-Scratch Code Index

Prerequisite map

Each chapter with what it lets you do and the concepts to know first (linked to where they are taught).

Part I — Mathematical & Systems Foundations
Compute and reason with matmuls, SVD, norms, and the backprop transpose identities behind LoRA.
Prereqs: basic vector and matrix notation derivatives and the chain rule Python and PyTorch tensor basics big-O time-complexity notation
Compute entropy, KL divergence, cross-entropy, and perplexity, and justify cross-entropy as the LLM training loss.
Prereqs: logarithms and exponentials basic calculus (derivatives, integrals) summation and integral notation the softmax function vectors and basic linear algebra
Analyze loss landscapes via gradients and Hessians, and choose/tune optimizers like SGD and Adam.
Prereqs: single-variable calculus (derivatives) linear algebra basics (vectors, matrices, eigenvalues) matrix multiplication partial derivatives the concept of a neural network loss function
Reason about floating-point formats and apply stable-arithmetic tricks to keep LLM training numerically sound.
Prereqs: binary representation of numbers basic calculus (exponentials and logarithms) the softmax function gradients and backpropagation basics matrix multiplication basic Python/PyTorch tensor operations
Diagnose bias-variance tradeoffs, apply regularization, and choose correct metrics for any ML model.
Prereqs: gradient descent basic probability and expectation vector norms (L1/L2) loss functions and cross-entropy basic Python/PyTorch usage
Build and hand-verify backprop for an MLP, from scalar autograd to a vectorized NumPy classifier.
Prereqs: matrix multiplication and transposes partial derivatives and the chain rule gradient descent and convex/non-convex optimization basics vectors and linear maps (linear algebra) softmax and probability basics
Trace PyTorch's autograd tape, write custom Function backwards, and debug memory/precision bugs from strides to NaNs.
Prereqs: chain rule Jacobian matrix MLP forward and backward pass (backpropagation) ReLU activation function gradient descent basics
Classify any GPU kernel as compute- or memory-bound and reason about occupancy and hardware fit.
Prereqs: matrix multiplication basic linear algebra floating-point number formats (FP16/BF16/FP32) Python programming basic notion of parallel computing
Reason about GPU collective communication costs and choose the right collective for a parallelism strategy.
Prereqs: gradient descent and backpropagation GPU memory hierarchy (HBM) and CUDA basics Python and PyTorch tensor operations basic computer networking (bandwidth vs. latency) processes vs. threads / operating-system basics
Choose and port LLM workloads across TPU, Trainium, AMD ROCm, and Gaudi accelerators using roofline reasoning.
Prereqs: SIMT GPU architecture and the memory hierarchy floating-point formats (bf16, FP8/FP4) collective communication (all-reduce, all-gather, NVLink) arithmetic intensity and the roofline model the KV cache in LLM inference tensor-parallel sharding
Part II — The Transformer Architecture
Implement and choose a subword tokenizer (BPE, WordPiece, Unigram, byte-level) and reason about its cost/arithmetic tradeoffs.
Prereqs: basic Python programming UTF-8 and character encoding basics regular expressions the idea of an embedding table big-O complexity basic probability (likelihood, EM at an intuitive level)
Implement and size the token embedding, weight-tied unembedding, and input pipeline for a Transformer LM.
Prereqs: matrix multiplication softmax tokenization and token IDs backpropagation and gradients basic PyTorch nn.Module usage
Derive, implement, and mask scaled dot-product attention from scratch in NumPy and PyTorch.
Prereqs: matrix multiplication and transposes dot product as a similarity measure the softmax function backpropagation / automatic differentiation basic NumPy and PyTorch tensor operations
Derive KV-cache size for MHA/MQA/GQA/MLA and implement the MHA-to-GQA conversion in PyTorch.
Prereqs: single-head scaled dot-product attention softmax matrix multiplication and matrix reshaping autoregressive decoding GPU memory hierarchy and HBM bandwidth
Implement RoPE/ALiBi positional encodings and extend a model's context length via NTK/YaRN scaling.
Prereqs: self-attention / scaled dot-product attention softmax token embeddings KV cache basic trigonometry and rotation matrices multi-head attention
Assemble and implement a full pre-norm transformer block: norms, residuals, gated FFN, activations.
Identify and implement encoder-only, encoder-decoder, decoder-only, and prefix-LM attention masks and their tradeoffs.
Build a sparse MoE layer with routing, load balancing, and capacity, and reason about its systems cost.
Prereqs: the Transformer block (attention plus position-wise FFN) the FFN as two linear layers with a nonlinearity (GELU/SwiGLU) softmax gradient descent and backpropagation basic distributed/parallel computing concepts (optional, for the expert-parallelism preview)
Explain and implement the modern transformer recipe (RMSNorm, SwiGLU, RoPE, GQA, QK-norm) used in production LLMs.
Analyze and choose sub-quadratic attention alternatives (SSMs, Mamba, RWKV, RetNet, hybrids) for long-context LLMs.
Part III — Pretraining at Scale
Build a pretraining data pipeline: source, extract, weight, and shard trillions of tokens.
Prereqs: BPE tokenization next-token prediction training objective basic HTTP/HTML concepts distributed/streaming systems basics (object storage, worker pools)
Build a production pipeline to filter, deduplicate, and decontaminate raw web text for pretraining.
Prereqs: tokenization web crawl data pipelines (CommonCrawl/WARC/WET) hash functions basic probability and set operations n-gram language models next-token prediction / language modeling objective
Compute, mask, and debug the causal-LM cross-entropy loss, including packing and tokenizer-agnostic BPB scoring.
Prereqs: the attention mechanism and causal masking softmax function chain rule of probability KL divergence / entropy tokenization and vocabulary (BPE)
Derive and apply scaling laws to compute-optimally plan a training run's model size and data.
Prereqs: cross-entropy loss for next-token prediction FLOP counting for matrix multiplications learning rate schedules (cosine decay and warmup) basic optimization (derivatives, Lagrange multipliers) GPU peak throughput and memory hierarchy basics pretraining data pipeline and tokenization
Implement DDP's bucketed gradient sync and choose/apply ZeRO-1/2/3 or FSDP sharding to fit large models.
Prereqs: collective communication primitives (all-reduce, reduce-scatter, all-gather) the alpha-beta communication cost model backpropagation and autograd mixed-precision (bf16/fp32) training the Adam/AdamW optimizer GPU memory basics
Partition huge transformer models via tensor, pipeline, sequence/context, and expert parallelism to train beyond single-GPU memory.
Configure Megatron-LM + DeepSpeed parallelism degrees for a multi-hundred-GPU run and measure hardware efficiency via MFU/HFU.
Implement correct bf16/fp16 AMP training loops and scale FP8 GEMMs for production LLM training.
Prereqs: floating-point representation (exponent/mantissa, dynamic range vs precision) matrix multiplication and GEMMs backpropagation and gradient computation gradient-based optimizers (e.g. AdamW) GPU tensor cores / accelerator throughput basics
Pick, derive, and implement an optimizer (AdamW, Adafactor, Lion, Shampoo, Muon) for a memory/speed budget.
Prereqs: stochastic gradient descent and backpropagation the Hessian and condition number of a loss surface singular value decomposition (SVD) mixed-precision training (bf16/fp32 master weights) matrix multiplication and basic linear algebra
Choose, implement, and debug LR schedules, warmup, batch-size scaling, and muP hyperparameter transfer for pretraining.
Diagnose, mitigate, and prevent loss spikes and divergence in large-scale LLM pretraining runs.
Design and implement fault-tolerant, resumable checkpointing for large-scale distributed LLM training.
Prereqs: Fully Sharded Data Parallel (FSDP) / ZeRO parameter sharding Adam optimizer and its moment estimates mixed-precision training (bf16/fp16) basic distributed training concepts (ranks, world size, process groups) PyTorch training loop fundamentals
Design, weight, and schedule a pretraining data mixture using epoch budgets, DoReMi, and annealing.
Prereqs: cross-entropy loss data deduplication scaling laws for language models learning rate warmup and decay schedules power-law learning curves basic probability distributions (simplex, weighted average)
Design synthetic-data pipelines (rephrasing, textbook generation, reasoning distillation) that avoid model collapse.
Adapt a converged base model to new domains/languages/data via re-warm+replay CPT, model growth, and compute planning.
Prereqs: cosine learning rate schedules and warmup Adam optimizer and its moment estimates compute/scaling-law estimates (C ≈ 6ND) Mixture-of-Experts architecture and routing BPE tokenization embedding and unembedding matrices
Run a full pretrain pipeline end-to-end, raw corpus to sampled checkpoint, at four hardware scales.
Prereqs: GPT / transformer architecture BPE tokenization AdamW and gradient-based optimization cross-entropy loss distributed data-parallel training (DDP/FSDP) learning rate scheduling
Part IV — Kernels, Efficiency & Quantization
Classify any GPU kernel as compute- or memory-bound and pick the matching optimization.
Prereqs: GPU architecture and memory hierarchy (HBM, SM, L2) the transformer block (attention and FFN) matrix multiplication and its FLOP cost floating-point number formats (fp32, bf16, fp8) basic big-O style counting of operations
Analyze FlashAttention-2/3's work partitioning, warp specialization, and FP8 incoherent-processing tricks.
Prereqs: the online-softmax recurrence for attention FlashAttention-1's IO-aware tiling GPU architecture (SMs, warps, shared memory, register pressure) the roofline model and arithmetic intensity the attention mechanism and softmax matrix multiplication / GEMM basics
Write, profile, and optimize custom CUDA kernels (tiled matmul, fused ops) for LLM workloads.
Prereqs: GPU memory hierarchy roofline model and arithmetic intensity matrix multiplication basic C/C++ programming PyTorch tensor operations
Compute KV-cache memory, diagnose fragmentation, and implement block-table paging with copy-on-write sharing.
Prereqs: the attention mechanism autoregressive decoding (prefill and decode phases) KV cache GQA/MQA virtual memory and paging (operating systems) FlashAttention and online softmax
Quantize a trained LLM's weights (and activations) to INT4/INT8 post-hoc using GPTQ, AWQ, or SmoothQuant.
Prereqs: floating-point number representation matrix multiplication / linear layers KV cache memory-bandwidth-bound vs compute-bound performance (roofline model) LayerNorm / RMSNorm affine parameters
Choose and implement INT4/INT8/FP8/GGUF quantization formats, plus QAT and QLoRA, for efficient deployment.
Fuse kernels, capture CUDA graphs, and use torch.compile to speed up PyTorch models.
Compute a transformer's full training memory budget and apply checkpointing, offloading, and LoRA/QLoRA to fit it on smaller GPUs.
Prereqs: GPU memory hierarchy (HBM, PCIe bandwidth) mixed-precision training (bf16/fp32) the Adam optimizer transformer architecture (attention, FFN, layer norm) ZeRO/FSDP distributed training basics
Part V — Post-Training & Alignment
Fine-tune a base model into an instruction-follower via response-only loss masking, with data curation and forgetting mitigation.
Build chat templates, loss masks, and packed batches for training conversational models.
Adapt LLMs via soft prompts, prefix tuning, IA3, or by merging fine-tuned checkpoints without retraining.
Derive DPO's closed-form loss from RLHF, implement it, and pick among IPO/KTO/ORPO/SimPO/CPO variants.
Derive and implement critic-free RL (RLOO, GRPO) and apply the 2025 Dr. GRPO/DAPO fixes.
Implement knowledge distillation, pruning, and quantization-aware compression to shrink large models.
Diagnose reward hacking via the KL-reward frontier and defend RLHF pipelines with KL control, reward ensembles, and verifiable rewards.
Part VI — RL Infrastructure (Deep Dive)
Map the six components and dataflow of any RL-for-LLM system and diagnose its bottlenecks.
Prereqs: policy-gradient RL for LLMs (PPO) GRPO / RLOO critic-free RL autoregressive decoding and KV cache distributed training (FSDP / data parallelism) mixed precision training basics of LLM inference serving
Trace, profile, and optimize the five-phase RL rollout-to-gradient loop and its staleness tradeoffs.
Prereqs: PPO (Proximal Policy Optimization) objective GRPO / group-relative advantage estimation KV cache autoregressive decoding FSDP or other distributed training basics reward modeling / RLHF basics
Configure and debug TRL's SFT/Reward/DPO/PPO/GRPO trainers, including PEFT and vLLM integration, for real alignment runs.
Explain and implement veRL's HybridFlow dispatch and 3D-HybridEngine resharding to scale RL-for-LLM training.
Prereqs: the RL-for-LLM training loop (policy, rollout, reward, trainer) PPO/GRPO and advantage estimation distributed training (FSDP, Megatron tensor/pipeline parallelism) vLLM/SGLang inference engines and PagedAttention Ray actors and remote calls GPU memory budgeting for weights, gradients, and optimizer state
Design and choose a Ray/Megatron-based RLHF system, laying out actors and weight sync for a given cluster.
Prereqs: the PPO objective vLLM's PagedAttention engine the four-role decomposition of an RL-for-LLM system (policy, critic, reward model, reference model) DeepSpeed ZeRO / distributed data parallelism Megatron-LM tensor/pipeline/data parallelism
Design async off-policy RL pipelines with staleness corrections and verify untrusted decentralized inference via TOPLOC.
Design rule-based verifiers, LLM judges, and sandboxes to compute reliable RL training rewards.
Implement and debug production-grade advantage estimators, KL control, and PPO clipping tricks for LLM RL.
Build and train multi-turn agentic RL rollouts with correct action/observation masking and credit assignment.
Select, curriculum-order, and replay RL prompts so every rollout carries gradient signal.
Part VII — Inference & Serving
Estimate LLM serving speed from model size and GPU bandwidth using prefill/decode physics.
Prereqs: the transformer forward pass causal self-attention mechanism the roofline performance model GPU memory hierarchy and HBM bandwidth softmax and matrix multiplication
Design and implement an iteration-level scheduler that keeps LLM-serving batches pinned near capacity.
Reuse cached KV blocks across requests via content hashing/radix tries to cut TTFT and prefill compute.
Choose and implement decoding algorithms (temperature, top-k/p, min-p, beam search, contrastive decoding) to control LLM output quality.
Prereqs: the autoregressive decoding loop / KV cache softmax function transformer output logits over a vocabulary basic probability (multinomial sampling, entropy) cumulative sum / cumulative probability mass
Implement and reason about FSM/PDA-based logit masking to guarantee LLM output matches a grammar or schema.
Size and configure multi-GPU/multi-node LLM serving using tensor, pipeline, expert, and data parallelism.
Derive $/1M-token costs, size GPU clusters, and pick batching/quantization tradeoffs against latency SLOs.
Design and diagnose large-EP MoE inference: overlap all-to-all, balance hot experts, size dense-equivalent throughput.
Part VIII — Agents & Harness Engineering
Build a robust tool-calling loop: define schemas, parse/validate/dispatch calls, handle errors, run in parallel.
Build a working ReAct agent and apply plan-execute, reflection, and tree-search patterns with guardrails against loops and drift.
Architect and implement episodic, semantic, and vector agent memory with compaction and session persistence.
Build, connect, and secure MCP servers exposing tools, resources, and prompts to agent hosts.
Design, implement, and cost-benchmark multi-agent LLM systems across topologies and frameworks.
Select agent benchmarks and compute pass@k, confidence intervals, and harness-adjusted comparisons correctly.
Prereqs: tool use / function calling in agents the agent harness/scaffold concept basic probability and combinatorics software unit testing and test suites reward modeling / RL reward hacking basics
Design, optimize, and evaluate production prompts using CoT, few-shot, DSPy/APE, and caching.
Prereqs: instruction-tuned language models and chat message roles autoregressive next-token generation KV cache and prefill/decode inference basics basic conditional probability notation the agentic tool-use loop (calling tools, observing results)
Part IX — Retrieval & RAG
Train and evaluate bi-encoder dense embedding models with contrastive InfoNCE and hard negatives for RAG retrieval.
Build and choose ANN indexes (IVF, PQ, HNSW) to retrieve top-k vectors at scale within a latency budget.
Prereqs: dense vector embeddings cosine similarity and Euclidean distance k-means clustering matrix multiplication / GEMM GPU memory bandwidth vs. compute (memory-bound operations)
Design, build, and evaluate a production RAG pipeline from chunking through RAGAS metrics.
Prereqs: dense embeddings / vector representations cosine similarity approximate nearest neighbor search transformer-based language models BM25 sparse retrieval basics prompt construction for LLMs
Build a production RAG retrieval pipeline: chunk documents, fuse BM25/dense search, and rerank with cross-encoders.
Prereqs: embeddings and cosine similarity dense vector retrieval / ANN search the attention mechanism tokenization RAG system architecture basics TF-IDF / inverted index concepts
Diagnose naive RAG failure modes and choose among GraphRAG, agentic, self-correcting, or long-context architectures.
Part X — Multimodal & Generative Frontiers
Patchify images into tokens and build ViT-based CLIP, SigLIP, and DINOv2 image encoders.
Convert audio to tokens/features and build ASR, TTS, and streaming speech LMs fused with text.
Prereqs: the attention mechanism / transformer architecture autoregressive next-token prediction and text tokenization (BPE) cross-attention and encoder-decoder architectures vector quantization / embedding lookup basics KV cache and inference latency (prefill/decode, TTFT) basic signal processing (sampling rate, Fourier transform)
Derive, train, and sample diffusion models (DDPM, DDIM, CFG, latent diffusion, flow matching, diffusion LMs).
Prereqs: Gaussian distributions and basic probability the attention mechanism (self- and cross-attention) variational autoencoders (VAEs) convolutional neural networks and U-Net basics the Transformer architecture gradient-based training and MSE regression
Design and train a single transformer that understands and generates text, images, audio, and video.
Prereqs: decoder-only transformer architecture autoregressive next-token prediction and cross-entropy loss causal self-attention masking vision-language models with frozen encoder plus connector basic diffusion/denoising generative models Mixture-of-Experts routing basics
Part XI — Evaluation
Critically read LLM benchmark claims: spot contamination, saturation, and statistically insignificant score gains.
Prereqs: next-token prediction / language modeling objective basic probability and confidence intervals chain-of-thought prompting reading and writing basic Python (regex, functions) multiple-choice question-answering setup
Build, debias, and calibrate an LLM-as-a-judge pipeline, including Elo-based arena ranking.
Prereqs: prompting and chat-completion APIs chain-of-thought prompting basic probability and statistics (correlation, expected value) reward modeling and the RLHF pipeline benchmark-style evaluation (e.g., MMLU, HumanEval)
Build, run, and statistically validate reproducible eval harnesses like lm-evaluation-harness and HELM.
Prereqs: next-token prediction and log-probabilities few-shot prompting the benchmark landscape (e.g. MMLU, HellaSwag) tokenization and special/BOS tokens basic statistics (standard error, hypothesis testing) chat/instruction-tuned model formatting
Build trustworthy, execution-verified evals for coding, math reasoning, and long-horizon agentic tasks.
Prereqs: basic probability and combinatorics chain-of-thought reasoning unit testing / test suites containerization and process isolation the broader benchmark landscape (accuracy, exact-match metrics) reinforcement learning reward signals
Attach confidence intervals, paired significance tests, and power analysis to any eval score.
Prereqs: benchmark evaluation basics (accuracy, pass/fail scoring) probability and statistics foundations (sampling distributions, standard error, hypothesis testing) binomial distribution LLM-as-a-judge evaluation eval harness mechanics
Part XII — Production, Systems & MLOps
Design and size a multi-replica LLM serving fleet: routing, SLOs, queueing, memory, batching, autoscaling.
Instrument, log, evaluate, and alert on production LLM systems, closing the ship-observe-improve loop.
Prereqs: the LLM serving pipeline (prefill, decode, KV cache) retrieval-augmented generation (RAG) basics LLM-as-a-judge evaluation basic statistics (mean, standard deviation, hypothesis testing) distributed systems / microservices concepts token-based API pricing
Design a layered cache-route-batch-spot stack that cuts LLM production API spend 50-90%.
Prereqs: KV cache token-based API pricing (input/output tokens) quantization (PTQ, INT4/INT8) continuous batching / request scheduling basics embeddings and cosine similarity basic distributed-systems concepts (load balancers, retries, TTL)
Design, tune, and deploy a layered guardrail stack (input/output classifiers, PII redaction, shield models) around a production LLM.
Prereqs: RLHF/DPO-based alignment precision, recall, and F-scores fine-tuning encoder classifiers (e.g. BERT-scale models) system prompts and chat templates retrieval-augmented generation (RAG) basic LLM serving/inference pipeline (prefill, time-to-first-token)
Build a production data flywheel that logs, labels, distills, retrains, and eval-gates model updates.
Design A/B tests, canaries, and guardrail metrics to evaluate and safely roll out LLM features in production.
Prereqs: hypothesis testing and p-values statistical power and sample size LLM-as-a-judge evaluation offline benchmark evaluation basic probability and variance
Define quality-aware SLOs, diagnose LLM failures, and build rollback, postmortem, and failover systems.
Prereqs: LLM inference basics (latency, tokens, streaming) retrieval-augmented generation (RAG) pipelines LLM-as-a-judge automated evaluation structured logging and distributed tracing A/B testing and canary deployments basic statistics (percentiles, standard deviation)
Part XIII — Interpretability, Safety & Governance
Reverse-engineer transformer internals using probing, logit lens, activation patching, circuits, and SAEs.
Locate and surgically edit facts in model weights, and verify unlearning survives adversarial audits.
Measure and defend against LLM training-data leakage using canaries, MIA audits, and DP-SGD.
Prereqs: cross-entropy loss and maximum-likelihood training objective gradient descent / SGD basic probability (log-likelihood, Gaussian distributions, ROC curves) overfitting vs. generalization next-token prediction / autoregressive language modeling
Implement, evaluate, and choose among watermarking, C2PA provenance, and post-hoc AI-text detection.
Prereqs: next-token prediction and logits softmax and sampling (temperature/nucleus) cryptographic hash functions basic hypothesis testing (p-values, z-scores) LLM inference serving basics
Design scalable-oversight, dangerous-capability, and control protocols to gate frontier model deployment.
Prereqs: RLHF (reinforcement learning from human feedback) and reward modeling chain-of-thought reasoning reward hacking and alignment failure modes red-teaming and safety evaluation methodology basic statistical hypothesis testing (effect size, p-values)
Determine which AI-regulation obligations apply to a model and build the compliance artefacts to satisfy them.
Prereqs: training compute (FLOPs) and Chinchilla-style scaling approximations pretraining data pipelines and web crawling red-teaming and safety evaluation methodology watermarking and content-provenance techniques basic notions of model parameters and training tokens
Part XIV — Capstone: Build a 100M LLM End-to-End
Plan and budget a from-scratch 101M-parameter LLM build using 2026 small-model best practices.
Prereqs: the transformer architecture and attention mechanism KV cache Chinchilla scaling laws byte-level BPE tokenization mixed-precision (bf16) training basics GPU FLOP throughput and training compute (the 6ND rule)
Source, filter, deduplicate, tokenize, and pack a 20B-token corpus for a 100M-parameter model.
Assemble and parameter-count a from-scratch 100M-parameter transformer from named, cited 2024-2026 SOTA components.
Fit and validate your own scaling law from a cheap model ladder before committing training budget.
Prereqs: Kaplan/Chinchilla scaling laws for loss vs. parameters and tokens the 6ND FLOP-counting rule for transformers transformer architecture components (GQA, RoPE, SwiGLU, RMSNorm) learning rate schedules (WSD/cosine decay) tokenization and vocabulary size trade-offs nonlinear curve fitting / non-convex optimization
Write and run a complete, resumable single-GPU pretraining loop with real throughput monitoring.
Prereqs: transformer forward/backward pass the optimizer and WSD learning-rate schedule (Muon+AdamW) packed dataset and doc-aware masking floating-point precision (fp32/fp16/bf16) cross-entropy loss scaling laws and compute-optimal training
Anneal on premium data, extend RoPE context to 8192, and inject math/code capability across one continuous LR decay.
Itemize the ~$100 training bill, make a run bit-reproducible, and plan the 100M-to-1B scale-up.
Prereqs: scaling laws (Chinchilla-optimal compute allocation) distributed training (DDP, FSDP/ZeRO, tensor and pipeline parallelism) checkpointing and fault-tolerant training loops mixed-precision (bf16/fp8) training and optimizer memory footprint optimizers (AdamW, Muon) and learning-rate/batch-size scheduling the full Stack-100M pipeline (tokenizer, pretraining, alignment, quantization)
Appendix
Look up a precise, cross-linked definition for any term used anywhere in the LLM stack.
Prereqs: the Transformer architecture gradient descent and backpropagation GPU and CUDA basics probability and information theory
Navigate the field's canonical papers by topic and follow a six-week reading curriculum with textbook cross-links.
Prereqs: the Transformer architecture and self-attention gradient-based training and backpropagation the standard pretraining-then-fine-tuning paradigm GPU memory and compute basics the RLHF/alignment pipeline at a conceptual level familiarity with the book's core chapters this list cross-links to
Set up, pin, debug, and profile the CUDA/PyTorch/HF/DeepSpeed/vLLM stack for real LLM work.
Locate any from-scratch code implementation in the book and trace what it depends on and enables.