Why is RoPE applied to queries and keys rather than to the input embeddings?

Last updated 22 November 2026

  • Rotating q and k gives (R_m q)·(R_n k) = q·R_(n-m) k, so the attention score depends only on the relative offset.

  • Rotating input embeddings would be scrambled by projections, LayerNorm and MLPs, and would only inform layer 1. Applying RoPE per layer refreshes position at each attention step.

  • Values are not rotated because position should affect where to attend, not the mixed content. This keeps the residual stream position-free and works with KV caching.

  • https://pub.towardsai.net/one-formula-to-map-the-positional-encoding-landscape-7534093c230c
  • https://www.henryfzh-note.com/llm/01-foundations/positional-encoding.html
  • https://learncodecamp.net/rope-explained/
All Transformers interview questions