11/42
Part 2 of 6 · Split the headsLearn and do
Every head runs at once, with no loop
With the heads in front, one matmul serves them all.
Start with one head of one sequence. qh[0, 0] is its 5 queries and kh[0, 0] its 5 keys, 3 numbers each.
kh = k.view(B, T, H, d).transpose(1, 2)
print((qh[0, 0] @ kh[0, 0].T).shape)
qh[0, 0] and kh[0, 0] are both (5, 3). What shape is qh[0, 0] @ kh[0, 0].T?
Pick one to see what it prints.
Pick an answer above to see the rest