sharpenb commited on
Commit
a55e209
1 Parent(s): c3596e6

9df1bc28e69bf1d8988953792150b07aaa2443edf971688b68447f721115224e

Browse files
Files changed (4) hide show
  1. README.md +90 -0
  2. model/optimized_model.pkl +3 -0
  3. model/smash_config.json +30 -0
  4. plots.png +0 -0
README.md ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: pruna-engine
3
+ thumbnail: "https://assets-global.website-files.com/646b351987a8d8ce158d1940/64ec9e96b4334c0e1ac41504_Logo%20with%20white%20text.svg"
4
+ metrics:
5
+ - memory_disk
6
+ - memory_inference
7
+ - inference_latency
8
+ - inference_throughput
9
+ - inference_CO2_emissions
10
+ - inference_energy_consumption
11
+ ---
12
+ <!-- header start -->
13
+ <!-- 200823 -->
14
+ <div style="width: auto; margin-left: auto; margin-right: auto">
15
+ <a href="https://www.pruna.ai/" target="_blank" rel="noopener noreferrer">
16
+ <img src="https://i.imgur.com/eDAlcgk.png" alt="PrunaAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
17
+ </a>
18
+ </div>
19
+ <!-- header end -->
20
+
21
+ [![Twitter](https://img.shields.io/twitter/follow/PrunaAI?style=social)](https://twitter.com/PrunaAI)
22
+ [![GitHub](https://img.shields.io/github/followers/PrunaAI?label=Follow%20%40PrunaAI&style=social)](https://github.com/PrunaAI)
23
+ [![LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-blue)](https://www.linkedin.com/company/93832878/admin/feed/posts/?feedType=following)
24
+ [![Discord](https://img.shields.io/badge/Discord-Join%20Us-blue?style=social&logo=discord)](https://discord.gg/CP4VSgck)
25
+
26
+ # Simply make AI models cheaper, smaller, faster, and greener!
27
+
28
+ - Give a thumbs up if you like this model!
29
+ - Contact us and tell us which model to compress next [here](https://www.pruna.ai/contact).
30
+ - Request access to easily compress your *own* AI models [here](https://z0halsaff74.typeform.com/pruna-access?typeform-source=www.pruna.ai).
31
+ - Read the documentations to know more [here](https://pruna-ai-pruna.readthedocs-hosted.com/en/latest/)
32
+ - Join Pruna AI community on Discord [here](https://discord.gg/CP4VSgck) to share feedback/suggestions or get help.
33
+
34
+ ## Results
35
+
36
+ ![image info](./plots.png)
37
+
38
+ **Frequently Asked Questions**
39
+ - ***How does the compression work?*** The model is compressed by combining xformers, triton, jit, cuda graphs, tiling, and step caching.
40
+ - ***How does the model quality change?*** The quality of the model output might slightly vary compared to the base model.
41
+ - ***How is the model efficiency evaluated?*** These results were obtained on NVIDIA A100-PCIE-40GB with configuration described in `model/smash_config.json` and are obtained after a hardware warmup. The smashed model is directly compared to the original base model. Efficiency results may vary in other settings (e.g. other hardware, image size, batch size, ...). We recommend to directly run them in the use-case conditions to know if the smashed model can benefit you.
42
+ - ***What is the model format?*** We used a custom Pruna model format based on pickle to make models compatible with the compression methods. We provide a tutorial to run models in dockers in the documentation [here](https://pruna-ai-pruna.readthedocs-hosted.com/en/latest/) if needed.
43
+ - ***What is the naming convention for Pruna Huggingface models?*** We take the original model name and append "turbo", "tiny", or "green" if the smashed model has a measured inference speed, inference memory, or inference energy consumption which is less than 90% of the original base model.
44
+ - ***How to compress my own models?*** You can request premium access to more compression methods and tech support for your specific use-cases [here](https://z0halsaff74.typeform.com/pruna-access?typeform-source=www.pruna.ai).
45
+ - ***What are "first" metrics?*** Results mentioning "first" are obtained after the first run of the model. The first run might take more memory or be slower than the subsequent runs due cuda overheads.
46
+
47
+ ## Setup
48
+
49
+ You can run the smashed model with these steps:
50
+
51
+ 0. Check that you have linux, python 3.10, and cuda 12.1.0 requirements installed. For cuda, check with `nvcc --version` and install with `conda install nvidia/label/cuda-12.1.0::cuda`.
52
+ 1. Install the `pruna-engine` available [here](https://pypi.org/project/pruna-engine/) on Pypi. It might take up to 15 minutes to install.
53
+ ```bash
54
+ pip install pruna-engine[gpu]==0.7.1 --extra-index-url https://pypi.nvidia.com --extra-index-url https://pypi.ngc.nvidia.com --extra-index-url https://prunaai.pythonanywhere.com/
55
+ ```
56
+ 3. Download the model files using one of these three options.
57
+ - Option 1 - Use command line interface (CLI):
58
+ ```bash
59
+ mkdir leosams-moonfilm-fp16cleaned-turbo-green-smashed
60
+ huggingface-cli download PrunaAI/leosams-moonfilm-fp16cleaned-turbo-green-smashed --local-dir leosams-moonfilm-fp16cleaned-turbo-green-smashed --local-dir-use-symlinks False
61
+ ```
62
+ - Option 2 - Use Python:
63
+ ```python
64
+ import subprocess
65
+ repo_name = "leosams-moonfilm-fp16cleaned-turbo-green-smashed"
66
+ subprocess.run(["mkdir", repo_name])
67
+ subprocess.run(["huggingface-cli", "download", 'PrunaAI/'+ repo_name, "--local-dir", repo_name, "--local-dir-use-symlinks", "False"])
68
+ ```
69
+ - Option 3 - Download them manually on the HuggingFace model page.
70
+ 3. Load & run the model.
71
+ ```python
72
+ from pruna_engine.PrunaModel import PrunaModel
73
+
74
+ model_path = "leosams-moonfilm-fp16cleaned-turbo-green-smashed/model" # Specify the downloaded model path.
75
+ smashed_model = PrunaModel.load_model(model_path) # Load the model.
76
+ smashed_model(prompt='Beautiful fruits in trees', height=1024, width=1024)[0][0] # Run the model where x is the expected input the model.
77
+ ```
78
+
79
+ ## Configurations
80
+
81
+ The configuration info are in `model/smash_config.json`.
82
+
83
+ ## Credits & License
84
+
85
+ The license of the smashed model follows the license of the original model. Please check the license of the original model https://civitai.com/api/download/models/135862 before using this model which provided the base model. The license of the `pruna-engine` is [here](https://pypi.org/project/pruna-engine/) on Pypi.
86
+
87
+ ## Want to compress other models?
88
+
89
+ - Contact us and tell us which model to compress next [here](https://www.pruna.ai/contact).
90
+ - Request access to easily compress your own AI models [here](https://z0halsaff74.typeform.com/pruna-access?typeform-source=www.pruna.ai).
model/optimized_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b698d161e35411a45e68757222c9309cc95800effb55c1e3244526c15d72b86d
3
+ size 2135131103
model/smash_config.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "api_key": null,
3
+ "verify_url": "http://johnrachwan.pythonanywhere.com",
4
+ "smash_config": {
5
+ "pruners": "None",
6
+ "pruning_ratio": 0.0,
7
+ "factorizers": "None",
8
+ "quantizers": "None",
9
+ "n_quantization_bits": 32,
10
+ "output_deviation": 0.005,
11
+ "compilers": "['diffusers2', 'tiling', 'step_caching']",
12
+ "static_batch": true,
13
+ "static_shape": false,
14
+ "controlnet": "None",
15
+ "unet_dim": 4,
16
+ "device": "cuda",
17
+ "cache_dir": "/ceph/hdd/staff/charpent/.cache/modelsqge_odq8",
18
+ "batch_size": 1,
19
+ "max_batch_size": 1,
20
+ "image_height": 1024,
21
+ "image_width": 1024,
22
+ "version": "1.5",
23
+ "scheduler": "DDIM",
24
+ "task": "txt2img",
25
+ "model_url": "https://civitai.com/api/download/models/135862",
26
+ "model_name": "leosams-moonfilm-fp16cleaned",
27
+ "weight_name": "None",
28
+ "save_load_fn": "stable_fast"
29
+ }
30
+ }
plots.png ADDED