From 1bb1c3c2b9ea27c0a630155a99526cc805f99ca7 Mon Sep 17 00:00:00 2001 From: Daniel Han-Chen Date: Tue, 23 Jan 2024 03:36:50 +1100 Subject: [PATCH] LoRA --- unsloth/kernels/utils.py | 2 +- unsloth/models/llama.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/unsloth/kernels/utils.py b/unsloth/kernels/utils.py index 141814c332..a00be89942 100644 --- a/unsloth/kernels/utils.py +++ b/unsloth/kernels/utils.py @@ -183,7 +183,7 @@ def fast_linear_forward(proj, X, temp_lora = None, out = None): if lora_A is not None: dtype = X.dtype temp_lora = torch.matmul(X, lora_A.to(dtype).t(), out = temp_lora) - out.addmv_(lora_B.to(dtype).t(), temp_lora, alpha = lora_S) + out.addmv_(lora_B.to(dtype), temp_lora, alpha = lora_S) pass return out pass diff --git a/unsloth/models/llama.py b/unsloth/models/llama.py index 0a157860c6..18947744c5 100644 --- a/unsloth/models/llama.py +++ b/unsloth/models/llama.py @@ -180,6 +180,7 @@ def LlamaAttention_fast_forward_inference( A = fast_linear_forward(self.o_proj, A) A = A.reshape(1, 1, self.hidden_size) + # return A, (Kn, Vn) return A, (Kn.unsqueeze(0), Vn.unsqueeze(0)) pass