LLM Foundations

Build the tokenizer-to-cached-generation path, test every causal and state boundary, and connect model quality claims to evaluation and arithmetic.

5 sections · 35 units · about 135 hours

0/35
Start hereText as bytes: Unicode, encodings and normalization
1Tokenization, Corpus Identity & Packed Data0 of 7 passed · project: Tokenizer and corpus audit pack
  1. Text as bytes: Unicode, encodings and normalization3h
  2. Byte-level BPE: training, merges and tie-breaking6h
  3. Tokenizer design choices: vocabulary size, Unigram and special tokens3h
  4. A tokenizer you can trust: round trips, identity and streaming6h
  5. From documents to training examples: packing and loss masks4h
  6. Provenance, deduplication and contamination4h
  7. Filtering, mixtures and deterministic shards5h
2Decoder Transformer Mechanics0 of 7 passed · project: Tiny decoder with an independent oracle
  1. Embeddings, positions and the vocabulary axis3h
  2. Scaled dot-product attention from scratch5h
  3. Multi-head attention: split, merge and gradients4h
  4. MQA and GQA: sharing keys and values4h
  5. RoPE: positions as rotations4h
  6. The modern decoder block: residuals, RMSNorm and SwiGLU6h
  7. Assembling and verifying a decoder6h
3Causal Training, Checkpointing & Generation0 of 7 passed · project: Train, resume and sample the tiny decoder
  1. The next-token objective: shifts, masks and perplexity4h
  2. Feeding the model: batches, initialization and first steps3h
  3. AdamW, schedules and the global token batch4h
  4. Keeping training numerically healthy3h
  5. Checkpoints that really resume4h
  6. Decoding policies: from greedy to nucleus sampling4h
  7. Stopping rules and reproducible generation3h
4Evaluation, Claims & Model Arithmetic0 of 7 passed · project: Evaluation and arithmetic dossier
  1. Likelihood and perplexity, and their limits3h
  2. Task contracts and automatic metrics4h
  3. Model judges and human review3h
  4. Uncertainty, robustness and honest claims4h
  5. Contamination and memorization3h
  6. Counting parameters and FLOPs4h
  7. Memory, arithmetic intensity and reconciling estimates4h
5KV Cache, Prefill & Decode0 of 7 passed · project: Cached generation, proved and measured
  1. Why cache: recomputation in autoregressive decoding2h
  2. Building a KV cache5h
  3. Proving the cache correct4h
  4. KV memory arithmetic2h
  5. Two regimes: prefill and decode3h
  6. Measuring time to first token and inter-token latency4h
  7. Beyond one cache: prefix sharing, paging and speculation2h

Final project: Tokenizer-to-Cached-Generation Evidence Pack

Keep one small corpus, tokenizer identity, model configuration and evaluation manifest across three artifacts. The result proves the whole causal-language-model mechanism while leaving large-scale training and serving to their dedicated tracks.

  • Tokenizer and corpus audit pack - deterministic byte-safe BPE, serialized identity, adversarial properties, split-before-pack pipeline, provenance manifest, deduplication report, contamination probe and reproducible restart
  • Tiny decoder stack - blank-file embeddings, RoPE, RMSNorm, MHA plus GQA or MQA, SwiGLU, causal loss, AdamW, complete checkpoint state, four decoding policies and differential, causality, mask and resume tests
  • Evaluation, arithmetic and cached-generation dossier - versioned task and parser, raw outputs, slices and uncertainty, evaluator failure case, parameter, FLOP and memory worksheet, full-prefix cache equivalence and separate prefill and decode measurements
How it's graded · about 8 to 12 hours

One identity across artifacts

Pass: All three artifacts use one tokenizer hash, one model config and one evaluation manifest.

Great: One command checks the hashes and fails if any artifact uses a different one.

Tokenizer and corpus audit pack

Pass: The section 1 mini-project meets Pass on every criterion.

Great: It meets Strong on at least half its criteria, including reproducibility.

Tiny decoder stack

Pass: The section 2 and 3 mini-projects meet Pass, and their CS336 tests and your own tests pass in one run.

Great: Resume is exact on CPU, and the attention oracle compares gradients in float64.

Evaluation, arithmetic and cached-generation dossier

Pass: The section 4 and 5 mini-projects meet Pass.

Great: Every estimate sits next to a measurement, and cache equivalence covers MHA, GQA and MQA.

Rebuild from a clean clone

Pass: A README lists the commands that rebuild each artifact.

Great: One script rebuilds every reported number from a fresh clone on a CPU in under an hour.

Honest limits

Pass: The dossier states what the tiny model and small corpus cannot show.

Great: Each limit names the later track that addresses it.