Skip to content

Commit

Permalink
Fix dynamic RoPE (#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgaddair authored Mar 21, 2024
1 parent 9d2a106 commit 5909ea1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions server/lorax_server/utils/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,14 @@ def get_cos_sin(
"""
Return cos and sin for the asked position ids
"""

# When using dynamic position embeddings, the max sequence length might exceed
# the max position embeddings of the base model, so we need to update our
# cache during warmup.
# This should never result in a change after warmup, otherwise we break
# cuda graphs.
self._update_cos_sin_cache(dtype, position_ids.device, max_s)

cos = torch.index_select(self._cos_cached, 0, position_ids)
sin = torch.index_select(self._sin_cached, 0, position_ids)
return cos.unsqueeze(1), sin.unsqueeze(1)
Expand Down

0 comments on commit 5909ea1

Please sign in to comment.