MCPcopy
hub / github.com/policy-gradient/GRPO-Zero / rotate_half

Function rotate_half

qwen2_model.py:53–57  ·  view source on GitHub ↗

Rotates half the hidden dims of the input.

(x)

Source from the content-addressed store, hash-verified

51
52
53def rotate_half(x):
54 """Rotates half the hidden dims of the input."""
55 x1 = x[..., : x.shape[-1] // 2]
56 x2 = x[..., x.shape[-1] // 2 :]
57 return torch.cat((-x2, x1), dim=-1)
58
59
60def apply_rotary_pos_emb(q, k, cos, sin, unsqueeze_dim=2):

Callers 1

apply_rotary_pos_embFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected