Skip to content

Commit

Permalink
Implement feedback on RoPE equation implementation
Browse files Browse the repository at this point in the history
Adjusting equation for RoPE, as per discussion:
ReaLLMASIC#35 (comment)
  • Loading branch information
gkielian committed Nov 16, 2023
1 parent 292a365 commit 7e86704
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions model.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ def __init__(self, config):
self.dim = config.n_embd

# Register frequencies directly as buffers
self.register_buffer('freq_left', 1.0 / (10000 ** (torch.arange(0, self.dim//2).float() / self.dim//2)))
self.register_buffer('freq_right', 1.0 / (10000 ** (torch.arange(0, self.dim//2).float() / self.dim//2)))
self.register_buffer('freq_left', (10000 ** (torch.arange(0, self.dim//2).float() / self.dim//2)))
self.register_buffer('freq_right',(10000 ** (torch.arange(0, self.dim//2).float() / self.dim//2)))

def forward(self, x):
seq_len = x.shape[-2]
Expand Down Expand Up @@ -187,8 +187,8 @@ def __init__(self, config):
self.dim = config.n_embd

# Generate freqs of size n rather than full dim
self.register_buffer('freq_left', 1.0 / (10000 ** (torch.arange(0, self.n//2).float() / self.n//2)))
self.register_buffer('freq_right', 1.0 / (10000 ** (torch.arange(0, self.n//2).float() / self.n//2)))
self.register_buffer('freq_left', (10000 ** (torch.arange(0, self.n//2).float() / self.n//2)))
self.register_buffer('freq_right', (10000 ** (torch.arange(0, self.n//2).float() / self.n//2)))

def forward(self, x):
# Step 1: Get the input tensor shape
Expand Down

0 comments on commit 7e86704

Please sign in to comment.