Practice track
Papers to code
Implement the core method of a research paper and test it against the paper's equations. 10 problems, about 295 minutes. Do them in order: each problem uses ideas from the problems before it.
- 01Focal loss
Binary and multi-class focal loss with gamma and alpha, from logits and without overflow, plus the binary gradient.
From Loss Functions
ResearchEasy20 min - 02CLIP symmetric contrastive loss
Normalize image and text embeddings, build the temperature-scaled similarity matrix, and compute the symmetric InfoNCE loss and its gradient.
ResearchMedium30 min - 03Grouped-query attention
GQA forward with H query heads and G shared key and value groups, plus mean pooling of a multi-head checkpoint into groups.
From Multi-Head Attention
ResearchMedium30 min - 04Top-k MoE gating and the Switch load-balancing loss
Route tokens to the top k experts with renormalized softmax gates, and compute the Switch Transformer auxiliary loss E times sum f_i P_i.
ResearchMedium30 min - 05Rectified flow loss and Euler sampler
Interpolate along straight paths, regress the velocity x1 - x0 with the flow matching loss, and integrate a velocity field with Euler steps.
ResearchMedium25 min - 06DDPM noise schedule, closed form noising and posterior
Build the linear beta schedule and alpha bars, sample x_t from x_0 in closed form, and compute the mean and variance of q(x_{t-1} | x_t, x_0).
ResearchMedium30 min - 07GRPO group advantages and clipped objective
Normalize rewards within each group, estimate the KL with k3, and compute the clipped GRPO objective averaged per answer over valid tokens.
From RL for Games — AlphaZero, MuZero, and the LLM-Reasoning Era
ResearchMedium30 min - 08DPO loss and implicit rewards
The direct preference optimization loss, its implicit rewards and its gradient, from policy and reference log probabilities.
ResearchMedium25 min - 09Speculative decoding: accept, reject and resample
The min(1, p/q) acceptance rule and the residual distribution that keep speculative decoding exactly equal to the target model.
ResearchHard35 min - 10Tiled attention with an online softmax
FlashAttention in numpy: a running max and a running sum over key blocks give exact attention for any block size.
ResearchHard40 min