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()