// Stage 4 · Transformers & LLMs
Modern LLM Architecture
RoPE, SwiGLU, RMSNorm, GQA/MLA, FlashAttention, sliding windows and context extension.
about 12 hours12 algorithms5 paperslesson text in progress
01Goals
- Read the config files of Llama, Qwen and DeepSeek
- Compute how much KV cache GQA/MLA saves
- Understand why FlashAttention is fast
Do these first: Transformers & Attention
02Algorithms to master
Each card has the original paper, prerequisites and resources.
03Must-read papers
- RoFormer: Enhanced Transformer with Rotary Position Embedding ↗2021 ✓ verified in Essentials
- GQA: Training Generalized Multi-Query Transformer Models from Multi-Head Checkpoints ↗2023 ✓ verified in Essentials
- DeepSeek-V2: A Strong, Economical, and Efficient Mixture-of-Experts Language Model ↗2024 ✓ verified in Essentials
- FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness ↗2022 ✓ verified in Essentials
- YaRN: Efficient Context Window Extension of Large Language Models ↗2023 ✓ verified
04Courses & videos
- rasbt/LLMs-from-scratch ↗Reference codeEN
- Lilian Weng:The Transformer Family v2 ↗ExplainersEN
- Rotary Embeddings ↗ExplainersEN
- github.com ↗Reference codeEN
05Hands-on: project, code & exercises
Free, official or author-published pages. Most run in the browser or on a free Colab GPU.
PROJECT
Convert your small GPT to RoPE + RMSNorm + SwiGLU + GQA and record changes in parameter count, speed and loss.
- 1rasbt/LLMs-from-scratch ↗Reference code
Build GPT with the book, then convert it to a Llama-style model (RoPE, RMSNorm, SwiGLU, GQA) via the bonus chapters.
- 2scaled_dot_product_attention ↗Official docs
Swap hand-written attention for PyTorch SDPA and compare speed and memory.
06Self-test
Answer in your head, then open to check.
How much smaller is GQA’s KV cache than MHA’s?
By the ratio of KV heads to query heads.
What does RoPE make attention depend on?
The relative position of the two tokens.
What does FlashAttention mainly save?
Memory reads and writes (IO), not FLOPs.
On these routes: Algorithm Researchers