Lab: Package attention and test every claim
Module 2 · Lab · About 60 minutes · Needs: lessons 1 to 5 of this module, and Module 1's lab
What you are building
Sol 406 at Aurora Station. The five lessons wrote attention in notebooks: naive_attention with its scale switch, five masks, MultiHeadAttention, GroupedQueryAttention and the cost formulas. Each lesson ended "the module lab saves this". Today you do: one file, tinyformer/attention.py, and one test file, tests/test_m02_attention.py, holding the checks the lessons ran by hand, from agreement with PyTorch to the causal leak test and the "same as alone" packing check. Then you answer the question Hana Aoki asked in Lesson 5, "should we keep fewer key and value heads?", with a measured race on the shared reverse task, three seeds per setting, written to a run record. You commit and tag v0.2.0. Every number is labelled measured here, cited or arithmetic.