Archived
ladder=head kept the rotary_dim-wide pairing: pair i = (i, i + rotary_dim/2). HF's proportional RoPE (and vLLM's Gemma4RotaryEmbedding) rotates the whole head: inv_freq has head_dim/2 entries, the first rotary_dim/2 of them 1 / theta^(2i/head_dim) and the rest zero, so pair i is (i, i + head_dim/2). On Gemma 4's global layers (128 of 512) the old pairing turned channels 64..127 and left 256..319 alone. rope in libr4d, libref and libavx now rotates the whole head under ladder=head, with the frequencies past rotary_dim/2 at zero. The rotary ladder is unchanged. op_rope_ladder and the r4d_selftest mirror check the HF pairing.