Practice track
LLM inference
Tokenizers, sampling, beam search, the KV cache and LoRA. 11 problems, about 320 minutes. Do them in order: each problem uses ideas from the problems before it.
- 01Sweep the sampling temperature
Sweep the temperature on fixed logits, measure entropy and top 1 probability, find where entropy crosses 2 bits, and count the tokens top p keeps.
LabEasy20 min - 02LoRA linear layer
Forward pass of a linear layer with a low rank adapter, merge of the adapter into the weight, and the trainable parameter count.
ImplementEasy15 min - 03Train a character bigram language model
Train a table of next-character logits with gradient descent until the held-out negative log-likelihood beats a unigram model.
From Text Generation Before Transformers — N-gram Language Models
TrainMedium40 min - 04Fixed-capacity KV cache
Append keys and values to a preallocated cache, attend one query over the valid prefix, and reject an append past the capacity.
ImplementMedium25 min - 05Temperature, top-k and top-p sampling
Scale logits by temperature, keep the top k or the top p mass, renormalize, and draw one token with a seeded rng.
ImplementMedium30 min - 06Symmetric int8 quantization
Absmax int8 quantization with one scale per tensor and one scale per row, with dequantization and a zero-row rule.
ImplementMedium20 min - 07Sweep the quantization bit width
Sweep symmetric absmax quantization from 2 to 8 bits on weights with outliers, compare one scale per tensor with one scale per row.
LabMedium30 min - 08Read an SGLang sweep on an L4
Use real SGLang runs on an NVIDIA L4 to find the saturation point, the SLO limit, the FP8 gain and the effect of a smaller prefill chunk.
LabMedium30 min - 09BPE pair counts and merges
Count weighted adjacent pairs, pick the best pair with a fixed tie rule, merge it without overlap and train a BPE merge list.
ImplementMedium30 min - 10Beam search with EOS and length normalization
Keep the best beam_width partial sequences over a step function, finish beams at EOS, and rank them with a length penalty.
ImplementHard45 min - 11Speculative 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