lycoris-lora 2.3.0.dev2__tar.gz → 2.3.0.dev4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. {lycoris_lora-2.3.0.dev2/lycoris_lora.egg-info → lycoris_lora-2.3.0.dev4}/PKG-INFO +1 -1
  2. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/modules/__init__.py +12 -3
  3. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/modules/locon.py +2 -1
  4. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/modules/loha.py +2 -1
  5. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/modules/lokr.py +2 -1
  6. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/utils/__init__.py +10 -2
  7. lycoris_lora-2.3.0.dev4/lycoris/utils/tensor_norm.py +7 -0
  8. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4/lycoris_lora.egg-info}/PKG-INFO +1 -1
  9. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris_lora.egg-info/SOURCES.txt +1 -0
  10. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/setup.py +1 -1
  11. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/LICENSE.md +0 -0
  12. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/README.md +0 -0
  13. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/__init__.py +0 -0
  14. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/config.py +0 -0
  15. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/hcp/__init__.py +0 -0
  16. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/hcp/base.py +0 -0
  17. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/hcp/diag_oft.py +0 -0
  18. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/hcp/loha.py +0 -0
  19. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/hcp/lokr.py +0 -0
  20. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/kohya/__init__.py +0 -0
  21. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/kohya/model_utils.py +0 -0
  22. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/kohya/original_unet.py +0 -0
  23. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/kohya/sdxl_model_util.py +0 -0
  24. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/kohya/sdxl_original_unet.py +0 -0
  25. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/kohya/test_hyperdream.py +0 -0
  26. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/kohya/utils.py +0 -0
  27. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/logging.py +0 -0
  28. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/modules/attention.py +0 -0
  29. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/modules/base.py +0 -0
  30. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/modules/boft.py +0 -0
  31. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/modules/diag_oft.py +0 -0
  32. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/modules/dylora.py +0 -0
  33. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/modules/full.py +0 -0
  34. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/modules/glokr.py +0 -0
  35. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/modules/glora.py +0 -0
  36. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/modules/hypernet/__init__.py +0 -0
  37. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/modules/hypernet/generater.py +0 -0
  38. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/modules/hypernet/text_encoder.py +0 -0
  39. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/modules/ia3.py +0 -0
  40. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/modules/lilora.py +0 -0
  41. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/modules/norms.py +0 -0
  42. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/utils/bnb.py +0 -0
  43. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/utils/logger.py +0 -0
  44. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/utils/preset.py +0 -0
  45. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/utils/xformers_utils.py +0 -0
  46. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris/wrapper.py +0 -0
  47. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris_lora.egg-info/dependency_links.txt +0 -0
  48. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris_lora.egg-info/not-zip-safe +0 -0
  49. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris_lora.egg-info/requires.txt +0 -0
  50. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/lycoris_lora.egg-info/top_level.txt +0 -0
  51. {lycoris_lora-2.3.0.dev2 → lycoris_lora-2.3.0.dev4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lycoris_lora
3
- Version: 2.3.0.dev2
3
+ Version: 2.3.0.dev4
4
4
  Summary: Lora beYond Conventional methods, Other Rank adaptation Implementations for Stable diffusion
5
5
  Home-page: https://github.com/KohakuBlueleaf/LyCORIS
6
6
  Author: Shih-Ying Yeh(KohakuBlueLeaf), Yu-Guan Hsieh, Zhidong Gao
@@ -12,7 +12,7 @@ from .ia3 import IA3Module
12
12
  def make_module(lyco_type, params, lora_name, orig_module):
13
13
  module = None
14
14
  if lyco_type == "locon":
15
- up, down, mid, alpha = params
15
+ up, down, mid, alpha, dora_scale = params
16
16
  module = LoConModule(
17
17
  lora_name,
18
18
  orig_module,
@@ -20,13 +20,16 @@ def make_module(lyco_type, params, lora_name, orig_module):
20
20
  down.size(0),
21
21
  float(alpha),
22
22
  use_tucker=mid is not None,
23
+ weight_decompose=dora_scale is not None,
23
24
  )
24
25
  module.lora_up.weight.data.copy_(up)
25
26
  module.lora_down.weight.data.copy_(down)
26
27
  if mid is not None:
27
28
  module.lora_mid.weight.data.copy_(mid)
29
+ if dora_scale is not None:
30
+ module.dora_scale.copy_(dora_scale)
28
31
  elif lyco_type == "hada":
29
- w1a, w1b, w2a, w2b, t1, t2, alpha = params
32
+ w1a, w1b, w2a, w2b, t1, t2, alpha, dora_scale = params
30
33
  module = LohaModule(
31
34
  lora_name,
32
35
  orig_module,
@@ -34,6 +37,7 @@ def make_module(lyco_type, params, lora_name, orig_module):
34
37
  w1b.size(0),
35
38
  float(alpha),
36
39
  use_tucker=t1 is not None,
40
+ weight_decompose=dora_scale is not None,
37
41
  )
38
42
  module.hada_w1_a.copy_(w1a)
39
43
  module.hada_w1_b.copy_(w1b)
@@ -42,8 +46,10 @@ def make_module(lyco_type, params, lora_name, orig_module):
42
46
  if t1 is not None:
43
47
  module.hada_t1.copy_(t1)
44
48
  module.hada_t2.copy_(t2)
49
+ if dora_scale is not None:
50
+ module.dora_scale.copy_(dora_scale)
45
51
  elif lyco_type == "kron":
46
- w1, w1a, w1b, w2, w2a, w2b, _, t2, alpha = params
52
+ w1, w1a, w1b, w2, w2a, w2b, _, t2, alpha, dora_scale = params
47
53
  if w1a is not None:
48
54
  lora_dim = w1a.size(1)
49
55
  elif w2a is not None:
@@ -83,6 +89,7 @@ def make_module(lyco_type, params, lora_name, orig_module):
83
89
  use_tucker=t2 is not None,
84
90
  decompose_both=w1 is None and w2 is None,
85
91
  factor=factor,
92
+ weight_decompose=dora_scale is not None,
86
93
  )
87
94
  if w1 is not None:
88
95
  module.lokr_w1.copy_(w1)
@@ -96,6 +103,8 @@ def make_module(lyco_type, params, lora_name, orig_module):
96
103
  module.lokr_w2_b.copy_(w2b)
97
104
  if t2 is not None:
98
105
  module.lokr_t2.copy_(t2)
106
+ if dora_scale is not None:
107
+ module.dora_scale.copy_(dora_scale)
99
108
  elif lyco_type == "norm":
100
109
  w_norm, b_norm = params
101
110
  module = NormModule(
@@ -196,6 +196,7 @@ class LoConModule(ModuleCustomSD):
196
196
  return weight * self.scalar.to(device)
197
197
 
198
198
  def apply_weight_decompose(self, weight):
199
+ weight = weight.to(self.dora_scale.dtype)
199
200
  weight_norm = (
200
201
  weight.transpose(0, 1)
201
202
  .reshape(weight.shape[1], -1)
@@ -204,7 +205,7 @@ class LoConModule(ModuleCustomSD):
204
205
  .transpose(0, 1)
205
206
  )
206
207
 
207
- return weight * (self.dora_scale / weight_norm)
208
+ return weight * (self.dora_scale.to(weight.device) / weight_norm)
208
209
 
209
210
  def custom_state_dict(self):
210
211
  destination = {}
@@ -267,6 +267,7 @@ class LohaModule(ModuleCustomSD):
267
267
  return weight
268
268
 
269
269
  def apply_weight_decompose(self, weight):
270
+ weight = weight.to(self.dora_scale.dtype)
270
271
  weight_norm = (
271
272
  weight.transpose(0, 1)
272
273
  .reshape(weight.shape[1], -1)
@@ -275,7 +276,7 @@ class LohaModule(ModuleCustomSD):
275
276
  .transpose(0, 1)
276
277
  )
277
278
 
278
- return weight * (self.dora_scale / weight_norm)
279
+ return weight * (self.dora_scale.to(weight.device) / weight_norm)
279
280
 
280
281
  def custom_state_dict(self):
281
282
  destination = {}
@@ -337,6 +337,7 @@ class LokrModule(ModuleCustomSD):
337
337
  return weight
338
338
 
339
339
  def apply_weight_decompose(self, weight):
340
+ weight = weight.to(self.dora_scale.dtype)
340
341
  weight_norm = (
341
342
  weight.transpose(0, 1)
342
343
  .reshape(weight.shape[1], -1)
@@ -345,7 +346,7 @@ class LokrModule(ModuleCustomSD):
345
346
  .transpose(0, 1)
346
347
  )
347
348
 
348
- return weight * (self.dora_scale / weight_norm)
349
+ return weight * (self.dora_scale.to(weight.device) / weight_norm)
349
350
 
350
351
  def custom_state_dict(self):
351
352
  destination = {}
@@ -449,9 +449,17 @@ def tucker_weight(wa, wb, t):
449
449
 
450
450
 
451
451
  def apply_dora_scale(org_weight, rebuild, dora_scale, scale):
452
- dora_mean_dim = tuple(i for i in range(org_weight.dim()) if i != 1)
452
+ dora_norm_dims = org_weight.dim() - 1
453
453
  weight = org_weight + rebuild
454
- merged_scale1 = weight / weight.mean(dim=dora_mean_dim, keepdim=True) * dora_scale
454
+ weight = weight.to(dora_scale.dtype)
455
+ weight_norm = (
456
+ weight.transpose(0, 1)
457
+ .reshape(weight.shape[1], -1)
458
+ .norm(dim=1, keepdim=True)
459
+ .reshape(weight.shape[1], *[1] * dora_norm_dims)
460
+ .transpose(0, 1)
461
+ )
462
+ merged_scale1 = weight / weight_norm * dora_scale
455
463
  diff_weight = merged_scale1 - org_weight
456
464
  return org_weight + diff_weight * scale
457
465
 
@@ -0,0 +1,7 @@
1
+ import torch
2
+ import torch.nn as nn
3
+ import torch.nn.functional as F
4
+
5
+
6
+ def multi_dim_norm(x: torch.Tensor, dim: int = 1) -> torch.Tensor:
7
+ return torch.norm(x, dim=dim, p=2, keepdim=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lycoris_lora
3
- Version: 2.3.0.dev2
3
+ Version: 2.3.0.dev4
4
4
  Summary: Lora beYond Conventional methods, Other Rank adaptation Implementations for Stable diffusion
5
5
  Home-page: https://github.com/KohakuBlueleaf/LyCORIS
6
6
  Author: Shih-Ying Yeh(KohakuBlueLeaf), Yu-Guan Hsieh, Zhidong Gao
@@ -39,6 +39,7 @@ lycoris/utils/__init__.py
39
39
  lycoris/utils/bnb.py
40
40
  lycoris/utils/logger.py
41
41
  lycoris/utils/preset.py
42
+ lycoris/utils/tensor_norm.py
42
43
  lycoris/utils/xformers_utils.py
43
44
  lycoris_lora.egg-info/PKG-INFO
44
45
  lycoris_lora.egg-info/SOURCES.txt
@@ -4,7 +4,7 @@ from setuptools import setup, find_packages
4
4
  setup(
5
5
  name="lycoris_lora",
6
6
  packages=find_packages(),
7
- version="2.3.0.dev2",
7
+ version="2.3.0.dev4",
8
8
  url="https://github.com/KohakuBlueleaf/LyCORIS",
9
9
  description="Lora beYond Conventional methods, Other Rank adaptation Implementations for Stable diffusion",
10
10
  author="Shih-Ying Yeh(KohakuBlueLeaf), Yu-Guan Hsieh, Zhidong Gao",