Track 07 · Specialisation
Deep Learning Engineering
Build language models from scratch: data pipelines, tokenizers, Transformer architecture, pre-training, post-training (SFT, DPO, RL with verifiable rewards), distributed training, scaling laws and evaluation.
- Last updated
- Total effort
- 1100 h · ≈ 110 weeks
Overview
Deep learning engineering is the craft of turning data and compute into a capable model, and then into a useful one. You own the whole training stack: collecting and filtering data, training a tokenizer, designing the architecture, running stable pre-training at scale, then post-training with supervised fine-tuning (SFT), preference optimisation (DPO and relatives) and reinforcement learning, and finally measuring what you built with honest evals. It is where math, systems engineering and empirical science meet, and the open-source ecosystem (nanoGPT, nanochat, TorchTitan, TRL, open reports such as Llama 3, DeepSeek-V3 and Tulu 3) now makes it possible to learn on a single GPU what labs do on thousands.
Why it matters heading into 2027
The frontier moved from bigger pre-training to post-training and reasoning: DeepSeek-R1 (2025) showed reinforcement learning with verifiable rewards can teach reasoning, and since then GRPO-style RL, distillation and synthetic data have become standard recipes. Companies increasingly fine-tune and post-train open-weight models instead of only calling APIs, so engineers who understand the training stack end to end are scarce. AI skills appear in a fast-growing share of postings, with PyTorch named among the top skills for AI engineers. Deep training skills also make you a far better AI, inference and harness engineer, because you know why models behave as they do.
- AI engineer is LinkedIn's fastest-growing US role for 2026; PyTorch is among the most-listed skills. — Dice on LinkedIn Jobs on the Rise 2026
- AI skills now appear in 2.5% of all US job postings, up 55% year over year. — Lightcast for the Stanford AI Index 2026
Prerequisites
- Comfortable Python and NumPy; you can read and debug other people's code.
- Foundations Beginner stage: vectors and matrices, derivatives and the chain rule, basic probability.
- ML Engineering Beginner concepts: train/validation/test splits, overfitting, loss functions.
- Access to a GPU: a free Colab or Kaggle GPU is enough until the Advanced stage.
Learning path
How the stages build on each other, and where this track hands off to others.
flowchart TB
P["Prereqs: Python · linear algebra · calculus"] --> B
subgraph B["1 · Beginner — neural nets from scratch"]
direction LR
B1["autograd & backprop"] --> B2["MLP · CNN"] --> B3["clean training loop"]
end
subgraph I["2 · Intermediate — Transformers"]
direction LR
I1["BPE tokenizer"] --> I2["GPT from scratch"] --> I3["LoRA fine-tune"]
end
subgraph A["3 · Advanced — the LLM stack"]
direction LR
A1["data pipeline"] --> A2["pre-train 124M"] --> A3["SFT → DPO"] --> A4["evals"]
end
subgraph E["4 · Expert — scale & reasoning"]
direction LR
E1["FSDP · TP · PP"] --> E2["scaling-law sweep"] --> E3["GRPO / RLVR"] --> E4["tech report"]
end
B --> I --> A --> E
A -.-> INF["Inference & GPU"]
A -.-> CLOUD["Cloud: secure training"]
E -.-> SAFE["AI Security & Safety"]
Stages
Tick items as you go — progress is saved in this browser only. Times are focused hours (reading + building); the week estimates follow the study time you pick above.
01Beginner140 h · ≈ 14 weeksUnderstand learning as optimisation. Build a tiny autograd engine, then train MLPs and CNNs in PyTorch with a clean, reproducible training loop.
Key concepts
Build these
Ready for the next stage when…
02Intermediate220 h · ≈ 22 weeksMaster the Transformer. Write a tokenizer and a GPT from scratch, understand every line, then fine-tune an open model with LoRA.
Key concepts
Build these
Ready for the next stage when…
03Advanced320 h · ≈ 32 weeksRun the full LLM pipeline yourself: curated data → pre-training → SFT → preference optimisation → evals. Small models, real methodology.
Key concepts
Build these
Ready for the next stage when…
04Expert420 h · ≈ 42 weeksScale and reasoning: multi-GPU parallelism, scaling-law experiments, RL with verifiable rewards, and publishing reproducible results.
Key concepts
Build these
Ready for the next stage when…
Field guide
The ideas behind the checklist, with diagrams and the math where it helps.
The training pipeline at a glance
Every modern LLM goes through the same broad stages. Labs differ in the details (data, scale, the RL recipe), but the shape is the same. The roadmap above has you build each box yourself, at small scale.
flowchart TB
subgraph DATA["1 · Data"]
direction LR
D1["crawl / collect"] --> D2["filter · dedup · quality"] --> D3["mixture + tokenize"]
end
subgraph PT["2 · Pre-training"]
direction LR
P1["next-token prediction<br/>trillions of tokens"] --> P2["mid-training<br/>long context · code · math"]
end
subgraph POST["3 · Post-training"]
direction LR
S1["SFT"] --> S2["preference optimisation<br/>RLHF · DPO"] --> S3["RL with verifiable rewards<br/>GRPO"]
end
subgraph EVAL["4 · Evaluate & ship"]
direction LR
E1["benchmarks · judges · red-team"] --> E2["quantise · serve"]
end
DATA --> PT --> POST --> EVAL
EVAL -. "regressions become new data" .-> DATA
Learning is optimisation
A model with parameters takes a token sequence and is trained to predict each next token. Pre-training minimises the average negative log-likelihood (the cross-entropy):
Perplexity is just . Gradient descent updates , and backpropagation computes by applying the chain rule backwards through the computational graph. That’s why building micrograd comes first: once you’ve written backprop yourself, loss.backward() stops being magic.
Rule of thumb: when a run misbehaves, check in this order: data (look at real batches), learning rate, initialisation and normalisation, then numerics (overflow in fp16, missing loss scaling).
Attention in one equation
Each token produces a query , key and value . Stacked into matrices, scaled dot-product attention is:
is the causal mask ( above the diagonal), so a token can’t see the future. The keeps the dot products from growing with dimension and saturating the softmax. A modern decoder block wraps this as:
flowchart TB
X["residual stream x"] --> N1["RMSNorm"] --> ATT["causal self-attention<br/>RoPE on q,k · GQA"] --> ADD1(("+"))
X --> ADD1
ADD1 --> N2["RMSNorm"] --> MLP["SwiGLU MLP"] --> ADD2(("+"))
ADD1 --> ADD2
ADD2 --> OUT["to next block"]
Attention costs in sequence length. FlashAttention doesn’t change that count; it reorganises the computation so the matrix never sits in slow GPU memory. That’s why reading the Inference & GPU track pays off here.
Back-of-the-envelope compute and memory
You should be able to estimate a run before launching it. For a dense Transformer with parameters trained on tokens:
The 6 is 2 FLOPs per parameter per token for the forward pass and about 4 for the backward pass. Example: GPT-2 small () on tokens needs about FLOPs. At an achieved 40% of a GPU’s ~1 PFLOP/s bf16 peak, that’s roughly five GPU-hours.
Memory for mixed-precision training with AdamW is roughly 16 bytes per parameter before activations: bf16 weights (2) + bf16 grads (2) + fp32 master weights (4) + two fp32 Adam moments (8). So a 7B model needs ~112 GB for weights and optimiser state alone. That’s why ZeRO/FSDP sharding exists.
| Parallelism | What is split | Use it when |
|---|---|---|
| Data (DDP) | the batch | the model fits on one GPU |
| FSDP / ZeRO-3 | weights, grads, optimiser state | the model nearly fits; the default first step |
| Tensor (TP) | matrices inside a layer | layers are too big; needs fast NVLink within a node |
| Pipeline (PP) | groups of layers | many nodes; accept pipeline “bubbles” |
| Context / sequence | the sequence dimension | very long contexts |
| Expert (EP) | MoE experts | Mixture-of-Experts models |
Scaling laws: spend compute wisely
Kaplan et al. (2020) found loss falls as a power law in parameters, data and compute. Chinchilla (2022) fitted
and showed that, for a fixed budget, parameters and tokens should grow together: about 20 tokens per parameter. Modern open models deliberately “over-train” far past that (Llama 3 8B saw ~15T tokens) because a smaller, longer-trained model is cheaper to serve. Training-optimal and deployment-optimal are different questions, and the Expert-stage scaling-law project makes this concrete.
Post-training: from SFT to RL
SFT is the same next-token loss, applied only to the response tokens of curated (prompt, response) pairs in a chat template. It teaches format and behaviour.
RLHF (InstructGPT) trains a reward model on human preference pairs, then optimises the policy with PPO while a KL penalty keeps it near the SFT reference model:
DPO shows this objective has a closed-form optimal policy, so you can skip the reward model and RL loop and train directly on preferred () and rejected () answers:
GRPO (DeepSeekMath, then DeepSeek-R1) drops PPO’s value network. For each prompt it samples a group of answers, scores them (often with a verifiable reward: did the math answer match? did the tests pass?) and uses the group-normalised score as the advantage:
This is RL with verifiable rewards (RLVR), the recipe behind 2025-era reasoning models. Its failure modes are worth studying as much as its successes: reward hacking, exploding response length, and the normalisation biases that DAPO and Dr. GRPO correct.
flowchart LR
B["base model"] --> SFT["SFT<br/>demonstrations"]
SFT --> PREF{"preference data?"}
PREF -- "pairs" --> DPO["DPO / SimPO"]
PREF -- "thumbs up/down" --> KTO["KTO"]
PREF -- "reward model + online RL" --> PPO["RLHF (PPO)"]
SFT --> RLVR["GRPO / RLVR<br/>verifiable tasks"]
DPO --> M["aligned model"]
KTO --> M
PPO --> M
RLVR --> M
Evaluation is part of training
A training run without evals is a vibe. Build the habit early:
- Track held-out loss and a few cheap downstream evals during training, not just at the end.
- Check for contamination: n-gram overlap between your training data and benchmark test sets.
- Report uncertainty. Small benchmarks have wide confidence intervals; run several seeds where you can.
- Use LLM judges carefully: swap answer positions, control for length, and spot-check by hand (MT-Bench paper).
- Write at least one eval nobody else has, such as Sinhala QA or your domain’s tasks. Public benchmarks saturate; private evals tell you the truth.
How this track connects
- FoundationsThe chain rule is backprop, KL divergence sits inside DPO and RLHF, and diffusion is a physics-inspired stochastic process. Foundations make papers readable.
- Data Eng.Pre-training quality is mostly data quality: crawling, dedup, filtering and mixtures are data-pipeline engineering at scale.
- Inference & GPUKV caches, quantisation, FlashAttention and kernels decide what training choices (GQA, MoE, context length) cost at serving time.
- Cloud & IAMReal training runs need GPU clusters, object storage, least-privilege IAM for data buckets and secure model registries.
- AI Eng.Knowing post-training helps you decide when to prompt, when to RAG and when to fine-tune, and how to evaluate the result.
- AI SecurityRLHF, reward hacking, Constitutional AI and evals are where training meets alignment and safety.
References
Original sources first: arXiv, official docs, university courses and lab blogs. Every link was checked on 7 Nov 2026.
Foundational & seminal papers(45)
- Adam: A Method for Stochastic Optimization
Kingma & Ba · 2014 · arxiv.org
The default optimiser; understand its two moment estimates.
- Neural Machine Translation of Rare Words with Subword Units
Sennrich et al. · 2015 · arxiv.org
Byte-pair encoding for NLP — the tokenizer you'll implement.
- Attention Is All You Need
Vaswani et al. · 2017 · arxiv.org
The Transformer. Read it twice: once now, once after you've built a GPT.
- Decoupled Weight Decay Regularization (AdamW)
Loshchilov & Hutter · 2017 · arxiv.org
Why LLMs use AdamW rather than Adam + L2.
- Mixed Precision Training
Micikevicius et al. · 2017 · arxiv.org
Half-precision training with loss scaling.
- Deep reinforcement learning from human preferences
Christiano et al. · 2017 · arxiv.org
The origin of RLHF.
- Proximal Policy Optimization Algorithms
Schulman et al. · 2017 · arxiv.org
The RL algorithm behind classic RLHF.
- BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
Devlin et al. · 2018 · arxiv.org
The encoder-side counterpart; masked-language modelling is still used for embeddings and classifiers.
- SentencePiece: A simple and language independent subword tokenizer and detokenizer
Kudo & Richardson · 2018 · arxiv.org
Language-agnostic tokenization; important for non-English text like Sinhala.
- Language Models are Unsupervised Multitask Learners (GPT-2)
Radford et al., OpenAI · 2019 · cdn.openai.com
Decoder-only pre-training at scale gives zero-shot ability; the model you'll reproduce.
- Root Mean Square Layer Normalization
Zhang & Sennrich · 2019 · arxiv.org
RMSNorm — the cheaper normalisation in modern LLMs.
- ZeRO: Memory Optimizations Toward Training Trillion Parameter Models
Rajbhandari et al. · 2019 · arxiv.org
Sharding optimiser state, gradients and weights — the idea behind FSDP.
- Megatron-LM: Training Multi-Billion Parameter Language Models Using Model Parallelism
Shoeybi et al. · 2019 · arxiv.org
Tensor parallelism inside Transformer layers.
- Language Models are Few-Shot Learners (GPT-3)
Brown et al. · 2020 · arxiv.org
In-context learning emerges with scale.
- GLU Variants Improve Transformer
Shazeer · 2020 · arxiv.org
The SwiGLU feed-forward block used by most open models.
- Scaling Laws for Neural Language Models
Kaplan et al. · 2020 · arxiv.org
Loss follows power laws in parameters, data and compute.
- Measuring Massive Multitask Language Understanding (MMLU)
Hendrycks et al. · 2020 · arxiv.org
The classic knowledge benchmark — and a lesson in saturation.
- RoFormer: Enhanced Transformer with Rotary Position Embedding
Su et al. · 2021 · arxiv.org
RoPE, now the standard position encoding.
- Switch Transformers: Scaling to Trillion Parameter Models with Simple and Efficient Sparsity
Fedus et al. · 2021 · arxiv.org
Simplified Mixture-of-Experts routing.
- LoRA: Low-Rank Adaptation of Large Language Models
Hu et al. · 2021 · arxiv.org
Fine-tune by training a low-rank update; where you'll start fine-tuning.
- Evaluating Large Language Models Trained on Code (HumanEval)
Chen et al. · 2021 · arxiv.org
Defines pass@k for code evaluation.
- Training Compute-Optimal Large Language Models (Chinchilla)
Hoffmann et al. · 2022 · arxiv.org
Revised the ratio to ~20 tokens per parameter; the basis of compute budgeting.
- FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
Dao et al. · 2022 · arxiv.org
Thinking in memory hierarchy, not FLOPs. Follow with FlashAttention-2 (2023).
- Training language models to follow instructions with human feedback (InstructGPT)
Ouyang et al. · 2022 · arxiv.org
The canonical SFT → reward model → PPO pipeline.
- Constitutional AI: Harmlessness from AI Feedback
Bai et al. · 2022 · arxiv.org
RL from AI feedback guided by written principles.
- Self-Instruct: Aligning Language Models with Self-Generated Instructions
Wang et al. · 2022 · arxiv.org
The start of synthetic SFT data.
- Holistic Evaluation of Language Models (HELM)
Liang et al. · 2022 · arxiv.org
Evaluation as many metrics × many scenarios.
- GQA: Training Generalized Multi-Query Transformer Models from Multi-Head Checkpoints
Ainslie et al. · 2023 · arxiv.org
Smaller KV cache, faster inference — a training choice made for serving.
- LLaMA: Open and Efficient Foundation Language Models
Touvron et al. · 2023 · arxiv.org
The modern open-model recipe (RMSNorm, SwiGLU, RoPE) in one place.
- QLoRA: Efficient Finetuning of Quantized LLMs
Dettmers et al. · 2023 · arxiv.org
LoRA on a 4-bit base model — fine-tuning on one consumer GPU.
- Direct Preference Optimization: Your Language Model is Secretly a Reward Model
Rafailov et al. · 2023 · arxiv.org
Preference tuning without RL or a separate reward model.
- Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena
Zheng et al. · 2023 · arxiv.org
When model judges agree with humans, and their position and verbosity biases.
- The Llama 3 Herd of Models
Grattafiori et al. · 2024 · arxiv.org
A complete frontier pre- and post-training report; read it as a checklist.
- DeepSeek-V3 Technical Report
DeepSeek-AI · 2024 · arxiv.org
MoE, multi-head latent attention, FP8 training and multi-token prediction.
- The FineWeb Datasets: Decanting the Web for the Finest Text Data at Scale
Penedo et al. · 2024 · arxiv.org
How pre-training data is filtered and deduplicated, with ablations.
- KTO: Model Alignment as Prospect Theoretic Optimization
Ethayarajh et al. · 2024 · arxiv.org
Learns from thumbs-up/down data instead of pairs.
- ORPO: Monolithic Preference Optimization without Reference Model
Hong et al. · 2024 · arxiv.org
SFT and preference optimisation in one stage.
- SimPO: Simple Preference Optimization with a Reference-Free Reward
Meng et al. · 2024 · arxiv.org
Length-normalised, reference-free DPO variant.
- DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models
Shao et al. · 2024 · arxiv.org
Introduced GRPO — RL without a value network.
- Tulu 3: Pushing Frontiers in Open Language Model Post-Training
Lambert et al. · 2024 · arxiv.org
A fully open post-training recipe; introduced RL with verifiable rewards (RLVR).
- DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning
DeepSeek-AI · 2025 · arxiv.org
Reasoning emerging from RL with rule-based rewards; the 2025 turning point.
- DAPO: An Open-Source LLM Reinforcement Learning System at Scale
Yu et al. · 2025 · arxiv.org
Practical fixes to GRPO (clip-higher, dynamic sampling, token-level loss).
- Understanding R1-Zero-Like Training: A Critical Perspective (Dr. GRPO)
Liu et al. · 2025 · arxiv.org
Finds GRPO's length and normalisation biases — read before trusting long responses.
- Muon is Scalable for LLM Training
Liu et al., Moonshot AI · 2025 · arxiv.org
An orthogonalised-update optimiser that challenges AdamW at scale.
- Kimi K2: Open Agentic Intelligence
Kimi Team · 2025 · arxiv.org
Trillion-parameter MoE trained with MuonClip; agentic post-training at scale.
Courses & videos(10)
- Neural Networks: Zero to Hero
Andrej Karpathy · karpathy.ai
Start here: micrograd → makemore → GPT → tokenizer, all from scratch.
- Let's build GPT: from scratch, in code, spelled out
Andrej Karpathy · 2023 · youtube.com
Your Intermediate-stage project, line by line.
- Let's reproduce GPT-2 (124M)
Andrej Karpathy · 2024 · youtube.com
A real pre-training run with every efficiency trick explained.
- Stanford CS336: Language Modeling from Scratch
Stanford · cs336.stanford.edu
The best university course on building LLMs; do the assignments.
- Stanford CS224N: Natural Language Processing with Deep Learning
Stanford · web.stanford.edu
NLP and Transformer fundamentals with strong lectures.
- Stanford CS231n: Deep Learning for Computer Vision
Stanford · cs231n.stanford.edu
The classic backprop and training-practice course.
- Practical Deep Learning for Coders
fast.ai · course.fast.ai
Code-first, top-down — good alongside the from-scratch path.
- Hugging Face LLM Course
Hugging Face · huggingface.co
The HF ecosystem: tokenizers, Transformers, fine-tuning.
- The Ultra-Scale Playbook: Training LLMs on GPU Clusters
Hugging Face (nanotron) · 2025 · huggingface.co
Data, tensor, pipeline and context parallelism plus ZeRO, explained with benchmarks.
- The Smol Training Playbook
Hugging Face · 2025 · huggingface.co
An honest end-to-end log of training a small LLM, including what failed.
Books(8)
- Understanding Deep Learning
Simon J. D. Prince · 2023 · udlbook.github.io
Modern, clear and free — the best first textbook.
- Build a Large Language Model (From Scratch)
Sebastian Raschka · 2024 · manning.com
A GPT built step by step, through fine-tuning.
- Dive into Deep Learning
Zhang, Lipton, Li & Smola · d2l.ai
Interactive, code-heavy, free.
- Deep Learning: Foundations and Concepts
Christopher M. Bishop & Hugh Bishop · 2024 · bishopbook.com
Rigorous modern textbook for the math-minded.
- Deep Learning
Goodfellow, Bengio & Courville · 2016 · deeplearningbook.org
The classic theory reference (pre-Transformer, still valuable).
- How to Scale Your Model
Google DeepMind (Austin et al.) · 2025 · jax-ml.github.io
Rooflines, sharding and the arithmetic of training and serving at scale.
- Reinforcement Learning: An Introduction (2nd ed.)
Sutton & Barto · 2018 · incompleteideas.net
RL foundations for RLHF and GRPO; free.
- Reinforcement Learning from Human Feedback
Nathan Lambert · rlhfbook.com
The free, up-to-date book on post-training.
Articles, blogs & official docs(14)
- nanoGPT
Andrej Karpathy · github.com
Minimal, readable GPT training code.
- nanochat
Andrej Karpathy · github.com
The full ChatGPT-style pipeline (tokenizer → pre-train → SFT → RL) for about $100.
- llm.c
Andrej Karpathy · github.com
LLM training in raw C/CUDA — where the Expert stage meets GPU programming.
- The Annotated Transformer
Harvard NLP · nlp.seas.harvard.edu
The paper, interleaved with runnable code.
- The Illustrated Transformer
Jay Alammar · jalammar.github.io
Visual intuition for attention.
- RLHF: Reinforcement Learning from Human Feedback
Chip Huyen · 2023 · huyenchip.com
A clear tour of the pipeline.
- Reward Hacking in Reinforcement Learning
Lilian Weng · 2024 · lilianweng.github.io
How RL post-training goes wrong, and what to watch for.
- Understanding Reasoning LLMs
Sebastian Raschka · 2025 · magazine.sebastianraschka.com
The four main ways reasoning models are built.
- The State of Reinforcement Learning for LLM Reasoning
Sebastian Raschka · 2025 · magazine.sebastianraschka.com
GRPO and the papers that followed, summarised.
- Muon: An optimizer for hidden layers in neural networks
Keller Jordan · 2024 · kellerjordan.github.io
The original Muon write-up.
- TRL documentation
Hugging Face · huggingface.co
SFT, DPO, GRPO and PPO trainers you'll use for post-training.
- TorchTitan
PyTorch · github.com
PyTorch-native reference for large-scale pre-training (FSDP2, TP, PP).
- PyTorch FSDP documentation
PyTorch · docs.pytorch.org
Sharded data parallelism in practice.
- lm-evaluation-harness
EleutherAI · github.com
The standard open evaluation framework.