Rúben GalvãoThe Rabbit Hole

The Rabbit Hole / AI and machine learning / Language models / Giving tokens a sense of position

Partial RoPE: rotating only part of each head

If position helps attention, why give it to only part of each head? What might the remaining coordinates be useful for?

A head is looking for an earlier mention of “Alice”. It might be in the last sentence, or a thousand tokens back.

Distance changes every match

With RoPE, every pair of query and key coordinates turns with position. So the same word, seen from further away, lines up less well with itself.

With full RoPE, the same word matches itself less the further away it isA curve of the match between a query and a key with the same content, rotated by RoPE, against the distance between them. It starts at 1, falls to about 0.28 at 1,000 tokens and wanders near zero by 4,000.0.00.51.001,0002,0003,0004,000tokens apartmatch
The same word, matched with itself further and further back. With every pair rotated, the match falls to 0.28 at 1,000 tokens apart and keeps wobbling.

That is what we want for position. But this head only cares whether it is the same word. Far away, the rotation hides a match that should be perfect.

Leave some pairs still

What if only some of the pairs turned? The rest would compare pure content, the same at any distance, while the rotated pairs still say how far apart the tokens are.

Leave some pairs unrotated

Interactive

Grey: every pair rotated. Green: the share you choose.

0.00.51.001,0002,0003,0004,000tokens apartmatchnever below 0.50

Rotate half the pairs, and a match can never fall below half, however far back it is. This is partial RoPE: each head keeps a share of its coordinates free of position.

Models choose the share

GLM-4.5 and MiniMax-M2 rotate half of each head. Qwen3-Next rotates 64 of its 256 coordinates, a quarter.

Latent attention does the same for another reason. Its compressed keys cannot be rotated per position, so a small separate part of each key carries the rotation. DeepSeek-V4 rotates only the last 64 of 512.

If some coordinates can do without position, could a whole layer? Next, NoPE.

Sources and assumptions

The charts use one 64-wide head (32 pairs) with RoPE’s usual base of 10,000. The query and key are the same vector, with its content spread evenly over the pairs, so their match at a given distance is the average of cos(distance × speed) over the rotated pairs, plus one for every pair left still, divided by the number of pairs. As in implementations, the rotated pairs’ speeds are spread over the rotated width only. Each plotted point averages the match over the next 50 tokens, because the fastest pairs swing on every token; the numbers in the captions and notes are unsmoothed. Real heads need not spread content evenly; a head can also put a match in the slowest pairs, which barely turn.

← Browse all subjectsBack to the beginning ↑