devoppro commited on
Commit
0e1badc
·
verified ·
1 Parent(s): 3546054

Update modeling_modern_llm.py

Browse files
Files changed (1) hide show
  1. modeling_modern_llm.py +2 -2
modeling_modern_llm.py CHANGED
@@ -39,8 +39,8 @@ def rotate_half(x: torch.Tensor) -> torch.Tensor:
39
 
40
 
41
  def apply_rotary_pos_emb(q, k, cos, sin):
42
- cos = cos.unsqueeze(0).unsqueeze(2)
43
- sin = sin.unsqueeze(0).unsqueeze(2)
44
  q_embed = (q * cos) + (rotate_half(q) * sin)
45
  k_embed = (k * cos) + (rotate_half(k) * sin)
46
  return q_embed, k_embed
 
39
 
40
 
41
  def apply_rotary_pos_emb(q, k, cos, sin):
42
+ cos = cos.unsqueeze(0).unsqueeze(2).to(q.dtype)
43
+ sin = sin.unsqueeze(0).unsqueeze(2).to(q.dtype)
44
  q_embed = (q * cos) + (rotate_half(q) * sin)
45
  k_embed = (k * cos) + (rotate_half(k) * sin)
46
  return q_embed, k_embed