Fix adapter scalar handling under torch.compile (#946)
* Fix adapter scalar handling under torch.compile * Fix instance where error could happen when merging in a lora to the base model --------- Co-authored-by: Rydén Johan <johan.ryden@bostad.uppsala.se> Co-authored-by: Jaret Burkett <jaretburkett@gmail.com>
This commit is contained in:
@@ -63,9 +63,9 @@ class LoRAModule(torch.nn.Module):
|
||||
self.lora_up = torch.nn.Linear(self.lora_dim, out_dim, bias=False)
|
||||
|
||||
if type(alpha) == torch.Tensor:
|
||||
alpha = alpha.detach().float().numpy() # without casting, bf16 causes error
|
||||
alpha = float(alpha.detach().float().item())
|
||||
alpha = self.lora_dim if alpha is None or alpha == 0 else alpha
|
||||
self.scale = alpha / self.lora_dim
|
||||
self.scale = float(alpha) / self.lora_dim
|
||||
self.register_buffer("alpha", torch.tensor(alpha)) # 定数として扱える
|
||||
|
||||
# same as microsoft's
|
||||
|
||||
Reference in New Issue
Block a user