From e56eb3f4069a1d048f18ec40b0f6518fc7f6006c Mon Sep 17 00:00:00 2001 From: Daniel Han-Chen Date: Sun, 25 Feb 2024 02:26:57 +1100 Subject: [PATCH] Update gemma.py --- unsloth/models/gemma.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unsloth/models/gemma.py b/unsloth/models/gemma.py index aa87d846b0..b105d8456e 100644 --- a/unsloth/models/gemma.py +++ b/unsloth/models/gemma.py @@ -70,12 +70,12 @@ class FastGemmaRotaryEmbedding(torch.nn.Module): # x: [bs, num_attention_heads, seq_len, head_size] if self.inv_freq is None: self.inv_freq = 1.0 / ( - self.base ** (torch.arange(0, self.dim, 2, dtype=torch.int64, device=x.device).float() / self.dim) + self.base ** (torch.arange(0, self.dim, 2, dtype=torch.int64, device="cpu").float() / self.dim) ) t = torch.arange(self.max_position_embeddings, device="cpu", dtype=torch.int64).float() freqs = torch.outer(t, self.inv_freq) - emb = torch.cat((freqs, freqs), dim=-1) + emb = torch.cat((freqs, freqs), dim=-1).to("cuda") # inv_freq_expanded = self.inv_freq[None, :, None].float().expand(position_ids.shape[0], -1, 1) # position_ids_expanded = position_ids[:, None, :].float()