27/30
Part 6 of 6 · What interviewers ask nextLearn and do
New tokens sit at position past, not at 0
Six tokens are cached at positions 0 to 5, and one new token arrives:
| Positions | pos_emb row for the new token | |
|---|---|---|
| right | torch.arange(past, past + T) | 6 |
| wrong | torch.arange(T) | 0 |
The new tokens sit at positions past onward, so they need pos_emb rows past onward. Embed them at torch.arange(T), and every decode step lands at position 0.
The first new token still comes out right, because it comes from the prefill, which starts at 0 with an empty cache. Every one after it is computed at the wrong position.
Where should forward_cached read past, the cached length, from?
Pick an answer above to see the rest
The window is full, and the loop crops a off the front to make room for e. Can you keep the cached keys and values of b, c and d?
Pick an answer above to see the rest
A 4-token window and a 2-token prompt. The cache is full after step 3. What does step 4 feed the model?
Pick an answer above to see the rest