cast around lora adapters (#613)

This commit is contained in:
Awni Hannun 2024-03-24 19:34:51 -07:00 committed by GitHub
parent 5a52899405
commit bbfcc103d7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -97,9 +97,6 @@ class LoRALinear(nn.Module):
self.lora_b = mx.zeros(shape=(r, output_dims))
def __call__(self, x):
dtype = self.linear.weight.dtype
if isinstance(self.linear, nn.QuantizedLinear):
dtype = self.linear.scales.dtype
y = self.linear(x.astype(dtype))
y = self.linear(x)
z = (self.dropout(x) @ self.lora_a) @ self.lora_b
return y + self.scale * z
return y + (self.scale * z).astype(x.dtype)