From 404e177adbb6151cb2e01041394a69e9d729401b Mon Sep 17 00:00:00 2001 From: Daniel Han-Chen Date: Sat, 3 Feb 2024 02:30:47 +1100 Subject: [PATCH] Update utils.py --- unsloth/kernels/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unsloth/kernels/utils.py b/unsloth/kernels/utils.py index 775d881eea..d7e2f41faf 100644 --- a/unsloth/kernels/utils.py +++ b/unsloth/kernels/utils.py @@ -203,6 +203,7 @@ def fast_linear_forward(proj, X, temp_lora = None, out = None): # Add in LoRA weights if lora_A is not None: + dtype = X.dtype if not hasattr(lora_A, "_fast_lora_A"): lora_A._fast_lora_A = lora_A.to(dtype) lora_A._fast_lora_B = lora_B.to(dtype) @@ -211,7 +212,6 @@ def fast_linear_forward(proj, X, temp_lora = None, out = None): lora_B = lora_A._fast_lora_B out_dim = out.shape[2] - dtype = X.dtype if bsz == 1: out = out.view(out_dim) temp_lora = torch.mv(lora_A, X.ravel(), out = temp_lora)