lycoris-lora 3.0.1.dev10__tar.gz → 3.0.1.dev12__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 (46) hide show
  1. {lycoris_lora-3.0.1.dev10/lycoris_lora.egg-info → lycoris_lora-3.0.1.dev12}/PKG-INFO +1 -1
  2. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/functional/lokr.py +4 -1
  3. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/modules/loha.py +5 -2
  4. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/modules/lokr.py +26 -2
  5. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12/lycoris_lora.egg-info}/PKG-INFO +1 -1
  6. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/setup.py +1 -1
  7. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/test/kohya.py +3 -1
  8. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/test/wrapper.py +7 -2
  9. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/LICENSE.md +0 -0
  10. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/README.md +0 -0
  11. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/__init__.py +0 -0
  12. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/config.py +0 -0
  13. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/functional/__init__.py +0 -0
  14. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/functional/boft.py +0 -0
  15. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/functional/diag_oft.py +0 -0
  16. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/functional/general.py +0 -0
  17. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/functional/locon.py +0 -0
  18. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/functional/loha.py +0 -0
  19. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/kohya.py +0 -0
  20. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/logging.py +0 -0
  21. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/modules/__init__.py +0 -0
  22. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/modules/base.py +0 -0
  23. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/modules/boft.py +0 -0
  24. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/modules/diag_oft.py +0 -0
  25. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/modules/dylora.py +0 -0
  26. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/modules/full.py +0 -0
  27. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/modules/glora.py +0 -0
  28. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/modules/ia3.py +0 -0
  29. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/modules/locon.py +0 -0
  30. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/modules/norms.py +0 -0
  31. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/utils/__init__.py +0 -0
  32. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/utils/bnb.py +0 -0
  33. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/utils/general.py +0 -0
  34. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/utils/logger.py +0 -0
  35. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/utils/preset.py +0 -0
  36. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/utils/xformers_utils.py +0 -0
  37. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris/wrapper.py +0 -0
  38. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris_lora.egg-info/SOURCES.txt +0 -0
  39. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris_lora.egg-info/dependency_links.txt +0 -0
  40. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris_lora.egg-info/not-zip-safe +0 -0
  41. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris_lora.egg-info/requires.txt +0 -0
  42. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/lycoris_lora.egg-info/top_level.txt +0 -0
  43. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/setup.cfg +0 -0
  44. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/test/__init__.py +0 -0
  45. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/test/functional.py +0 -0
  46. {lycoris_lora-3.0.1.dev10 → lycoris_lora-3.0.1.dev12}/test/module.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lycoris_lora
3
- Version: 3.0.1.dev10
3
+ Version: 3.0.1.dev12
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
@@ -14,7 +14,10 @@ def make_kron(w1, w2, scale):
14
14
  w2 = w2.contiguous()
15
15
  rebuild = torch.kron(w1, w2)
16
16
 
17
- return rebuild * scale
17
+ if scale != 1:
18
+ rebuild = rebuild * scale
19
+
20
+ return rebuild
18
21
 
19
22
 
20
23
  def weight_gen(
@@ -182,6 +182,9 @@ class LohaModule(LycorisBaseModule):
182
182
  )
183
183
 
184
184
  def get_weight(self, shape):
185
+ scale = torch.tensor(
186
+ self.scale, dtype=self.hada_w1_b.dtype, device=self.hada_w1_b.device
187
+ )
185
188
  if self.tucker:
186
189
  weight = loha_diff_weight(
187
190
  self.hada_w1_b,
@@ -190,7 +193,7 @@ class LohaModule(LycorisBaseModule):
190
193
  self.hada_w2_a,
191
194
  self.hada_t1,
192
195
  self.hada_t2,
193
- gamma=torch.tensor(self.scale),
196
+ gamma=scale,
194
197
  )
195
198
  else:
196
199
  weight = loha_diff_weight(
@@ -200,7 +203,7 @@ class LohaModule(LycorisBaseModule):
200
203
  self.hada_w2_a,
201
204
  None,
202
205
  None,
203
- gamma=torch.tensor(self.scale),
206
+ gamma=scale,
204
207
  )
205
208
  if shape is not None:
206
209
  weight = weight.reshape(shape)
@@ -281,7 +281,29 @@ class LokrModule(LycorisBaseModule):
281
281
  ):
282
282
  factor = -1
283
283
  else:
284
- factor = max(w1.shape) if w1 is not None else max(w1a.size(0), w1b.size(1))
284
+ w1_shape = w1.shape if w1 is not None else (w1a.size(0), w1b.size(1))
285
+ w2_shape = w2.shape if w2 is not None else (w2a.size(0), w2b.size(1))
286
+ shape_group_1 = (w1_shape[0], w2_shape[0])
287
+ shape_group_2 = (w1_shape[1], w2_shape[1])
288
+ w_shape = (w1_shape[0] * w2_shape[0], w1_shape[1] * w2_shape[1])
289
+ factor1 = max(w1.shape) if w1 is not None else max(w1a.size(0), w1b.size(1))
290
+ factor2 = max(w2.shape) if w2 is not None else max(w2a.size(0), w2b.size(1))
291
+ if (
292
+ w_shape[0] % factor1 == 0
293
+ and w_shape[1] % factor1 == 0
294
+ and factor1 in shape_group_1
295
+ and factor1 in shape_group_2
296
+ ):
297
+ factor = factor1
298
+ elif (
299
+ w_shape[0] % factor2 == 0
300
+ and w_shape[1] % factor2 == 0
301
+ and factor2 in shape_group_1
302
+ and factor2 in shape_group_2
303
+ ):
304
+ factor = factor2
305
+ else:
306
+ factor = max(factor1, factor2)
285
307
 
286
308
  module = cls(
287
309
  lora_name,
@@ -337,7 +359,7 @@ class LokrModule(LycorisBaseModule):
337
359
  else self.lokr_w2_a @ self.lokr_w2_b
338
360
  )
339
361
  ),
340
- torch.tensor(self.scale),
362
+ self.scale,
341
363
  )
342
364
  dtype = weight.dtype
343
365
  if shape is not None:
@@ -516,6 +538,8 @@ class LokrModule(LycorisBaseModule):
516
538
  weight = self.apply_weight_decompose(
517
539
  weight + diff_weight, self.multiplier
518
540
  )
541
+ elif self.multiplier == 1:
542
+ weight = weight + diff_weight
519
543
  else:
520
544
  weight = weight + diff_weight * self.multiplier
521
545
  bias = (
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lycoris_lora
3
- Version: 3.0.1.dev10
3
+ Version: 3.0.1.dev12
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
@@ -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="3.0.1.dev10",
7
+ version="3.0.1.dev12",
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",
@@ -104,9 +104,11 @@ class LycorisKohyaWrapperTests(unittest.TestCase):
104
104
  )
105
105
  network.apply_to([sd_te1, sd_te2], sdxl_unet, True, True)
106
106
  network.restore()
107
- create_network_from_weights(
107
+ network = create_network_from_weights(
108
108
  1, "", vae, [sd_te1, sd_te2], sdxl_unet, weights_sd=network.state_dict()
109
109
  )
110
+ network.merge_to()
111
+ del network
110
112
  torch.cuda.empty_cache()
111
113
 
112
114
  @parameterized.expand(extract_param_list)
@@ -206,6 +206,7 @@ class LycorisWrapperTests(unittest.TestCase):
206
206
  test_input = torch.randn(1, 16, 8, 8, 8).to(device, dtype)
207
207
  test_output = test_net(test_input)
208
208
  test_lycoris.restore()
209
+ test_lycoris.merge_to()
209
210
 
210
211
  state_dict = test_lycoris.state_dict()
211
212
  test_lycoris_from_weights: LycorisNetwork
@@ -219,9 +220,13 @@ class LycorisWrapperTests(unittest.TestCase):
219
220
  test_lycoris_from_weights.load_state_dict(test_lycoris.state_dict())
220
221
 
221
222
  self.assertTrue(
222
- len(test_lycoris.loras) == len(test_lycoris_from_weights.loras)
223
+ len(test_lycoris.loras) == len(test_lycoris_from_weights.loras),
224
+ f"{len(test_lycoris.loras)} != {len(test_lycoris_from_weights.loras)}",
225
+ )
226
+ self.assertTrue(
227
+ torch.allclose(test_output, test_output_from_weights),
228
+ f"diff: {torch.nn.functional.mse_loss(test_output, test_output_from_weights).item()}",
223
229
  )
224
- self.assertTrue(torch.allclose(test_output, test_output_from_weights))
225
230
  finally:
226
231
  reset_globals()
227
232