Exercises — RoPE
Questions, exercises, and worked answers
Check your understanding
Consider an attention head using standard RoPE.
- Which components are rotated: Q, K, or V?
- Why does the dot product between a query and a key depend on the relative offset of their positions?
- What does — and does not — follow from the score being invariant when the same shift is added to every position?
Show the reasoning
Standard RoPE rotates queries Q and keys K after projection, not values V. For one coordinate pair, the rotations make the dot product depend on the difference between the two angles, hence on the relative offset. Common-shift invariance holds for fixed, unrotated Q/K; it does not guarantee that adding a real prefix leaves hidden states and Q/K projections unchanged. Nor does it prove reliable extrapolation to arbitrary lengths.