Hands-on labs and teaching materials
Choose a question for your class or your next experiment. Open the lesson for the worked example, or download the files to try it yourself.
Which tokens can the model see?
- Calculate attention weights by hand, then change a future token.
- Change “red cat” to “blue cat” and trace where the vector for “cat” first changes.
- Measure which token an attention head reads, then zero its output and compare predictions.
- Change a masked source value and check what reaches the decoder.
- Change the fifth token and test whether the fourth position can see it.
What changes during a training step?
- Track six tokens to their assigned experts and back across two CPU ranks.
- Check a gathered loss with CPU autograd and compare a two-rank DDP update.
- Trace gradient shards and updated weights across four CPU ranks.
- Train a tiny decoder, hide its earlier tokens, and resume from a checkpoint.
- Count how domain-token exposure changes on a second pass through 80 work orders.
How much cache does a batch need?
- Fit requests of different lengths into a fixed KV memory budget.
- Measure a real decoder’s KV cache by counting its key and value tensor bytes.
- Measure the padding cost of batching a 3-token prompt with an 11-token prompt.
- Reorder six prompts and compare total padding with peak KV payload.
- Follow one decode query through a block table to the five values it reads.