From facf574a61a07c0b6ed5773ea1355c83ccc2ea6c Mon Sep 17 00:00:00 2001 From: catboxanon <122327233+catboxanon@users.noreply.github.com> Date: Mon, 14 Apr 2025 12:17:15 -0400 Subject: [PATCH] Correct DoRA implementation --- comfy/lora.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/comfy/lora.py b/comfy/lora.py index bc9f3022a..8ff4bf332 100644 --- a/comfy/lora.py +++ b/comfy/lora.py @@ -413,11 +413,10 @@ def weight_decompose(dora_scale, weight, lora_diff, alpha, strength, intermediat lora_diff *= alpha weight_calc = weight + function(lora_diff).type(weight.dtype) weight_norm = ( - weight_calc.transpose(0, 1) - .reshape(weight_calc.shape[1], -1) + weight_calc + .reshape(weight_calc.shape[0], -1) .norm(dim=1, keepdim=True) - .reshape(weight_calc.shape[1], *[1] * (weight_calc.dim() - 1)) - .transpose(0, 1) + .reshape(weight_calc.shape[0], *[1] * (weight_calc.dim() - 1)) ) weight_calc *= (dora_scale / weight_norm).type(weight.dtype)