Merge pull request #19 from ccx1324/lora-device-fix

fix: create LoRA parameters on base weight device instead of CPU
This commit is contained in:
ViperEkura
2026-07-20 16:14:30 +08:00
committed by GitHub
+4 -2
View File
@@ -39,8 +39,10 @@ class LoRALinear(nn.Module):
self.r = r self.r = r
self.scaling = alpha / r self.scaling = alpha / r
self.lora_A = nn.Parameter(torch.randn(r, self.weight.shape[1]) / r) device = self.weight.device
self.lora_B = nn.Parameter(torch.zeros(self.weight.shape[0], r)) dtype = self.weight.dtype
self.lora_A = nn.Parameter(torch.randn(r, self.weight.shape[1], device=device, dtype=dtype) / r)
self.lora_B = nn.Parameter(torch.zeros(self.weight.shape[0], r, device=device, dtype=dtype))
self._merged = False self._merged = False
def forward(self, x): def forward(self, x):