mmgp 3.6.5__py3-none-any.whl → 3.6.7__py3-none-any.whl

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.

Potentially problematic release.


This version of mmgp might be problematic. Click here for more details.

mmgp/offload.py CHANGED
@@ -1,4 +1,4 @@
1
- # ------------------ Memory Management 3.6.5 for the GPU Poor by DeepBeepMeep (mmgp)------------------
1
+ # ------------------ Memory Management 3.6.7 for the GPU Poor by DeepBeepMeep (mmgp)------------------
2
2
  #
3
3
  # This module contains multiples optimisations so that models such as Flux (and derived), Mochi, CogView, HunyuanVideo, ... can run smoothly on a 24 GB GPU limited card.
4
4
  # This a replacement for the accelerate library that should in theory manage offloading, but doesn't work properly with models that are loaded / unloaded several
@@ -63,7 +63,7 @@ import json
63
63
  import psutil
64
64
  import builtins
65
65
  from accelerate import init_empty_weights
66
-
66
+ from functools import wraps
67
67
  import functools
68
68
  import types
69
69
 
@@ -86,6 +86,14 @@ class QEmbedding(QModuleMixin, torch.nn.Embedding):
86
86
 
87
87
 
88
88
 
89
+ def cudacontext(device):
90
+ def decorator(func):
91
+ @wraps(func)
92
+ def wrapper(*args, **kwargs):
93
+ with torch.device(device):
94
+ return func(*args, **kwargs)
95
+ return wrapper
96
+ return decorator
89
97
 
90
98
 
91
99
  shared_state = {}
@@ -689,7 +697,7 @@ def _welcome():
689
697
  if welcome_displayed:
690
698
  return
691
699
  welcome_displayed = True
692
- print(f"{BOLD}{HEADER}************ Memory Management for the GPU Poor (mmgp 3.6.5) by DeepBeepMeep ************{ENDC}{UNBOLD}")
700
+ print(f"{BOLD}{HEADER}************ Memory Management for the GPU Poor (mmgp 3.6.7) by DeepBeepMeep ************{ENDC}{UNBOLD}")
693
701
 
694
702
  def change_dtype(model, new_dtype, exclude_buffers = False):
695
703
  for submodule_name, submodule in model.named_modules():
@@ -1075,15 +1083,10 @@ def load_loras_into_model(model, lora_path, lora_multi = None, activate_all_lora
1075
1083
 
1076
1084
  if not fail:
1077
1085
  pos = first_key.find(".")
1078
- prefix = first_key[0:pos]
1079
- if prefix not in ["diffusion_model", "transformer"]:
1080
- msg = f"No compatible weight was found in Lora file '{path}'. Please check that it is compatible with the Diffusers format."
1081
- error_msg = append(error_msg, msg)
1082
- fail = True
1086
+ prefix = first_key[0:pos+1]
1087
+ if prefix in ["diffusion_model.", "transformer."]:
1088
+ state_dict = { k[ len(prefix):]: v for k, v in state_dict.items() if k.startswith(prefix) }
1083
1089
 
1084
- if not fail:
1085
-
1086
- state_dict = { k[ len(prefix) + 1:]: v for k, v in state_dict.items() if k.startswith(prefix) }
1087
1090
  clean_up = True
1088
1091
 
1089
1092
  keys = list(state_dict.keys())
@@ -1421,7 +1424,6 @@ def fast_load_transformers_model(model_path: str, do_quantize = False, quantiza
1421
1424
  model = transfomer_class.from_config(transformer_config )
1422
1425
 
1423
1426
 
1424
- torch.set_default_device('cpu')
1425
1427
  model.eval().requires_grad_(False)
1426
1428
 
1427
1429
  model._config = transformer_config
@@ -1432,6 +1434,7 @@ def fast_load_transformers_model(model_path: str, do_quantize = False, quantiza
1432
1434
 
1433
1435
 
1434
1436
 
1437
+ @cudacontext("cpu")
1435
1438
  def load_model_data(model, file_path, do_quantize = False, quantizationType = qint8, pinToMemory = False, partialPinning = False, modelPrefix = None, writable_tensors = True, preprocess_sd = None, postprocess_sd = None, modules = None, return_shared_modules = None, default_dtype = torch.bfloat16, ignore_unused_weights = False, verboseLevel = -1):
1436
1439
  """
1437
1440
  Load a model, detect if it has been previously quantized using quanto and do the extra setup if necessary
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mmgp
3
- Version: 3.6.5
3
+ Version: 3.6.7
4
4
  Summary: Memory Management for the GPU Poor
5
5
  Author-email: deepbeepmeep <deepbeepmeep@yahoo.com>
6
6
  Requires-Python: >=3.10
@@ -15,7 +15,7 @@ Dynamic: license-file
15
15
 
16
16
 
17
17
  <p align="center">
18
- <H2>Memory Management 3.6.5 for the GPU Poor by DeepBeepMeep</H2>
18
+ <H2>Memory Management 3.6.7 for the GPU Poor by DeepBeepMeep</H2>
19
19
  </p>
20
20
 
21
21
 
@@ -0,0 +1,10 @@
1
+ __init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ mmgp/__init__.py,sha256=A9qBwyQMd1M7vshSTOBnFGP1MQvS2hXmTcTCMUcmyzE,509
3
+ mmgp/fp8_quanto_bridge.py,sha256=VtUaD6wzo7Yn9vGY0LMtbhwt6KMWRpSWLc65bU_sfZU,21155
4
+ mmgp/offload.py,sha256=_-fgKyHyIZ7mWgjzZ_PsmShStl0i7soo4ZXpzA55b6A,138996
5
+ mmgp/safetensors2.py,sha256=zYNMprt1KoxgVALbcz6DawxsQDNNRImvgO9cYRChUiY,19028
6
+ mmgp-3.6.7.dist-info/licenses/LICENSE.md,sha256=DD-WIS0BkPoWJ_8hQO3J8hMP9K_1-dyrYv1YCbkxcDU,94
7
+ mmgp-3.6.7.dist-info/METADATA,sha256=PwOn_JzoyOYqoBZtPhnT9B-wNFH7fGHszW0Ypg7LZFI,16309
8
+ mmgp-3.6.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
+ mmgp-3.6.7.dist-info/top_level.txt,sha256=waGaepj2qVfnS2yAOkaMu4r9mJaVjGbEi6AwOUogU_U,14
10
+ mmgp-3.6.7.dist-info/RECORD,,
@@ -1,2 +1,2 @@
1
- GNU GENERAL PUBLIC LICENSE
1
+ GNU GENERAL PUBLIC LICENSE
2
2
  Version 3, 29 June 2007
@@ -1,10 +0,0 @@
1
- __init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- mmgp/__init__.py,sha256=A9qBwyQMd1M7vshSTOBnFGP1MQvS2hXmTcTCMUcmyzE,509
3
- mmgp/fp8_quanto_bridge.py,sha256=VtUaD6wzo7Yn9vGY0LMtbhwt6KMWRpSWLc65bU_sfZU,21155
4
- mmgp/offload.py,sha256=GwM0o0rWUwY3tb_HDl_pO6S0XvMpVZsre3DzwFCLQh4,138988
5
- mmgp/safetensors2.py,sha256=zYNMprt1KoxgVALbcz6DawxsQDNNRImvgO9cYRChUiY,19028
6
- mmgp-3.6.5.dist-info/licenses/LICENSE.md,sha256=HjzvY2grdtdduZclbZ46B2M-XpT4MDCxFub5ZwTWq2g,93
7
- mmgp-3.6.5.dist-info/METADATA,sha256=9wXPfJYiHExhfM-kSeA4mLoNh0laDRXJ3ZrBFSpQlUg,16309
8
- mmgp-3.6.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
- mmgp-3.6.5.dist-info/top_level.txt,sha256=waGaepj2qVfnS2yAOkaMu4r9mJaVjGbEi6AwOUogU_U,14
10
- mmgp-3.6.5.dist-info/RECORD,,
File without changes