Back to Module 2.

Problem 2.1 (Four tokens).

A completion has tokens given a prompt . Write as a sum of four conditionals. Which tokens are allowed to appear inside the conditional for ?

Problem 2.2 (What the cache stores).

The prompt has tokens and you are about to generate the next token after already generating completion tokens. Per layer, how many new query vectors and how many new key vectors does a cached step compute? What goes wrong if the rotary position of that new token is set to ?

Problem 2.3 (Compile).

You turn on torch.compile and greedy decoding, and a unit test that compares token ids to an eager run fails on a late token. Name one cause that is not “the compiler changed the model,” and name the quantity that should still match if both runs are the same function up to rounding.