26/26
Part 4 of 4 · Prefill, decode and memoryCheck yourself
Check yourself
5 questions
  1. 1.Why does the cache hold keys and values but never queries?

  2. 2.The cache is (B, H, T_past, d) and the new keys are (B, H, 1, d). Which line grows the cache?

  3. 3.With 3 tokens cached, you feed 2 new tokens at once, so the scores are 2 by 5. Which mask is right?

  4. 4.Whenever a cache comes in, your forward returns that cache instead of the grown one. You prefill a 4-token prompt and then decode 3 tokens. What happens?

  5. 5.Llama 3 8B has 32 layers, 8 key/value heads and a head size of 128. How much KV cache does one 8,192-token sequence need in 16-bit?

Now the problem this lesson builds to: 04 KV cache for incremental decoding (PyTorch)Practice it