The point of RoPE is that attention scores should depend on how far apart two tokens are, not on their absolute positions. Rotating queries and keys by their own positions gives exactly that: the product of two rotations depends only on the difference of the angles.
Implement rope_dot(q, k, m, n, base), which rotates the query to position m, the key to position n, and returns their dot product.
Reuse the rotation from rope_rotate for each vector, then take a dot product.
No results yet
Run your code to check it against the examples, or submit to run every test.