lycoris-lora 2.2.0.dev12__tar.gz → 2.2.0.post1__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 (50) hide show
  1. {lycoris_lora-2.2.0.dev12/lycoris_lora.egg-info → lycoris_lora-2.2.0.post1}/PKG-INFO +1 -1
  2. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/README.md +20 -16
  3. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/kohya/__init__.py +2 -2
  4. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/modules/locon.py +3 -4
  5. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/modules/loha.py +1 -1
  6. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/modules/lokr.py +1 -1
  7. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/wrapper.py +2 -2
  8. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1/lycoris_lora.egg-info}/PKG-INFO +1 -1
  9. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/setup.py +1 -1
  10. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/LICENSE.md +0 -0
  11. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/__init__.py +0 -0
  12. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/config.py +0 -0
  13. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/hcp/__init__.py +0 -0
  14. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/hcp/base.py +0 -0
  15. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/hcp/diag_oft.py +0 -0
  16. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/hcp/loha.py +0 -0
  17. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/hcp/lokr.py +0 -0
  18. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/kohya/model_utils.py +0 -0
  19. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/kohya/original_unet.py +0 -0
  20. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/kohya/sdxl_model_util.py +0 -0
  21. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/kohya/sdxl_original_unet.py +0 -0
  22. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/kohya/test_hyperdream.py +0 -0
  23. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/kohya/utils.py +0 -0
  24. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/logging.py +0 -0
  25. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/modules/__init__.py +0 -0
  26. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/modules/attention.py +0 -0
  27. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/modules/base.py +0 -0
  28. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/modules/boft.py +0 -0
  29. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/modules/diag_oft.py +0 -0
  30. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/modules/dylora.py +0 -0
  31. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/modules/full.py +0 -0
  32. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/modules/glokr.py +0 -0
  33. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/modules/glora.py +0 -0
  34. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/modules/hypernet/__init__.py +0 -0
  35. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/modules/hypernet/generater.py +0 -0
  36. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/modules/hypernet/text_encoder.py +0 -0
  37. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/modules/ia3.py +0 -0
  38. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/modules/lilora.py +0 -0
  39. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/modules/norms.py +0 -0
  40. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/utils/__init__.py +0 -0
  41. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/utils/bnb.py +0 -0
  42. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/utils/logger.py +0 -0
  43. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/utils/preset.py +0 -0
  44. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris/utils/xformers_utils.py +0 -0
  45. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris_lora.egg-info/SOURCES.txt +0 -0
  46. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris_lora.egg-info/dependency_links.txt +0 -0
  47. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris_lora.egg-info/not-zip-safe +0 -0
  48. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris_lora.egg-info/requires.txt +0 -0
  49. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/lycoris_lora.egg-info/top_level.txt +0 -0
  50. {lycoris_lora-2.2.0.dev12 → lycoris_lora-2.2.0.post1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lycoris_lora
3
- Version: 2.2.0.dev12
3
+ Version: 2.2.0.post1
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
@@ -153,6 +153,10 @@ forward_with_lyco = your_model(x)
153
153
 
154
154
  You can check my [HakuPhi](https://github.com/KohakuBlueleaf/HakuPhi) project to see how I utilize LyCORIS to finetune the Phi-1.5 models.
155
155
 
156
+ #### Bitsandbytes support
157
+
158
+ See [bnb_example.py](bnb_example.py) for example. Basically as same as standalone wrapper.
159
+
156
160
  #### Graphical interfaces and Colabs (via kohya trainer)
157
161
 
158
162
  You can also train LyCORIS with the following graphical interfaces
@@ -236,30 +240,30 @@ See [docs/Conversion-scripts.md](docs/Conversion-scripts.md) for more informatio
236
240
 
237
241
  For full log, please see [Change.md](Change.md)
238
242
 
239
- ## 2024/02/18 update to 2.1.0
243
+ ## 2024/03/15 update to 2.2.0 - QLyCORIS and DoRA
240
244
 
241
245
  #### New Algo
242
246
 
243
- * [BOFT (Butterfly OFT)](https://arxiv.org/abs/2311.06243)
247
+ * DoRA
248
+ * Ref: [DoRA: Weight-Decomposed Low-Rank Adaptation](https://github.com/KohakuBlueleaf/LyCORIS)
249
+ * Weight decompose for LoHa and LoKr. (A.K.A DoHa/DoKr)
250
+ * DoRA/DoHa/DoKr will require smaller Learning rate!
244
251
 
245
- #### Improvements
252
+ #### New Features
246
253
 
247
- * Faster, better extract script
248
- * support kohya-ss/sd-scripts image gen
249
- * support regex name in kohya-ss/sd-scripts
250
- * support resume on:
251
- * full
252
- * loha
253
- * oft
254
- * boft
255
- * Add logger into LyCORIS
254
+ * Support "bypass" (a.k.a. adapter) mode for LoHa/LoKr/OFT/BOFT
255
+ * LoHa will require 2xFLOPs since we rebuild full diff weight and then do one more forward.
256
+ * LoKr, OFT, BOFT should be more efficient than LoHa in bypass mode.
257
+ * Support [bnb 8bit/4bit Linear layer](https://github.com/TimDettmers/bitsandbytes) (a.k.a. QLyCORIS) with LoHa/LoKr/OFT/BOFT.
258
+ * This will force module to enable bypass mode.
256
259
 
257
260
  #### Fixes, slight changes
258
261
 
259
- * Update HCP convert for the case where only UNet or TE is trained.
260
- * Change arg names for conversion scripts.
261
- * Fix wrong TE prefix in merge scripts.
262
- * Fix warnings and confusing logging.
262
+ * Refine some details about code quality. Based on the report from GitRoll. (Thx you gitroll!)
263
+ * Remove redundant calculation in BOFT
264
+ * rank_dropout has been removed from OFT/BOFT temporarily untill we ensure how to apply it.
265
+ * Fix bugs in lokr when `lokr_w1_a` not exist.
266
+ * Fix bugs in conversion scritps.
263
267
 
264
268
  ## Todo list
265
269
 
@@ -350,10 +350,10 @@ class LycorisNetworkKohya(LycorisNetwork):
350
350
  **kwargs,
351
351
  )
352
352
  lora = None
353
- if module.__class__.__name__ == "Linear" and lora_dim > 0:
353
+ if isinstance(module, torch.nn.Linear) and lora_dim > 0:
354
354
  dim = dim or lora_dim
355
355
  alpha = alpha or self.alpha
356
- elif module.__class__.__name__ == "Conv2d":
356
+ elif isinstance(module, torch.nn.Conv2d):
357
357
  k_size, *_ = module.kernel_size
358
358
  if k_size == 1 and lora_dim > 0:
359
359
  dim = dim or lora_dim
@@ -133,7 +133,6 @@ class LoConModule(ModuleCustomSD):
133
133
  if use_scalar:
134
134
  self.scalar = nn.Parameter(torch.tensor(0.0))
135
135
  else:
136
- self.scalar: torch.FloatTensor
137
136
  self.register_buffer("scalar", torch.tensor(1.0), persistent=False)
138
137
  # same as microsoft's
139
138
  torch.nn.init.kaiming_uniform_(self.lora_down.weight, a=math.sqrt(5))
@@ -225,11 +224,11 @@ class LoConModule(ModuleCustomSD):
225
224
  return self.org_forward(x)
226
225
  scale = self.scale * self.multiplier
227
226
 
228
- dtype_device = next(self.parameters())
227
+ dtype = next(self.parameters()).dtype
229
228
  if not self.bypass_mode:
230
229
  weight = (
231
- self.org_module[0].weight.data.to(dtype_device)
232
- + self.make_weight(x.device).to(dtype_device) * scale
230
+ self.org_module[0].weight.data.to(device=x.device, dtype=dtype)
231
+ + self.make_weight(x.device).to(device=x.device, dtype=dtype) * scale
233
232
  )
234
233
  if self.wd:
235
234
  weight = self.apply_weight_decompose(weight)
@@ -281,7 +281,7 @@ class LohaModule(ModuleCustomSD):
281
281
 
282
282
  @torch.no_grad()
283
283
  def apply_max_norm(self, max_norm, device=None):
284
- orig_norm = (self.get_weight() * self.scalar).norm()
284
+ orig_norm = (self.get_weight(self.shape) * self.scalar).norm()
285
285
  norm = torch.clamp(orig_norm, max_norm / 2)
286
286
  desired = torch.clamp(norm, max=max_norm)
287
287
  ratio = desired.cpu() / norm.cpu()
@@ -352,7 +352,7 @@ class LokrModule(ModuleCustomSD):
352
352
 
353
353
  @torch.no_grad()
354
354
  def apply_max_norm(self, max_norm, device=None):
355
- orig_norm = self.get_weight().norm()
355
+ orig_norm = self.get_weight(self.shape).norm()
356
356
  norm = torch.clamp(orig_norm, max_norm / 2)
357
357
  desired = torch.clamp(norm, max=max_norm)
358
358
  ratio = desired.cpu() / norm.cpu()
@@ -292,10 +292,10 @@ class LycorisNetwork(torch.nn.Module):
292
292
  **kwargs,
293
293
  )
294
294
  lora = None
295
- if module.__class__.__name__ == "Linear" and lora_dim > 0:
295
+ if isinstance(module, torch.nn.Linear) and lora_dim > 0:
296
296
  dim = dim or lora_dim
297
297
  alpha = alpha or self.alpha
298
- elif module.__class__.__name__ == "Conv2d":
298
+ elif isinstance(module, torch.nn.Conv2d):
299
299
  k_size, *_ = module.kernel_size
300
300
  if k_size == 1 and lora_dim > 0:
301
301
  dim = dim or lora_dim
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lycoris_lora
3
- Version: 2.2.0.dev12
3
+ Version: 2.2.0.post1
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="2.2.0.dev12",
7
+ version="2.2.0.post1",
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",