From 37a3036934357075d4610c30075ef9b287d8b447 Mon Sep 17 00:00:00 2001 From: ViperEkura <3081035982@qq.com> Date: Mon, 20 Jul 2026 16:23:47 +0800 Subject: [PATCH] refactor: split LoRA param init into local vars --- astrai/model/components/lora.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/astrai/model/components/lora.py b/astrai/model/components/lora.py index f7cc4a8..9c470a5 100644 --- a/astrai/model/components/lora.py +++ b/astrai/model/components/lora.py @@ -41,8 +41,10 @@ class LoRALinear(nn.Module): self.scaling = alpha / r device = self.weight.device 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)) + lora_a = torch.randn(r, self.weight.shape[1], device=device, dtype=dtype) / r + lora_b = torch.zeros(self.weight.shape[0], r, device=device, dtype=dtype) + self.lora_A = nn.Parameter(lora_a) + self.lora_B = nn.Parameter(lora_b) self._merged = False def forward(self, x):