Transformer Systems Lab
RoPE: what position does to an attention score
Rotary position embedding (RoPE) rotates each query and key by an angle proportional to its position. Predict whether shifting both positions by the same amount changes their score, then predict what happens when only the key moves.
What this step asks
The same query–key score, now with positions.
Step 1 scored a query against keys with a plain dot product. RoPE rotates the query and the key before that dot product, by angles set by their positions (Su et al., 2024). This step asks which part of the score still depends on position after the rotation.
Step 2 of 8
RoPE: rotate the query and key by position
The same kind of query–key score as step 1, now with positions. Which part of the score survives when both positions change?
Example
One query and one key in two dimensions, at one frequency
(R_m q)^T (R_n k)R_m rotates the query q by m·ω, its position m times the frequency ω; R_n rotates the key k by n·ω. The vectors q and k stay fixed; only the positions and the frequency change, and each rotation is small enough to check by hand.
Your prediction
Shift both positions by +3: query 2 → 5, key 0 → 3. What happens to the query–key score?
Controls
Change a setting, then predict again.
Medium (default): 0.42 rad per position, enough movement to see each change clearly.
Outline of this lesson
(R_m q)^T (R_n k)one rotated query/key pair
absolute position or the gap between positions?
what an equal shift does to the score
move m, n, the shift and the frequency
phase table and dot-product score
shown after you answer
move only the key
KV memory
Where this step sits
From the score to the cache.
Finish the equal-shift and key-only cases, then save what you found. The next step uses it: the keys stored in a KV cache are the rotated keys from this step.