Decode-Step Attention Shapes
A decoder-only model has d_model = 512 and h = 8 heads, so d_k = d_v = 64. It is generating token 1025, with 1024 tokens already in the KV cache. Inside one head, the query for the new token is Q with shape (1, 64), and the cached keys and values are K and V, each (1024, 64).
Work out the shape of Q @ K.T, the axis softmax normalizes over, and the shape of the head's output.
Sign in to answer questions and track your progress
Sign In