sharpenb commited on
Commit
a58d6ea
·
verified ·
1 Parent(s): 4dfe3ad

Upload folder using huggingface_hub (#1)

Browse files

- 52739febc7f6e85fa42fdd93ed79b3e60480bb2beaab2be5c4fb1ec5b85b111b (e1a939278ccdf5a007d5d9131838231406629b51)

Files changed (5) hide show
  1. README.md +89 -0
  2. config.json +98 -0
  3. pretrained_config.py +30 -0
  4. qmodel.pt +3 -0
  5. smash_config.json +34 -0
README.md ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ thumbnail: "https://assets-global.website-files.com/646b351987a8d8ce158d1940/64ec9e96b4334c0e1ac41504_Logo%20with%20white%20text.svg"
3
+ base_model: ORIGINAL_REPO_NAME
4
+ metrics:
5
+ - memory_disk
6
+ - memory_inference
7
+ - inference_latency
8
+ - inference_throughput
9
+ - inference_CO2_emissions
10
+ - inference_energy_consumption
11
+ tags:
12
+ - pruna-ai
13
+ ---
14
+ <!-- header start -->
15
+ <!-- 200823 -->
16
+ <div style="width: auto; margin-left: auto; margin-right: auto">
17
+ <a href="https://www.pruna.ai/" target="_blank" rel="noopener noreferrer">
18
+ <img src="https://i.imgur.com/eDAlcgk.png" alt="PrunaAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
19
+ </a>
20
+ </div>
21
+ <!-- header end -->
22
+
23
+ [![Twitter](https://img.shields.io/twitter/follow/PrunaAI?style=social)](https://twitter.com/PrunaAI)
24
+ [![GitHub](https://img.shields.io/github/followers/PrunaAI?label=Follow%20%40PrunaAI&style=social)](https://github.com/PrunaAI)
25
+ [![LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-blue)](https://www.linkedin.com/company/93832878/admin/feed/posts/?feedType=following)
26
+ [![Discord](https://img.shields.io/badge/Discord-Join%20Us-blue?style=social&logo=discord)](https://discord.gg/rskEr4BZJx)
27
+
28
+ # Simply make AI models cheaper, smaller, faster, and greener!
29
+
30
+ - Give a thumbs up if you like this model!
31
+ - Contact us and tell us which model to compress next [here](https://www.pruna.ai/contact).
32
+ - Request access to easily compress your *own* AI models [here](https://z0halsaff74.typeform.com/pruna-access?typeform-source=www.pruna.ai).
33
+ - Read the documentations to know more [here](https://pruna-ai-pruna.readthedocs-hosted.com/en/latest/)
34
+ - Join Pruna AI community on Discord [here](https://discord.gg/CP4VSgck) to share feedback/suggestions or get help.
35
+
36
+ ## Results
37
+
38
+ ![image info](./plots.png)
39
+
40
+ **Frequently Asked Questions**
41
+ - ***How does the compression work?*** The model is compressed with hqq.
42
+ - ***How does the model quality change?*** The quality of the model output might vary compared to the base model.
43
+ - ***How is the model efficiency evaluated?*** These results were obtained 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.
44
+ - ***What is the model format?*** We use safetensors.
45
+ - ***What calibration data has been used?*** If needed by the compression method, we used WikiText as the calibration data.
46
+ - ***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.
47
+ - ***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).
48
+ - ***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.
49
+ - ***What are "Sync" and "Async" metrics?*** "Sync" metrics are obtained by syncing all GPU processes and stop measurement when all of them are executed. "Async" metrics are obtained without syncing all GPU processes and stop when the model output can be used by the CPU. We provide both metrics since both could be relevant depending on the use-case. We recommend to test the efficiency gains directly in your use-cases.
50
+
51
+ ## Setup
52
+
53
+ You can run the smashed model with these steps:
54
+
55
+ 0. Check requirements from the original repo ORIGINAL_REPO_NAME installed. In particular, check python, cuda, and transformers versions.
56
+ 1. Make sure that you have installed quantization related packages.
57
+ ```bash
58
+ pip install hqq
59
+ ```
60
+ 2. Load & run the model.
61
+ ```python
62
+ from transformers import AutoModelForCausalLM, AutoTokenizer
63
+ from hqq.engine.hf import HQQModelForCausalLM
64
+ from hqq.models.hf.base import AutoHQQHFModel
65
+
66
+ try:
67
+ model = HQQModelForCausalLM.from_quantized("PrunaAI/BeardedMonster-SabiYarn-diacritics-cleaner-HQQ-4bit-smashed", device_map='auto')
68
+ except:
69
+ model = AutoHQQHFModel.from_quantized("PrunaAI/BeardedMonster-SabiYarn-diacritics-cleaner-HQQ-4bit-smashed")
70
+ tokenizer = AutoTokenizer.from_pretrained("ORIGINAL_REPO_NAME")
71
+
72
+ input_ids = tokenizer("What is the color of prunes?,", return_tensors='pt').to(model.device)["input_ids"]
73
+
74
+ outputs = model.generate(input_ids, max_new_tokens=216)
75
+ tokenizer.decode(outputs[0])
76
+ ```
77
+
78
+ ## Configurations
79
+
80
+ The configuration info are in `smash_config.json`.
81
+
82
+ ## Credits & License
83
+
84
+ The license of the smashed model follows the license of the original model. Please check the license of the original model ORIGINAL_REPO_NAME 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.
85
+
86
+ ## Want to compress other models?
87
+
88
+ - Contact us and tell us which model to compress next [here](https://www.pruna.ai/contact).
89
+ - Request access to easily compress your own AI models [here](https://z0halsaff74.typeform.com/pruna-access?typeform-source=www.pruna.ai).
config.json ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "/tmp/models/tmp3y5bwtdu/tmpj0r4i7dk",
3
+ "architectures": [
4
+ "GPTJXForCausalLM"
5
+ ],
6
+ "auto_map": {
7
+ "AutoConfig": "pretrained_config.GPTJXConfig",
8
+ "AutoModelForCausalLM": "BeardedMonster/SabiYarn-125M--pretrained_model.GPTJXForCausalLM"
9
+ },
10
+ "bias": false,
11
+ "block_size": 1024,
12
+ "dropout": 0.0,
13
+ "model_type": "nanogpt-j",
14
+ "n_embd": 768,
15
+ "n_head": 12,
16
+ "n_layer": 12,
17
+ "quantization_config": {
18
+ "transformer.h.attn.c_attn": {
19
+ "offload_meta": false,
20
+ "scale_quant_params": null,
21
+ "weight_quant_params": {
22
+ "axis": 0,
23
+ "channel_wise": true,
24
+ "group_size": 64,
25
+ "nbits": 4,
26
+ "optimize": true,
27
+ "round_zero": true,
28
+ "view_as_float": false
29
+ },
30
+ "zero_quant_params": {
31
+ "channel_wise": false,
32
+ "group_size": null,
33
+ "nbits": 8,
34
+ "optimize": false
35
+ }
36
+ },
37
+ "transformer.h.attn.c_proj": {
38
+ "offload_meta": false,
39
+ "scale_quant_params": null,
40
+ "weight_quant_params": {
41
+ "axis": 0,
42
+ "channel_wise": true,
43
+ "group_size": 64,
44
+ "nbits": 4,
45
+ "optimize": true,
46
+ "round_zero": true,
47
+ "view_as_float": false
48
+ },
49
+ "zero_quant_params": {
50
+ "channel_wise": false,
51
+ "group_size": null,
52
+ "nbits": 8,
53
+ "optimize": false
54
+ }
55
+ },
56
+ "transformer.h.mlp.c_fc": {
57
+ "offload_meta": false,
58
+ "scale_quant_params": null,
59
+ "weight_quant_params": {
60
+ "axis": 0,
61
+ "channel_wise": true,
62
+ "group_size": 64,
63
+ "nbits": 4,
64
+ "optimize": true,
65
+ "round_zero": true,
66
+ "view_as_float": false
67
+ },
68
+ "zero_quant_params": {
69
+ "channel_wise": false,
70
+ "group_size": null,
71
+ "nbits": 8,
72
+ "optimize": false
73
+ }
74
+ },
75
+ "transformer.h.mlp.c_proj": {
76
+ "offload_meta": false,
77
+ "scale_quant_params": null,
78
+ "weight_quant_params": {
79
+ "axis": 0,
80
+ "channel_wise": true,
81
+ "group_size": 64,
82
+ "nbits": 4,
83
+ "optimize": true,
84
+ "round_zero": true,
85
+ "view_as_float": false
86
+ },
87
+ "zero_quant_params": {
88
+ "channel_wise": false,
89
+ "group_size": null,
90
+ "nbits": 8,
91
+ "optimize": false
92
+ }
93
+ }
94
+ },
95
+ "torch_dtype": "float32",
96
+ "transformers_version": "4.44.0",
97
+ "vocab_size": 52050
98
+ }
pretrained_config.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import PretrainedConfig
2
+
3
+ repo_name = "BeardedMonster/SabiYarn-125M"
4
+
5
+ class GPTJXConfig(PretrainedConfig):
6
+ model_type="nanogpt-j"
7
+
8
+
9
+ def __init__(self,
10
+ block_size: int = 1024,
11
+ vocab_size: int = 52050, #50304 # GPT-2 vocab_size of 50257, padded up to nearest multiple of 64 for efficiency
12
+ n_layer: int = 12,
13
+ n_head: int = 12,
14
+ n_embd: int = 768,
15
+ dropout: float = 0.0,
16
+ bias: bool = False, # True: bias in Linears and LayerNorms, like GPT-2. False: a bit better and faster
17
+ **kwargs
18
+ ):
19
+
20
+ self.block_size = block_size
21
+ self.vocab_size = vocab_size
22
+ self.n_layer = n_layer
23
+ self.n_head = n_head
24
+ self.n_embd = n_embd
25
+ self.dropout = dropout
26
+ self.bias = bias
27
+
28
+ super().__init__(**kwargs)
29
+
30
+
qmodel.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5f2524c6cd32263ee6c874e05b4e960459e6903d664887de494ea3e841806a91
3
+ size 376230690
smash_config.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "comp_cgenerate_active": false,
3
+ "comp_ctranslate_active": false,
4
+ "comp_cwhisper_active": false,
5
+ "comp_diffusers2_active": false,
6
+ "comp_flux_caching_active": false,
7
+ "comp_ifw_active": false,
8
+ "comp_onediff_active": false,
9
+ "comp_step_caching_active": false,
10
+ "comp_torch_compile_active": false,
11
+ "comp_ws2t_active": false,
12
+ "comp_x-fast_active": false,
13
+ "prune_torch-structured_active": false,
14
+ "prune_torch-unstructured_active": false,
15
+ "quant_aqlm_active": false,
16
+ "quant_awq_active": false,
17
+ "quant_gptq_active": false,
18
+ "quant_half_active": false,
19
+ "quant_hqq_active": true,
20
+ "quant_llm-int8_active": false,
21
+ "quant_quanto_active": false,
22
+ "quant_torch_dynamic_active": false,
23
+ "quant_torch_static_active": false,
24
+ "quant_hqq_backend": "torchao_int4",
25
+ "quant_hqq_group_size": 64,
26
+ "quant_hqq_weight_bits": 4,
27
+ "max_batch_size": 1,
28
+ "device": "cuda",
29
+ "cache_dir": "/tmp/models/tmp3y5bwtdu",
30
+ "task": "",
31
+ "save_load_fn": "hqq",
32
+ "save_load_fn_args": {},
33
+ "api_key": null
34
+ }