Skip to content

Commit

Permalink
More concise
Browse files Browse the repository at this point in the history
  • Loading branch information
li-plus committed Feb 13, 2025
1 parent 7990710 commit 40d625d
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/transformers/models/qwen2_vl/modeling_qwen2_vl.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,8 @@ def apply_rotary_pos_emb_vision(
) -> Tuple[torch.Tensor, torch.Tensor]:
orig_q_dtype = q.dtype
orig_k_dtype = k.dtype
q = q.float()
k = k.float()
cos = cos.unsqueeze(-2)
sin = sin.unsqueeze(-2)
q, k = q.float(), k.float()
cos, sin = cos.unsqueeze(-2), sin.unsqueeze(-2)
q_embed = (q * cos) + (rotate_half(q) * sin)
k_embed = (k * cos) + (rotate_half(k) * sin)
q_embed = q_embed.to(orig_q_dtype)
Expand Down

0 comments on commit 40d625d

Please sign in to comment.