How to become an AI Research Engineer
Step by step and free: 12 phases, 90 topics and 285 graded practice questions.
Open any topic and mark it Learning, Done or Skip to track your progress. Sign in to save it to your account.
0 of 90 done · 0 learning · 0 skipped · Start with the first topic
Saved on this device only. Sign up free or sign in to keep your progress everywhere.
It's saved on this device only. Sign up free to keep it everywhere; your marks move into your account.
What is an AI Research Engineer?
An AI Research Engineer turns research ideas into experiments that run, scale and give a trustworthy answer. They implement methods from papers, write and debug training code in PyTorch or JAX, design ablations and sweeps within a compute budget, and diagnose runs that diverge or stall. They work alongside research scientists, help decide which results are real, and carry the ones that hold up toward a product.
Who this roadmap is for
Machine learning engineers and strong software engineers who already train models in PyTorch or JAX and want to join research teams, and PhD students who want production-grade engineering habits. You need linear algebra, probability and solid Python. It is not a starting point for people new to machine learning.
What you will be able to do
You will be able to implement a paper and prove numerical parity with a reference, build and debug a training loop and its data pipeline, design experiments with honest baselines and statistics, choose a distributed training layout, profile and speed up a run, and run fine-tuning and RL experiments on language models.
The AI Research Engineer roadmap
AI Research Engineer
-
Phase 1 Foundations and the research loop
-
Phase 2 Deep learning internals for research engineers
-
Phase 3 Research code and tooling
-
Phase 4 Implementing from papers
-
Phase 5 The training loop and its data
-
Phase 6 Debugging training runs
-
Phase 7 Experiment design and infrastructure
-
Phase 8 Evaluation and analysis for research
-
Phase 9 Distributed training
-
Phase 10 Performance and efficiency
-
Phase 11 Post-training and RL experiments
-
Phase 12 Research to production and the craft
All topics, in order
Mark each topic Learning, Done or Skip, and sign in to save your place to your account. Done is your own word, not passing: a topic is passed when you score 50 or more on its questions. This order is the study plan.
-
Phase 1 · Foundations and the research loop
-
What a research engineer does
A research engineer makes research ideas cheap to test and their results trustworthy. Scientists own the hypothesis; you own the harness that runs it: the training code, configs, tracking and evals, so a question asked on Monday has a believable answer by Friday. Your leverage is in what you make reusable and in refusing to report a number you cannot trace. Harden what the team reruns often, not every script, and say plainly when a result is not ready.
Reading
- A Recipe for Training Neural Networks (Karpathy) karpathy.github.io
- Stas Bekman: Machine Learning Engineering (open book) github.com
- The Research Engineer role at EleutherAI eleuther.ai
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
The research loop and time to signal
Research speed is set by time to signal: how long it takes from a change in code to a number you trust. Keep an inner loop of minutes (a tiny model, a small data slice, a test that must pass) and an outer loop of hours or days for runs at scale, and push as many questions as you can into the inner one. When the team slows down, measure where the hours go, because queue time, flaky jobs and manual analysis often cost more than the GPUs.
Reading
- Google Research: Deep Learning Tuning Playbook github.com
- Hamming: You and Your Research cs.virginia.edu
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
From an idea to a runnable experiment
Scientists often arrive with a direction, not a test. Before writing code, pin down the question in one sentence, the smallest experiment that could answer it, the metric and baseline, and the result that would change the plan. Write the decision rule down before you see the numbers, so a weak or mixed result becomes a decision rather than a reason to keep tuning. If no outcome would change what the team does next, the run is not worth its compute.
Reading
- Google Research: Deep Learning Tuning Playbook github.com
- A Recipe for Training Neural Networks (Karpathy) karpathy.github.io
- Hamming: You and Your Research cs.virginia.edu
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Reading papers as an engineer
Read a paper as a claim about one setup, not a fact about the world. Find the exact baseline and whether it was tuned as hard as the method, the model size, data and token count, the eval protocol, and how many seeds sit behind each number. Many gains come from details left out of the text, such as a schedule or a data filter. Use the first pass to decide whether the claim is relevant and credible at your scale before spending a week reproducing it.
Reading
- How to Read a Paper (Keshav) web.stanford.edu
- Troubling Trends in Machine Learning Scholarship (Lipton, Steinhardt) arxiv.org
- NeurIPS paper checklist neurips.cc
- arXiv cs.LG recent listings arxiv.org
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
Reading reference code and configs
When a paper ships code, the code is the method: initialisation, schedules, normalisation placement, data filtering and loss tricks often live only in a config file or a helper function. Read the training entry point first, then the config that produced the headline number, then diff both against your own setup. Treat every unstated default as a possible cause of the gain, and record which ones you copied so a later gap can be traced back to them.
Reading
- The 37 Implementation Details of PPO (ICLR blog track) iclr-blog-track.github.io
- Implementation Matters in Deep Policy Gradients (Engstrom et al.) arxiv.org
- Do Transformer Modifications Transfer? (Narang et al.) arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Reproducing results
Reproducing a result is diagnosis. First check that your evaluation matches the paper's exactly, then reproduce the paper's baseline in your own harness: if your baseline is also low, the gap is in your pipeline, and if it matches, the gap is in the method or a missing detail. Change one suspected cause at a time rather than tuning until the target number appears, and when the paper is simply underspecified, say so and report what you could and could not match.
Reading
- ML Reproducibility Checklist (Pineau) cs.mcgill.ca
- Improving Reproducibility in ML Research (Pineau et al.) arxiv.org
- PyTorch reproducibility notes pytorch.org
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
Chapter 1 lab
Write the instruction for an agent that diagnoses a reproduction gap
A prompt lab that closes the chapter: you write the instruction, and it is graded on a rubric.
Start the lab -
-
Phase 2 · Deep learning internals for research engineers
-
Tensors, shapes and broadcasting
Many silent bugs in research code are shape bugs that broadcasting hides. Adding a tensor of shape (batch,) to one of shape (batch, 1) gives a (batch, batch) result with no error, and a reduction over the wrong axis still returns a number. Name your dimensions in comments or with einops, assert shapes at module boundaries, and test with distinct sizes for batch, sequence and hidden so a swapped axis fails loudly instead of training on garbage.
Reading
- PyTorch: broadcasting semantics pytorch.org
- NumPy: broadcasting numpy.org
- einops documentation einops.rocks
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Autograd in practice
Autograd records operations on tensors that require gradients and walks them backwards when you call backward. Gradients accumulate until you zero them, detach cuts a tensor out of the graph, no_grad skips recording entirely, and an in-place edit to a saved tensor can raise an error or corrupt a gradient. When a parameter's gradient is missing or zero, check whether its path to the loss was cut, usually by a detach, a trip through NumPy or an integer operation.
Reading
- PyTorch: autograd mechanics pytorch.org
- Karpathy: micrograd github.com
- Karpathy: Neural Networks: Zero to Hero karpathy.ai
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Losses and their numerics
Compute cross-entropy from raw logits with the library's fused function, which uses the log-sum-exp trick, rather than taking the log of a softmax you computed yourself, which can underflow. Know how the loss is reduced: a mean over all tokens and a mean of per-sequence means weight long and short examples differently, and padding must be excluded with an ignore index or a mask. Two runs whose losses are averaged differently cannot share a plot.
Reading
- PyTorch: CrossEntropyLoss pytorch.org
- PyTorch: log_softmax pytorch.org
- Dive into Deep Learning: softmax regression, concise implementation d2l.ai
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Optimizers: SGD, Adam and AdamW
SGD with momentum stores one buffer per parameter; Adam stores two (running means of gradients and of squared gradients), which is why optimizer state often outweighs the weights. AdamW decouples weight decay from the adaptive update, so decay acts on the weights directly instead of being rescaled away. Betas, epsilon and which parameters get decay (usually not norms or biases) all change results, so set them in the config and never let a library default decide silently.
Reading
- Adam: A Method for Stochastic Optimization (Kingma, Ba) arxiv.org
- Decoupled Weight Decay Regularization (AdamW) arxiv.org
- PyTorch: torch.optim pytorch.org
- Dive into Deep Learning: Adam d2l.ai
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Learning rate schedules and warmup
The learning rate schedule is part of the method, and changing it can move results as much as an architecture tweak. Warmup protects the early steps while Adam's statistics are unreliable, cosine decay ties the schedule to a fixed run length, and warmup-stable-decay holds the rate flat and decays at the end, so one long run can be branched into several lengths. Compare methods only under schedules tuned for each, and never compare a mid-decay checkpoint with a fully decayed one.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Initialisation and normalisation
Initialisation and normalisation decide whether activations and gradients stay in a usable range as depth grows. Pre-norm transformers normalise each block's input and keep a clean residual path, which trains more stably at depth than post-norm; RMSNorm drops the mean subtraction and is cheaper. Residual branches are often scaled down at init so their sum does not grow with layer count. If a deeper model trains worse than a shallow one, check activation scales per layer before blaming the idea.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
The transformer as code
A decoder-only transformer is a stack of identical blocks writing into a residual stream. Each block reads the stream through a norm, adds an attention output (tokens mixing information, masked so none sees the future), then adds an MLP output (per-token computation). Embeddings map tokens in and an unembedding maps the final stream to logits. Write one block yourself from the equations at least once: it is the fastest way to read papers that change one part and to spot what a codebase does differently.
Reading
- Attention Is All You Need (Vaswani et al.) arxiv.org
- The Annotated Transformer (Harvard NLP) nlp.seas.harvard.edu
- Karpathy: nanoGPT github.com
- Karpathy: Neural Networks: Zero to Hero karpathy.ai
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Tokenizers and what they do to experiments
The tokenizer decides what the model sees, so it is part of the experiment. Byte-pair encoding merges frequent byte sequences into a fixed vocabulary, special tokens mark documents and turns, and the same word can tokenise differently with or without a leading space. Per-token loss is not comparable across tokenizers because the tokens differ, so compare in bits per byte or on downstream evals, and pin the tokenizer version with every dataset you build.
Reading
- Neural Machine Translation of Rare Words with Subword Units (BPE) arxiv.org
- Karpathy: minbpe github.com
- Hugging Face Tokenizers documentation huggingface.co
- OpenAI: tiktoken github.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
-
Phase 3 · Research code and tooling
-
PyTorch for research code
PyTorch runs eagerly, so you can print, step through and assert anywhere, which is why so much research code is written in it. A module holds parameters and buffers and exposes them through its state dict, which is what you save and load; forward and backward hooks let you read or edit activations without touching model code. Register non-trainable tensors as buffers so they move devices and get saved, and keep model, optimizer and data state separate so each can be restored.
Reading
- PyTorch: nn.Module pytorch.org
- PyTorch: modules, buffers and hooks pytorch.org
- PyTorch: saving and loading models pytorch.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
JAX for research code
JAX treats a model as a pure function of parameters and inputs, transformed by grad, jit and vmap. Randomness is explicit: you split and pass PRNG keys, so reusing a key silently repeats the same dropout mask. Jit traces your Python once per input shape, so Python side effects run only at trace time and changing shapes forces recompiles. In return you get whole-program compilation and sharding annotations that scale the same code across many accelerators.
Reading
- JAX quickstart docs.jax.dev
- JAX: the sharp bits docs.jax.dev
- JAX: pseudorandom numbers docs.jax.dev
- How to Scale Your Model (JAX scaling book) jax-ml.github.io
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Structuring a research codebase
A research codebase should make the common change easy and the baseline hard to break. Use one training entry point driven by config, put each new idea behind a flag that defaults off, and leave the baseline code path unchanged so old results stay reproducible. Prefer a little copied code over a deep class hierarchy every experiment must bend. Delete dead experiments once their results are written up, because unused flags become traps for the next person.
Reading
- The Good Research Code Handbook (Mineault) goodresearch.dev
- PyTorch: torchtitan github.com
- Karpathy: nanoGPT github.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Configs as the experiment record
The config is the record of what an experiment was. Use typed configs that fail on an unknown key, apply command-line overrides on top of a named base, and save the fully resolved config with every run. A typo that silently creates a new field, or a default changed in code, can make two runs differ in a way nobody notices. If a result cannot be rerun from its saved config and commit alone, the config is incomplete.
Reading
- Hydra documentation hydra.cc
- OmegaConf: structured configs omegaconf.readthedocs.io
- Python: dataclasses docs.python.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Testing research code
Research code needs tests because its bugs rarely crash; they make results slightly wrong. Unit test each component against a reference with small, odd shapes, check that a tiny model can overfit one batch, and keep a short golden run whose loss at a fixed step must match within tolerance after every change. Run them in CI on CPU or a small GPU. Tests that take seconds get run and tests that take an hour get skipped, so keep most of them tiny.
Reading
- pytest documentation docs.pytest.org
- PyTorch: torch.testing pytorch.org
- The Good Research Code Handbook: testing goodresearch.dev
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Seeds and determinism
A seed fixes the random streams for initialisation, data order and dropout, but GPU kernels that use atomic adds can still give slightly different sums from run to run. Seed every library, record the seeds, and give data order and model init separate seeds so you can vary one without the other. Turn on deterministic algorithms when debugging a divergence, leave them off for big runs if they cost speed, and measure seed variance instead of assuming it is small.
Reading
- PyTorch: reproducibility pytorch.org
- PyTorch: use_deterministic_algorithms pytorch.org
- JAX: pseudorandom numbers docs.jax.dev
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Environments and dependency pinning
Two machines running the same code can train differently because a library, CUDA or driver version moved. Lock exact dependency versions in a lock file, build runs from a container image whose tag is logged with each run, and record the driver and CUDA runtime next to the commit. Upgrade the framework deliberately, on a branch, with the golden run as the check, rather than letting a fresh install pick up whatever is newest that day.
Reading
- pip: repeatable installs pip.pypa.io
- uv documentation docs.astral.sh
- NVIDIA: deep learning framework containers docs.nvidia.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
-
Phase 4 · Implementing from papers
-
Implementing from papers
Big models train through many bugs, so a run that learns is weak evidence that a new component is right. Build the novel piece on its own, test it against a slow, obviously correct reference and with gradient checks, then integrate it and run a short comparison against the baseline. Copying a similar operator from another repository is risky, because masking, scaling and normalisation details are exactly where lookalikes differ. A run that starts only proves the shapes line up.
Reading
- PyTorch: extending with custom autograd functions pytorch.org
- torch.autograd.gradcheck docs.pytorch.org
- The Annotated Transformer (Harvard NLP) nlp.seas.harvard.edu
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
Writing a slow reference implementation
Before writing the fast version of anything, write the slow one: plain loops instead of fused ops, fp32 instead of bf16, the paper's equation line by line. That version is your oracle. Every optimised variant, kernel or sharded version is then tested by feeding both the same inputs and comparing outputs and gradients. Keep the reference in the repository beside its tests rather than deleting it, because the next optimisation will need it too.
Reading
- PyTorch: torch.testing pytorch.org
- torch.autograd.gradcheck docs.pytorch.org
- Karpathy: micrograd github.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Numerical parity testing
Two correct implementations rarely agree to the last bit, so parity tests need tolerances that mean something. Compare in fp32 first, where relative differences near 1e-6 are rounding; in bf16 expect differences around 1e-2, and check forward outputs, loss and gradients separately. A difference that grows with sequence length or depth is a bug, not noise. When a check fails, find the first layer where outputs diverge instead of loosening the tolerance until it passes.
Reading
- PyTorch: numerical accuracy pytorch.org
- PyTorch: torch.testing.assert_close pytorch.org
- Hugging Face: adding a new model (output parity steps) huggingface.co
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Attention masks and positional encodings
Attention bugs leak the future or ignore the past without crashing. A causal mask must stop position i attending to anything after i, padding masks must stop real tokens attending to padding, and packed documents need masks that stop attention across a document boundary. Rotary embeddings rotate queries and keys by position, so an off-by-one in positions after packing or caching changes every score. Test masks directly: change a future token and assert earlier outputs stay the same.
Reading
- RoFormer: rotary position embedding (Su et al.) arxiv.org
- PyTorch: scaled_dot_product_attention pytorch.org
- PyTorch blog: FlexAttention pytorch.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Loading and converting pretrained weights
Loading a released checkpoint into your code means mapping every tensor name, shape and layout: fused or separate query, key and value weights, transposed linear layers, tied embeddings and differing norm epsilons. Convert, then prove it: run both implementations on the same tokens and compare logits within a tight fp32 tolerance, and check that a standard eval matches the published score. A converted model that generates fluent text can still be subtly wrong.
Reading
- Hugging Face: adding a new model to Transformers huggingface.co
- Hugging Face: safetensors huggingface.co
- PyTorch: saving and loading models pytorch.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Adding a component to an existing model
Add a new idea to a shared model so that turning it off gives exactly the old model. Put it behind a config flag that defaults off, keep the baseline path untouched, and add a test that the flag-off model produces outputs identical to the previous commit. Then the comparison between baseline and idea differs only by the idea, and every older result in the tracker stays reproducible from its saved config.
Reading
- The Good Research Code Handbook (Mineault) goodresearch.dev
- Do Transformer Modifications Transfer? (Narang et al.) arxiv.org
- PyTorch: torchtitan github.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Mixture-of-experts layers
A mixture-of-experts layer replaces one MLP with many experts and a router that sends each token to a few of them, so parameters grow faster than per-token compute. Routers tend to collapse onto a few experts, so training adds a load-balancing loss or a bias adjustment, and a capacity limit per expert means overflow tokens can be dropped. Log expert load and dropped-token rate every step: a model can look fine on loss while half its experts sit idle.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
Chapter 4 lab
Write the brief for building a numerical parity suite against a paper
A prompt lab that closes the chapter: you write the instruction, and it is graded on a rubric.
Start the lab -
-
Phase 5 · The training loop and its data
-
Anatomy of a training step
One training step runs in a fixed order: forward pass, loss, backward pass, optional gradient clipping, optimizer step, zeroing gradients, then the scheduler step. Getting the order wrong causes quiet bugs, such as clipping before mixed-precision gradients are unscaled or stepping the scheduler per micro-batch instead of per optimizer step. Log loss, learning rate, gradient norm and throughput from one place each step, so every curve lines up with the step that produced it.
Reading
- PyTorch: optimizing model parameters pytorch.org
- PyTorch: clip_grad_norm_ pytorch.org
- PyTorch AMP examples (unscaling before clipping) pytorch.org
- Karpathy: nanoGPT github.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Effective batch size and gradient accumulation
The batch the optimizer sees is micro-batch size times accumulation steps times data-parallel ranks, and learning rate and warmup are tuned for that number. When you accumulate, scale each micro-batch's loss so the summed gradient equals the full-batch mean; with variable-length sequences that means normalising by the total tokens across all micro-batches, not averaging per-micro-batch means. Change any of the three factors and you have changed a hyperparameter.
Reading
- Hugging Face: fixing gradient accumulation huggingface.co
- An Empirical Model of Large-Batch Training (McCandlish et al.) arxiv.org
- Accurate, Large Minibatch SGD (Goyal et al.) arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Training infrastructure: keeping a long run productive
A long run's real output is goodput: useful training steps per hour of reserved hardware. It leaks two ways. Time spent waiting, when the input pipeline or a slow collective leaves GPUs idle, which a high utilisation reading can hide because it only shows that some kernel was running; and work lost to preemption or crashes, which checkpoint cadence and exact resumption control. A resumable checkpoint holds weights, optimizer, scheduler, step, RNG states and data loader position.
Reading
- PyTorch data loading and DataLoader pytorch.org
- PyTorch Profiler recipe pytorch.org
- PyTorch: distributed checkpoint pytorch.org
- torchdata: StatefulDataLoader pytorch.org
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
Data pipelines for pretraining
Pretraining data is tokenised ahead of time into shards so the training job only reads and batches. Shuffle at two levels, shard order and a buffer within shards, so batches do not inherit the order sources were written in, and make the loader's position part of the checkpoint so a resumed run neither repeats nor skips data. Benchmark the loader on its own: if it cannot outrun a training step on one node, it will starve every node.
Reading
- MosaicML Streaming documentation docs.mosaicml.com
- Hugging Face Datasets: streaming huggingface.co
- torchdata: StatefulDataLoader pytorch.org
- Dolma: an open corpus for LM pretraining research arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Sequence packing and document masks
Packing concatenates documents into fixed-length sequences so no compute is wasted on padding. Without a document mask, tokens attend to unrelated documents earlier in the same sequence, which leaks context and can hurt quality; with a per-document mask and positions reset at each boundary, a packed batch behaves like separate sequences. Count real tokens rather than sequences when you report how much data a run saw, and test the mask the same way you test a causal one.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Data mixtures and sampling weights
A pretraining dataset is a mixture of sources such as web, code, books and maths, and the sampling weights matter as much as the sources. Weights decide how many times each source repeats, and repeating a small source for many epochs can overfit it. Tune mixtures on small models with short runs, check that the ranking holds at a second size, and log per-source loss so you can see which part of the mixture a change helped or hurt.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Data filtering and deduplication experiments
A data filter or deduplication step is a hypothesis about quality, so test it like one. Train small models on filtered and unfiltered data with the same token budget, compare them on evals chosen before the run, and read samples of what was removed. Deduplication cuts memorisation and wasted compute, but an aggressive quality classifier can strip whole domains, and a filter tuned toward a benchmark's style can quietly inflate the comparison you meant to make.
Reading
- Deduplicating Training Data Makes Language Models Better (Lee et al.) arxiv.org
- The FineWeb Datasets (Penedo et al.) arxiv.org
- DataComp-LM (Li et al.) arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Weight averaging and EMA
Averaging weights smooths out the noise of the last steps. An exponential moving average keeps a running copy of the weights updated every step, and checkpoint averaging takes the mean of several saved checkpoints; both often evaluate better than the raw final weights, especially before the learning rate has fully decayed. Keep the average in fp32, record which weights each eval used, and never compare an averaged model with a raw one as if the method made the difference.
Reading
- PyTorch: weight averaging (SWA and EMA) pytorch.org
- Averaging Weights Leads to Wider Optima (SWA) arxiv.org
- Early Weight Averaging Meets High Learning Rates (LAWA) arxiv.org
- Model Soups (Wortsman et al.) arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
-
Phase 6 · Debugging training runs
-
Diagnosing a failing training run
Debug a failing run by narrowing, not guessing. Reproduce the failure from the last good checkpoint with more logging, decide whether it is the data, the optimisation or the code by swapping one at a time for a known good version, then shrink the setup (fewer GPUs, a smaller model, fewer steps) until it fails fast. Lowering the learning rate or clamping NaNs can hide the cause without removing it, and the model may already be damaged.
Reading
- A Recipe for Training Neural Networks (Karpathy) karpathy.github.io
- PyTorch autograd anomaly detection pytorch.org
- Machine Learning Engineering: debugging (Bekman) github.com
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
Sanity checks before a real run
Before any real run, do the cheap checks that catch most bugs. A fresh language model's first loss should be near the log of the vocabulary size; a tiny model should drive the loss on a single batch close to zero; and loss should fall on a short run with the real data pipeline. Decode a batch back to text and read it. If a sanity check fails, no amount of scale will fix it, and each one takes minutes.
Reading
- A Recipe for Training Neural Networks (Karpathy) karpathy.github.io
- PyTorch Lightning: debugging basics (overfit batches) lightning.ai
- Google Research: Deep Learning Tuning Playbook github.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Reading loss curves
A loss curve is a diagnostic. A long flat start can mean a learning rate that is too low or a broken signal; training loss rising steadily means divergence; sudden drops often line up with schedule changes or new data; and a growing gap between training and held-out loss means overfitting or a data mismatch. Plot against tokens rather than steps when batch sizes differ, use a log axis for the tail, and smooth lightly so you do not hide the spikes that matter.
Reading
- Google Research: Deep Learning Tuning Playbook github.com
- A Recipe for Training Neural Networks (Karpathy) karpathy.github.io
- Weights & Biases: experiment tracking docs.wandb.ai
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Loss spikes and divergence
Large transformers can spike or diverge even when small ones train smoothly. Common causes are attention logits growing until softmax saturates, output logits drifting large, and a bad batch meeting a high learning rate. Fixes that target a cause include normalising queries and keys (QK-norm), a small z-loss on the softmax normaliser, gradient clipping, and checking Adam's epsilon and beta2. Reproduce an instability on a small model with a raised learning rate, where fixes are cheap to test.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Monitoring gradients and activations
Loss tells you something is wrong late; per-layer statistics tell you early. Log the gradient norm overall and per layer, the ratio of each update to the weights it changes (Karpathy's rule of thumb is around 1e-3), activation norms and maximum values, and attention entropy. A single layer whose numbers drift away from the rest usually points to the cause of a later spike. Sample these every few hundred steps so logging does not slow the run.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Precision and overflow bugs
Low precision loses information in predictable places. bf16 keeps fp32's range but only about three significant decimal digits, so long sums, softmax normalisers, losses and optimizer state should stay in fp32; fp16 has more precision but a narrow range, so it needs loss scaling to stop small gradients underflowing to zero. A bug that appears only at large batch, long sequence or great depth often comes from an accumulation done in low precision.
Reading
- PyTorch: numerical accuracy pytorch.org
- PyTorch Automatic Mixed Precision pytorch.org
- Mixed Precision Training (Micikevicius et al.) arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Data bugs that look like model bugs
Many model bugs are data bugs. Padding or prompt tokens counted in the loss, labels shifted by the wrong offset, the same shard read twice, a shuffle that leaves sources in long blocks, or eval data inside the training set all train without error. Decode real batches back to text, check token counts per source against what you expected, and hash eval examples against training shards before trusting a result that looks too good.
Reading
- A Recipe for Training Neural Networks (Karpathy) karpathy.github.io
- PyTorch: CrossEntropyLoss (ignore_index) pytorch.org
- Deduplicating Training Data Makes Language Models Better (Lee et al.) arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Bisecting a regression
When a metric gets worse and nobody knows why, a golden run helps: a short, fixed config whose loss curve is saved. Rerun it at the last good commit and the current one to confirm the regression, then let git bisect choose the commits to test, using the golden run's loss at a fixed step as the pass test. Check that the environment did not change too, because a library upgrade can produce the same symptoms as a code change.
Reading
- Git: git-bisect git-scm.com
- pytest documentation docs.pytest.org
- Stas Bekman: Machine Learning Engineering (open book) github.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
-
Phase 7 · Experiment design and infrastructure
-
Experiment design
A clean comparison changes one thing. Hold code version, data, compute and evaluation fixed, vary only the factor under test, and run more than one seed per arm so you know the noise floor. Rerun the baseline on the current stack rather than reusing a number from last month, because library and data drift would become part of your effect. Write the run spec (question, arms, metric, seeds, decision rule) before launch, while mistakes are still cheap to fix.
Reading
- A Recipe for Training Neural Networks (Karpathy) karpathy.github.io
- Google Research: Deep Learning Tuning Playbook github.com
- Deep RL that Matters (variance in results) arxiv.org
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
Baselines run in the same harness
A new method looks better against a weak baseline, so the baseline deserves the same care. Run it in your harness, on the same data, token budget and eval, and tune its learning rate and schedule as hard as the method's; many published gains shrink when the baseline is tuned properly. If the method gets extra compute or parameters, give the baseline a matched version, or state clearly that the comparison is not matched.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Experiment tracking
A number without provenance cannot be reproduced. Log every run's commit and uncommitted diff, resolved config, data version, seeds, environment and metrics to a tracker at launch, not after the run starts looking interesting. Link checkpoints and eval outputs to the run that made them, and name and tag runs so a sweep of thousands stays searchable. A spreadsheet of final numbers loses the context you will need when someone asks how a result was produced.
Reading
- Weights & Biases: experiment tracking docs.wandb.ai
- Weights & Biases quickstart docs.wandb.ai
- MLflow documentation mlflow.org
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
Estimating compute before you launch
Estimate before you launch. Training a dense transformer costs about 6 FLOPs per parameter per token (2 forward, 4 backward), so a 1B model on 20B tokens needs about 1.2e20 FLOPs; divide by the hardware's peak times a realistic utilisation to get GPU-hours. Do the same for memory: weights, gradients and optimizer state cost a fixed number of bytes per parameter before activations. If the estimate does not fit the budget, change the plan before you queue the job.
Reading
- EleutherAI: Transformer Math 101 blog.eleuther.ai
- Scaling Laws for Neural Language Models (Kaplan et al.) arxiv.org
- How to Scale Your Model (JAX scaling book) jax-ml.github.io
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Spending a compute budget on a sweep
With a fixed budget, the goal is information per GPU-hour. Screen a large search space with cheap proxies (smaller models, data subsets, shorter schedules), stop clearly losing runs early, and spend full-length runs only on the survivors. Know where proxies fail: a setting that wins small can lose at scale, especially learning rate and anything tied to width. Balance new configurations against repeat seeds, because a winner chosen from one seed each may simply be the luckiest.
Reading
- Weights & Biases Sweeps docs.wandb.ai
- Hyperband: bandit-based hyperparameter optimization arxiv.org
- Google Research: Deep Learning Tuning Playbook github.com
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
Hyperparameter search methods
Pick the search method to fit the question. Grid search is clear for one or two knobs but wastes trials when only one of them matters; random search covers the important dimensions better for the same budget; Bayesian methods help when trials are expensive and the space is smooth; and successive halving (Hyperband, ASHA) kills weak trials early. Search learning rate and weight decay on a log scale, and always report how many trials the winner was chosen from.
Reading
- Random Search for Hyper-Parameter Optimization (Bergstra, Bengio) jmlr.org
- A System for Massively Parallel Hyperparameter Tuning (ASHA) arxiv.org
- Optuna documentation optuna.readthedocs.io
- Google Research: Deep Learning Tuning Playbook github.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Hyperparameter transfer across scale
Under standard parameterisation the best learning rate shifts as a model gets wider, so values tuned on a small model are wrong for the large one. The maximal update parameterisation (muP) rescales initialisation, learning rates and output multipliers per layer so the optimum stays roughly fixed across width, letting you tune small and transfer. Implement it exactly, including the attention scale and output layer, and check it by sweeping learning rate at two widths and confirming the optima line up.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Scaling ladders
A scaling ladder is a set of small runs at several sizes, each trained compute-efficiently, used to predict a larger run before paying for it. Fit loss against compute on log axes, check that the fit predicts a held-out rung, and compare methods by their whole ladder rather than at one size. Watch for the line bending: a change that helps small models can stop helping, and downstream evals are noisier and less smooth than loss.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
Chapter 7 lab
Write the instruction for an agent that audits a comparison for confounds
A prompt lab that closes the chapter: you write the instruction, and it is graded on a rubric.
Start the lab -
-
Phase 8 · Evaluation and analysis for research
-
Benchmarks
A benchmark score means little until you know what produced it. Check for contamination (the test set or close copies in the training data), whether the benchmark measures the capability you claim, and whether your protocol matches the models you compare against: prompt format, few-shot examples, decoding settings and answer extraction. When the top models all score inside the label noise, the benchmark is saturated and further gains there are not evidence of progress.
Reading
- EleutherAI LM Evaluation Harness github.com
- Lessons from the Trenches on Reproducible Evaluation of LMs arxiv.org
- Documenting large webtext corpora (C4) arxiv.org
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
Building an eval harness
Research evals are code and deserve the same care as training code. A good harness pins each task's version, prompt template and few-shot examples, fixes decoding settings, caches model outputs so rescoring is free, and writes per-example results rather than only the average, so you can read failures and compute intervals. Run it on a released model with a known score before trusting it on yours, and log the harness version with every number it produces.
Reading
- EleutherAI LM Evaluation Harness github.com
- Inspect (UK AI Security Institute) documentation inspect.aisi.org.uk
- Lessons from the Trenches on Reproducible Evaluation of LMs arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Likelihood and generative evals
There are two ways to score a model on a multiple-choice task. Likelihood scoring compares the log-probability the model gives each answer and needs no generation; generative scoring lets the model write an answer and parses it. They can rank models differently, and small or base models often look far better under likelihood scoring. Decide deliberately whether to normalise by answer length, and report the method, because the choice can move a number more than the change you are testing.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Evals during training
Evals during training tell you whether a run is on track before it ends. Score checkpoints on a schedule with a fast suite, choose evals that give signal at your scale (held-out loss and likelihood-scored tasks move smoothly, while many generative benchmarks sit at chance for small models), and measure checkpoint-to-checkpoint noise so a dip is not read as a trend. Keep the in-loop suite small enough that it never slows the run it is watching.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Sampling-based metrics and pass@k
pass@k is the chance that at least one of k samples solves a task. Estimate it by drawing n samples, with n larger than k, counting the c that pass, and using the unbiased formula, rather than drawing exactly k samples, which gives a high-variance estimate. Temperature changes the result, so report it alongside k and n, and give an interval over tasks. A method that raises pass@100 may not raise pass@1, which is what a single user actually experiences.
Reading
- Evaluating Large Language Models Trained on Code (Chen et al., pass@k) arxiv.org
- Adding Error Bars to Evals (Miller) arxiv.org
- OpenAI: human-eval github.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Model-graded evals
A model grader can score open-ended outputs at scale, but it is a measuring instrument that needs calibrating. Check it against human labels on a sample, look for known biases (favouring the first option shown, longer answers or its own outputs), randomise answer order, and keep the grader model and prompt fixed across every run you compare. If the grader changes, earlier numbers are no longer comparable and have to be rescored.
Reading
- Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena arxiv.org
- Large Language Models are not Fair Evaluators (Wang et al.) arxiv.org
- Inspect: scorers inspect.aisi.org.uk
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Ablations
When a method bundles several changes, only ablations say which ones matter. Start from one base, remove or toggle one component at a time, and keep everything else fixed, including token budget and tuned settings; then test the combinations your budget allows, since parts can interact. Spend scarce runs on the components most likely to carry the gain, and report ablations that show nothing, because a part that does not help should be removed.
Reading
- What Matters in On-Policy RL? A large-scale study arxiv.org
- Do Transformer Modifications Transfer? (Narang et al.) arxiv.org
- A Recipe for Training Neural Networks (Karpathy) karpathy.github.io
- arXiv cs.LG recent listings arxiv.org
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
Statistical rigor
One run per arm has no estimate of noise, so a small gap is not a result. Run several seeds per arm, report the mean with an interval, and pair the comparison where you can (same seeds, data order and eval examples) so shared noise cancels. A shaded band means something specific, standard deviation, standard error or a confidence interval, so say which. Picking the best of many sweep configurations overstates it; confirm the winner on fresh seeds.
Reading
- Deep RL that Matters (reporting variance) arxiv.org
- Show Your Work: improved reporting of results arxiv.org
- Adding Error Bars to Evals (Miller) arxiv.org
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
Writing up an experiment
An experiment is not finished until someone else can act on it. State the question, the setup (with links to runs and configs), the numbers with uncertainty, what you conclude and how sure you are. Report null and negative results as plainly as wins: the team needs to know which idea did not work and at what scale it was tested. Lead with the figure that answers the question, and cut any claim the data does not back.
Reading
- Distill: Research Debt distill.pub
- NeurIPS paper checklist neurips.cc
- Show Your Work: improved reporting of results arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
Chapter 8 lab
Write the instruction for drafting an ablation section whose headline component did nothing
A prompt lab that closes the chapter: you write the instruction, and it is graded on a rubric.
Start the lab -
-
Phase 9 · Distributed training
-
Scaling out without changing the result
Data-parallel training done correctly gives the same model as one GPU seeing the same tokens in the same batches, so an accuracy gap after scaling out is a bug or a changed hyperparameter, not a cost of scale. Check the global batch (it grew with the number of ranks, so learning rate and warmup may need retuning), that every rank reads different data, that gradients are averaged rather than summed, and that the loss is reduced the same way as before.
Reading
- PyTorch DistributedDataParallel notes pytorch.org
- Accurate, Large Minibatch SGD (linear LR scaling) arxiv.org
- Hugging Face: The Ultra-Scale Playbook huggingface.co
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
Collectives and what they cost
Distributed training is built from a few collective operations. All-reduce sums a tensor across ranks and gives everyone the result; reduce-scatter sums and leaves each rank one slice; all-gather collects slices into the whole; all-to-all swaps pieces between every pair of ranks. Know which ones your parallelism issues each step and how large they are, because communication time grows with bytes moved and the slowest link, and overlapping it with compute is often the biggest speedup available.
Reading
- NVIDIA NCCL: collective operations docs.nvidia.com
- PyTorch: torch.distributed pytorch.org
- How to Scale Your Model (JAX scaling book) jax-ml.github.io
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Sharded data parallelism: FSDP and ZeRO
Plain data parallelism keeps a full copy of weights, gradients and optimizer state on every GPU. Sharded data parallelism (ZeRO, FSDP) splits them across ranks and gathers each layer's weights just before use, trading extra communication for memory: sharding optimizer state saves the most for the least cost, then gradients, then parameters. Choose the sharding group (all ranks or within a node) by where your links are fast, and check that results match unsharded training.
Reading
- ZeRO: Memory Optimizations Toward Training Trillion Parameter Models arxiv.org
- PyTorch FSDP: experiences on scaling fully sharded data parallel arxiv.org
- PyTorch: getting started with FSDP pytorch.org
- DeepSpeed: ZeRO tutorial deepspeed.ai
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Tensor parallelism
Tensor parallelism splits a layer's weight matrices across GPUs so each computes part of every matrix multiply. In a transformer MLP the first matrix is split by columns and the second by rows, so the block needs one all-reduce in the forward pass and one in the backward; attention splits by heads. It communicates every layer, so it belongs inside a node on fast links, and it changes the order of sums slightly, so parity-test it against the unsplit model.
Reading
- Megatron-LM: training multi-billion parameter models (Shoeybi et al.) arxiv.org
- PyTorch: tensor parallel tutorial pytorch.org
- Hugging Face: The Ultra-Scale Playbook huggingface.co
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Pipeline parallelism
Pipeline parallelism puts groups of layers on different GPUs and streams micro-batches through them. The bubble, the time stages sit idle while the pipeline fills and drains, shrinks as the number of micro-batches grows relative to the number of stages, and interleaved schedules cut it further at the cost of more communication. It needs only point-to-point sends between neighbouring stages, so it suits slower links between nodes, but balancing layers across stages is your job.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Expert parallelism
Expert parallelism places different experts of a mixture-of-experts layer on different GPUs. Each step, tokens are sent to the GPUs holding their chosen experts and the results are sent back, using all-to-all communication whose cost depends on how evenly the router spreads the load. One overloaded expert slows every rank, so expert placement, capacity limits and load balance are performance settings as much as modelling ones, and you should log them per step.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Context parallelism for long sequences
At long sequence lengths, activations rather than weights run out of memory, because per-token activations and attention grow with length. Context parallelism splits the sequence across GPUs, and ring attention passes key and value blocks around the ring so each GPU attends over the whole sequence while holding only its share. Causal masking makes a naive split unbalanced, since later chunks attend to more tokens, so implementations reorder chunks to even out the work.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Choosing a parallelism layout
Real runs combine parallelisms: tensor parallelism inside a node, pipeline parallelism across nodes when the model is too deep for one, expert parallelism for MoE layers, and sharded data parallelism over everything else. Start from memory (does one replica fit?), then communication (put the chattiest split on the fastest link), and test a few layouts on a short run, measuring tokens per second per GPU. The best layout shifts with model size, sequence length and cluster, so do not copy one blindly.
Reading
- Hugging Face: The Ultra-Scale Playbook huggingface.co
- How to Scale Your Model (JAX scaling book) jax-ml.github.io
- Efficient Large-Scale LM Training on GPU Clusters (Narayanan et al.) arxiv.org
- PyTorch: torchtitan github.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
-
Phase 10 · Performance and efficiency
-
Profile before you optimise
Optimise from a profile, not a hunch. Capture a trace of a few steady-state steps, find where time goes (data waits, compute, communication, host overhead or idle gaps), and apply the change that targets that bottleneck. Make one change at a time, measure throughput again, and confirm the loss curve matches the unoptimised run, because some speedups change the numerics. Stacking every trick at once hides which one helped and whether another hurt quality.
Reading
- PyTorch Profiler recipe pytorch.org
- PyTorch performance tuning guide pytorch.org
- PyTorch Automatic Mixed Precision pytorch.org
- Making Deep Learning Go Brrrr From First Principles (He) horace.io
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
Throughput and MFU
Tokens per second is the number you watch; model FLOPs utilisation (MFU) tells you how good it is. MFU is the FLOPs the model needs per second (about 6 times parameters times tokens per second, for training) divided by the hardware's peak, and it ignores recomputation, so it compares fairly across codebases. Published large dense runs report roughly 35 to 50 percent. If you sit far below what others report for similar hardware and size, profile before scaling up.
Reading
- PaLM: Scaling Language Modeling with Pathways (MFU definition) arxiv.org
- EleutherAI: Transformer Math 101 blog.eleuther.ai
- How to Scale Your Model (JAX scaling book) jax-ml.github.io
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
The memory budget of training
Training memory is mostly arithmetic you can do before launch. With mixed precision and Adam, each parameter costs about 16 bytes: 2 for bf16 weights, 2 for gradients and 12 for the fp32 master weights and two optimizer moments, before any activations. Activations grow with batch, sequence length, width and depth and often dominate. Work out both, then take a memory snapshot of a real step to find what you missed, such as temporary buffers and fragmentation.
Reading
- ZeRO: Memory Optimizations Toward Training Trillion Parameter Models arxiv.org
- EleutherAI: Transformer Math 101 blog.eleuther.ai
- PyTorch: understanding CUDA memory usage pytorch.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Mixed precision training
Mixed precision runs the heavy matrix multiplies in a 16-bit format and keeps what needs precision in fp32: master weights, optimizer state, reductions and the loss. bf16 has the same range as fp32 and usually needs no loss scaling; fp16 needs loss scaling so small gradients do not underflow. fp8 training goes further but needs per-tensor or finer scaling factors and care with outliers. After any precision change, compare the loss curve against a higher-precision run.
Reading
- Mixed Precision Training (Micikevicius et al.) arxiv.org
- PyTorch Automatic Mixed Precision pytorch.org
- FP8 Formats for Deep Learning (Micikevicius et al.) arxiv.org
- NVIDIA Transformer Engine (fp8 training) github.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Activation checkpointing
Activation checkpointing saves memory by keeping only some activations in the forward pass and recomputing the rest during backward. Recomputing every block costs roughly one extra forward pass, about a third more compute, so checkpoint selectively: recompute cheap operations with large outputs, such as attention internals and elementwise ops, and keep the results of expensive matrix multiplies. Use it when memory, not compute, is what stops you raising batch size or sequence length.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Compilers: torch.compile and XLA
A compiler captures your model as a graph and fuses and schedules its operations, often speeding up a step without code changes. torch.compile traces Python, falls back at graph breaks (data-dependent control flow, unsupported calls) and recompiles when shapes or guards change; JAX with XLA compiles the whole function up front. Check the logs for graph breaks and recompiles, warm up before timing, and parity-test outputs, since fusion can change rounding.
Reading
- PyTorch: introduction to torch.compile pytorch.org
- JAX: just-in-time compilation docs.jax.dev
- OpenXLA: XLA documentation openxla.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Fused kernels and FlashAttention
Many operations in a model are memory-bound: the GPU spends more time moving data than computing. Fusing them into one kernel cuts memory traffic, which is why fused attention such as FlashAttention is faster and lighter: it computes attention in tiles without ever writing out the full score matrix. Use your framework's fused attention path, check which backend it actually picked, and confirm your mask and dropout settings are supported rather than silently falling back to a slow path.
Reading
- FlashAttention (Dao et al.) arxiv.org
- FlashAttention-2 (Dao) arxiv.org
- PyTorch: scaled_dot_product_attention pytorch.org
- Making Deep Learning Go Brrrr From First Principles (He) horace.io
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
When to write a custom kernel
Write a custom kernel only when a profile shows that an operation your research needs is slow and no library or compiler covers it. Triton lets you write GPU kernels in Python at the level of blocks rather than threads, which is usually enough for a fused or unusual operation. Keep the slow reference, test forward and backward against it across shapes and dtypes, and register the kernel as a custom op so autograd and the compiler can use it.
Reading
- Triton tutorials triton-lang.org
- PyTorch: custom operators pytorch.org
- PyTorch: extending with custom autograd functions pytorch.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
-
Phase 11 · Post-training and RL experiments
-
Supervised fine-tuning code
Supervised fine-tuning on conversations looks like pretraining with two differences that are easy to get wrong. The chat template must match exactly what the model will see at inference, including special tokens and the end-of-turn marker, and the loss should usually cover only the assistant's tokens, with the prompt masked out. Packing conversations needs per-conversation attention masks. Decode a batch with its loss mask shown before the first run.
Reading
- Hugging Face: chat templates huggingface.co
- Hugging Face TRL: SFT trainer huggingface.co
- Training language models to follow instructions (InstructGPT) arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Preference optimisation in code
Direct preference methods such as DPO train on pairs of a chosen and a rejected response, using log-probabilities from both the model being trained and a frozen reference model. Compute those as sums over response tokens only, with the same template and masking for both models, and precompute the reference log-probs once to save memory. Log chosen and rejected log-probs separately: a falling chosen likelihood is a common failure the loss alone hides.
Reading
- Direct Preference Optimization (Rafailov et al.) arxiv.org
- Hugging Face TRL: DPO trainer huggingface.co
- Tulu 3: pushing frontiers in open post-training arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
The RL loop for language models
RL for language models repeats a loop: generate rollouts from the current policy, score them with a reward, compute advantages, update the policy, and push the new weights to the generator. Generation usually dominates the time, so it runs on a fast inference engine, which means two copies of the model whose weights and numerics must stay in sync. Log reward, response length, entropy and KL to the reference, and measure any gap between generator and trainer log-probs.
Reading
- Proximal Policy Optimization Algorithms (Schulman et al.) arxiv.org
- DeepSeekMath (introduces GRPO) arxiv.org
- HybridFlow: a flexible RLHF framework (verl) arxiv.org
- verl on GitHub github.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Rewards and verifiers as code
In RL the reward function is the specification, and the policy will find every gap in it. Verifiable rewards (unit tests, exact answers, checkers) are the most robust, but they still need tests of their own: correct answers must pass, near misses must fail, and malformed output must neither crash the grader nor score. Read samples from the highest-reward rollouts regularly, because reward hacking first shows up as behaviour that scores well and looks wrong.
Reading
- Lilian Weng: Reward Hacking in Reinforcement Learning lilianweng.github.io
- Tulu 3 (RL with verifiable rewards) arxiv.org
- DeepSeek-R1: incentivizing reasoning via RL arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Environments for agentic RL
Training agents with RL needs environments: tasks with tools, state and a grader, run in sandboxes. A good environment resets to a known state, is deterministic given a seed, isolates each episode from the others and from the host, and records full transcripts. Running thousands at once makes environment latency and flakiness a training problem, so track environment failures separately from model failures and never let an infrastructure error count as a zero reward.
Reading
- SWE-bench (Jimenez et al.) arxiv.org
- Inspect: sandboxing inspect.aisi.org.uk
- Gymnasium documentation gymnasium.farama.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
LoRA as a cheap experiment
Low-rank adapters train a small update on top of frozen weights, so an experiment costs a fraction of full fine-tuning in memory and storage. That makes LoRA a fast way to run post-training ablations, but its conclusions can differ from full fine-tuning: the best learning rate is usually much higher, a low rank can limit what is learned, and which layers get adapters matters. Confirm an important LoRA result with a full fine-tune before it decides the plan.
Reading
- LoRA: Low-Rank Adaptation of Large Language Models arxiv.org
- LoRA Learns Less and Forgets Less (Biderman et al.) arxiv.org
- Hugging Face PEFT documentation huggingface.co
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
-
Phase 12 · Research to production and the craft
-
Coding agents in research engineering
AI coding agents can write a training script, a sweep launcher or a new layer quickly, and they can make research-code mistakes just as quickly: wrong axes, missing masks, silently changed defaults. Treat their output like a new colleague's: give them the tests, the reference implementation and the codebase's conventions, require parity tests to pass, and read every diff that touches the model, the loss or the data path. Speed only helps if the result is still right.
Reading
- Anthropic: Claude Code best practices anthropic.com
- METR: AI tools and experienced open-source developer productivity metr.org
- SWE-bench (Jimenez et al.) arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Working with research scientists
You and the scientists you support share one goal: correct answers to research questions, fast. Agree what each experiment is for before building it, send short regular updates with links to runs, and say early when a result is not ready to present, along with what is missing. Own the shared code: review changes, keep the main branch working and write down how things work, so the team is never blocked on one person.
Reading
- Hamming: You and Your Research cs.virginia.edu
- Distill: Research Debt distill.pub
- The Good Research Code Handbook (Mineault) goodresearch.dev
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Securing models, data and experiments
Research artefacts are valuable and some are hazardous. Restrict who can read frontier weights and unreleased datasets, keep credentials out of code and logs, and run model-written code (in RL environments, agent evals or code-generation tasks) in sandboxes with no network or secrets by default. If an experiment surfaces a capability that could cause harm, follow your organisation's reporting process before sharing the result widely.
Reading
- RAND: Securing AI Model Weights rand.org
- NIST SP 800-218A: secure development for generative AI csrc.nist.gov
- gVisor documentation gvisor.dev
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Releasing research code and models
Releasing code or a model turns your research into something others depend on. Ship the exact configs and commands behind the reported numbers, pinned dependencies, a model card covering training data, intended use, evaluations and known limits, and a licence chosen deliberately, and separately, for the code, the weights and the data. Before release, rerun the reported results from the public package on a clean machine.
Reading
- Model Cards for Model Reporting (Mitchell et al.) arxiv.org
- Hugging Face: model cards huggingface.co
- Choose an open source license choosealicense.com
- NeurIPS paper checklist neurips.cc
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Inference for research models
Research needs a lot of sampling: evals, synthetic data and RL rollouts. A serving engine with continuous batching and paged attention generates far faster than a training-code loop, but it is a second implementation of your model. Check that its log-probs match your training code on the same inputs, that sampling settings and stop tokens are the ones you meant, and that the new checkpoint actually loaded, before trusting anything it generates.
Reading
- vLLM documentation docs.vllm.ai
- Efficient Memory Management for LLM Serving with PagedAttention arxiv.org
- Hugging Face: generation strategies huggingface.co
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Research to product
A research model that wins offline still has to win on real traffic. Before launch, check that every feature or piece of context it uses exists at serving time, measure latency and cost against the product's budget, and evaluate it in shadow mode on production-like traffic before users see it. Hand the owning team the model, its eval suite, known failure cases, monitoring and a rollback plan. Offline numbers usually overstate live gains, so plan for the gap.
Reading
- Hidden Technical Debt in ML Systems papers.nips.cc
- Rules of Machine Learning (Zinkevich) developers.google.com
- The ML Test Score: a rubric for production readiness research.google
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
Chapter 12 lab
Write the instruction for planning a shadow evaluation before launch
A prompt lab that closes the chapter: you write the instruction, and it is graded on a rubric.
Start the lab -
Practise the AI Research Engineer roadmap
285 questions, each graded on the server out of 100. Free · no card.
Other AI careers
- Agent Engineer
- AI Alignment Researcher
- AI Data Engineer
- AI Engineer
- AI Evals Engineer
- AI Governance Analyst
- AI Infrastructure Engineer
- AI Integration Engineer
- AI Product Manager
- AI Red Team Specialist
- AI Reliability Engineer
- AI Safety Engineer
- AI Security Engineer
- AI Solutions Architect
- AI Strategist
- Computer Vision Engineer
- Context Engineer
- Conversational AI Designer
- Forward-Deployed Engineer
- Inference Optimization Engineer
- ML Engineer
- Multimodal AI Engineer
- Post-Training Engineer