mmgp 1.0.5__py3-none-any.whl → 1.1.0__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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mmgp
3
- Version: 1.0.5
3
+ Version: 1.1.0
4
4
  Summary: Memory Management for the GPU Poor
5
5
  Author-email: deepbeepmeep <deepbeepmeep@yahoo.com>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -683,7 +683,11 @@ License-File: LICENSE.md
683
683
  Requires-Dist: torch>=2.1.0
684
684
  Requires-Dist: optimum-quanto
685
685
 
686
- **------------------ Memory Management for the GPU Poor by DeepBeepMeep ------------------**
686
+
687
+ <p align="center">
688
+ <H2>Memory Management for the GPU Poor by DeepBeepMeep</H2>
689
+ </p>
690
+
687
691
 
688
692
  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.
689
693
  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
@@ -693,31 +697,50 @@ Requirements:
693
697
  - GPU: RTX 3090/ RTX 4090 (24 GB of VRAM)
694
698
  - RAM: minimum 48 GB, recommended 64 GB
695
699
 
700
+ First you need to install the module in your current project with:
701
+ ```shell
702
+ pip install mmgp
703
+ ```
704
+
696
705
  It is almost plug and play and just needs to be invoked from the main app just after the model pipeline has been created.
697
- 1) First make sure that the pipeline explictly loads the models in the CPU device
698
- for instance: pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16).to("cpu")
706
+ 1) First make sure that the pipeline explictly loads the models in the CPU device, for instance:
707
+ ```
708
+ pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16).to("cpu")
709
+ ```
710
+
699
711
  2) Once every potential Lora has been loaded and merged, add the following lines:
700
712
 
701
- *from mmgp import offload*
702
- *offload.me(pipe)*
703
-
704
- The 'transformer' model that contains usually the video or image generator is quantized on the fly by default to 8 bits. If you want to save time on disk and reduce the loading time, you may want to load directly a prequantized model. In that case you need to set the option *quantizeTransformer* to *False* to turn off on the fly quantization.
713
+ ```
714
+ from mmgp import offload
715
+ offload.me(pipe)
716
+ ```
717
+ The 'transformer' model in the pipe contains usually the video or image generator is quantized on the fly by default to 8 bits. If you want to save time on disk and reduce the loading time, you may want to load directly a prequantized model. In that case you need to set the option *quantizeTransformer* to *False* to turn off on the fly quantization.
705
718
 
706
719
  If you have more than 64GB RAM you may want to enable RAM pinning with the option *pinInRAM = True*. You will get in return super fast loading / unloading of models
707
720
  (this can save significant time if the same pipeline is run multiple times in a row)
708
721
 
709
- Sometime there isn't an explicit pipe object as each submodel is loaded separately in the main app. If this is the case, you need to create a dictionary that manually maps all the models.
710
-
722
+ Sometime there isn't an explicit pipe object as each submodel is loaded separately in the main app. If this is the case, you need to create a dictionary that manually maps all the models.\
711
723
  For instance :
712
- for flux derived models: *pipe = { "text_encoder": clip, "text_encoder_2": t5, "transformer": model, "vae":ae }*
713
- for mochi: *pipe = { "text_encoder": self.text_encoder, "transformer": self.dit, "vae":self.decoder }*
724
+
725
+
726
+ - for flux derived models:
727
+ ```
728
+ pipe = { "text_encoder": clip, "text_encoder_2": t5, "transformer": model, "vae":ae }
729
+ ```
730
+ - for mochi:
731
+ ```
732
+ pipe = { "text_encoder": self.text_encoder, "transformer": self.dit, "vae":self.decoder }
733
+ ```
734
+
714
735
 
715
736
  Please note that there should be always one model whose Id is 'transformer'. It corresponds to the main image / video model which usually needs to be quantized (this is done on the fly by default when loading the model).
716
737
 
717
738
  Becareful, lots of models use the T5 XXL as a text encoder. However, quite often their corresponding pipeline configurations point at the official Google T5 XXL repository
718
739
  where there is a huge 40GB model to download and load. It is cumbersorme as it is a 32 bits model and contains the decoder part of T5 that is not used.
719
740
  I suggest you use instead one of the 16 bits encoder only version available around, for instance:
720
- *text_encoder_2 = T5EncoderModel.from_pretrained("black-forest-labs/FLUX.1-dev", subfolder="text_encoder_2", torch_dtype=torch.float16)*
741
+ ```
742
+ text_encoder_2 = T5EncoderModel.from_pretrained("black-forest-labs/FLUX.1-dev", subfolder="text_encoder_2", torch_dtype=torch.float16)
743
+ ```
721
744
 
722
745
  Sometime just providing the pipe won't be sufficient as you will need to change the content of the core model:
723
746
  - For instance you may need to disable an existing CPU offload logic that already exists (such as manual calls to move tensors between cuda and the cpu)
@@ -727,6 +750,6 @@ You are free to use my module for non commercial use as long you give me proper
727
750
 
728
751
  Thanks to
729
752
  ---------
730
- Huggingface / accelerate for the hooking examples
731
- Huggingface / quanto for their very useful quantizer
732
- gau-nernst for his Pinnig RAM samples
753
+ - Huggingface / accelerate for the hooking examples
754
+ - Huggingface / quanto for their very useful quantizer
755
+ - gau-nernst for his Pinnig RAM samples
@@ -0,0 +1,7 @@
1
+ __init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ mmgp.py,sha256=SNnSSAtSoavzBgJQqp_O-9JlgsmI7pjboF3aO6MGZNE,20770
3
+ mmgp-1.1.0.dist-info/LICENSE.md,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
4
+ mmgp-1.1.0.dist-info/METADATA,sha256=RrKUBzntWC8fFolmAzRgakswejR0D4W715AeI49QHj8,44527
5
+ mmgp-1.1.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
6
+ mmgp-1.1.0.dist-info/top_level.txt,sha256=waGaepj2qVfnS2yAOkaMu4r9mJaVjGbEi6AwOUogU_U,14
7
+ mmgp-1.1.0.dist-info/RECORD,,
@@ -1,3 +1,2 @@
1
1
  __init__
2
- _version
3
2
  mmgp
_version.py DELETED
@@ -1,16 +0,0 @@
1
- # file generated by setuptools_scm
2
- # don't change, don't track in version control
3
- TYPE_CHECKING = False
4
- if TYPE_CHECKING:
5
- from typing import Tuple, Union
6
- VERSION_TUPLE = Tuple[Union[int, str], ...]
7
- else:
8
- VERSION_TUPLE = object
9
-
10
- version: str
11
- __version__: str
12
- __version_tuple__: VERSION_TUPLE
13
- version_tuple: VERSION_TUPLE
14
-
15
- __version__ = version = '1.0.5'
16
- __version_tuple__ = version_tuple = (1, 0, 5)
@@ -1,8 +0,0 @@
1
- __init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- _version.py,sha256=ClFIlbf5O23dVWC6oD6t3m2n6nB22IOt3V9t-YX_mG0,411
3
- mmgp.py,sha256=SNnSSAtSoavzBgJQqp_O-9JlgsmI7pjboF3aO6MGZNE,20770
4
- mmgp-1.0.5.dist-info/LICENSE.md,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
5
- mmgp-1.0.5.dist-info/METADATA,sha256=alsu9xZpEgqcSz-xLg3k2B5eF-3u03el7-nOaLu0HZo,44381
6
- mmgp-1.0.5.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
7
- mmgp-1.0.5.dist-info/top_level.txt,sha256=gf5FPNwF128kswDDAg8wKlyHQtBbgTfA37hYVvlA7mI,23
8
- mmgp-1.0.5.dist-info/RECORD,,
File without changes