From 2100f4cac29d90808ae7e6344e8587d9e9774984 Mon Sep 17 00:00:00 2001 From: Kohaku-Blueleaf <59680068+KohakuBlueleaf@users.noreply.github.com> Date: Wed, 23 Jul 2025 14:37:30 +0800 Subject: [PATCH] linting --- comfy/weight_adapter/loha.py | 4 ++-- comfy/weight_adapter/lokr.py | 10 ++++------ comfy/weight_adapter/oft.py | 3 +-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/comfy/weight_adapter/loha.py b/comfy/weight_adapter/loha.py index 2a09a63d9..55c97a3af 100644 --- a/comfy/weight_adapter/loha.py +++ b/comfy/weight_adapter/loha.py @@ -78,7 +78,7 @@ class LohaDiff(WeightAdapterTrainBase): def __init__(self, weights): super().__init__() # Unpack weights tuple from LoHaAdapter - w1a, w1b, alpha, w2a, w2b, t1, t2, dora_scale = weights + w1a, w1b, alpha, w2a, w2b, t1, t2, _ = weights # Create trainable parameters self.hada_w1_a = torch.nn.Parameter(w1a) @@ -98,7 +98,7 @@ class LohaDiff(WeightAdapterTrainBase): # Store rank and non-trainable alpha self.rank = w1b.shape[0] - self.register_buffer("alpha", torch.tensor(alpha)) + self.alpha = torch.nn.Parameter(torch.tensor(alpha), requires_grad=False) def __call__(self, w): org_dtype = w.dtype diff --git a/comfy/weight_adapter/lokr.py b/comfy/weight_adapter/lokr.py index d33077f27..49b0be55f 100644 --- a/comfy/weight_adapter/lokr.py +++ b/comfy/weight_adapter/lokr.py @@ -17,16 +17,16 @@ class LokrDiff(WeightAdapterTrainBase): (lokr_w1, lokr_w2, alpha, lokr_w1_a, lokr_w1_b, lokr_w2_a, lokr_w2_b, lokr_t2, dora_scale) = weights self.use_tucker = False if lokr_w1_a is not None: - out_dim_a, rank_a = lokr_w1_a.shape[0], lokr_w1_a.shape[1] - rank_a, in_dim_a = lokr_w1_b.shape[0], lokr_w1_b.shape[1] + _, rank_a = lokr_w1_a.shape[0], lokr_w1_a.shape[1] + rank_a, _ = lokr_w1_b.shape[0], lokr_w1_b.shape[1] self.lokr_w1_a = torch.nn.Parameter(lokr_w1_a) self.lokr_w1_b = torch.nn.Parameter(lokr_w1_b) self.w1_rebuild = True self.ranka = rank_a if lokr_w2_a is not None: - out_dim_b, rank_b = lokr_w2_a.shape[0], lokr_w2_a.shape[1] - rank_b, in_dim_b = lokr_w2_b.shape[0], lokr_w2_b.shape[1] + _, rank_b = lokr_w2_a.shape[0], lokr_w2_a.shape[1] + rank_b, _ = lokr_w2_b.shape[0], lokr_w2_b.shape[1] self.lokr_w2_a = torch.nn.Parameter(lokr_w2_a) self.lokr_w2_b = torch.nn.Parameter(lokr_w2_b) if lokr_t2 is not None: @@ -36,12 +36,10 @@ class LokrDiff(WeightAdapterTrainBase): self.rankb = rank_b if lokr_w1 is not None: - out_dim_a, in_dim_a = lokr_w1.shape[0], lokr_w1.shape[1] self.lokr_w1 = torch.nn.Parameter(lokr_w1) self.w1_rebuild = False if lokr_w2 is not None: - out_dim_b, in_dim_b = lokr_w2.shape[0], lokr_w2.shape[1] self.lokr_w2 = torch.nn.Parameter(lokr_w2) self.w2_rebuild = False diff --git a/comfy/weight_adapter/oft.py b/comfy/weight_adapter/oft.py index 1a59727d2..9d4982083 100644 --- a/comfy/weight_adapter/oft.py +++ b/comfy/weight_adapter/oft.py @@ -10,7 +10,7 @@ class OFTDiff(WeightAdapterTrainBase): def __init__(self, weights): super().__init__() # Unpack weights tuple from LoHaAdapter - blocks, rescale, alpha, dora_scale = weights + blocks, rescale, alpha, _ = weights # Create trainable parameters self.oft_blocks = torch.nn.Parameter(blocks) @@ -124,7 +124,6 @@ class OFTAdapter(WeightAdapterBase): rescale = v[1] alpha = v[2] if alpha is None: - print("Alpha is None") alpha = 0 dora_scale = v[3]