Anthonyg5005 commited on
Commit
fa0da4d
Β·
1 Parent(s): 14bc998

create ipynb folder

Browse files
Screenshot 2024-03-17 011855.png DELETED
Binary file (125 kB)
 
EXL2_Private_Quant_V1.ipynb β†’ ipynb/EXL2_Private_Quant_V1.ipynb RENAMED
File without changes
EXL2_Private_Quant_V2.ipynb β†’ ipynb/EXL2_Private_Quant_V2.ipynb RENAMED
@@ -1,32 +1,16 @@
1
  {
2
- "nbformat": 4,
3
- "nbformat_minor": 0,
4
- "metadata": {
5
- "colab": {
6
- "provenance": [],
7
- "gpuType": "T4"
8
- },
9
- "kernelspec": {
10
- "name": "python3",
11
- "display_name": "Python 3"
12
- },
13
- "language_info": {
14
- "name": "python"
15
- },
16
- "accelerator": "GPU"
17
- },
18
  "cells": [
19
  {
20
  "cell_type": "markdown",
 
 
 
21
  "source": [
22
  "#Quantizing huggingface models to exl2\n",
23
  "This version of my exl2 quantize colab creates a single quantizaion to upload privatly.\\\n",
24
  "To calculate an estimate for VRAM size use: [NyxKrage/LLM-Model-VRAM-Calculator](https://huggingface.co/spaces/NyxKrage/LLM-Model-VRAM-Calculator)\\\n",
25
  "Not all models and architectures are compatible with exl2."
26
- ],
27
- "metadata": {
28
- "id": "Ku0ezvyD42ng"
29
- }
30
  },
31
  {
32
  "cell_type": "code",
@@ -51,6 +35,12 @@
51
  },
52
  {
53
  "cell_type": "code",
 
 
 
 
 
 
54
  "source": [
55
  "#@title Login to HF (Required to upload files)\n",
56
  "#@markdown From my Colab/Kaggle login script on [Anthonyg5005/hf-scripts](https://huggingface.co/Anthonyg5005/hf-scripts/blob/main/HF%20Login%20Snippet%20Kaggle.py)\n",
@@ -104,16 +94,16 @@
104
  " login(input(\"Enter your HuggingFace (WRITE) token: \"))\n",
105
  " continue\n",
106
  " break"
107
- ],
108
- "metadata": {
109
- "cellView": "form",
110
- "id": "8Hl3fQmRLybp"
111
- },
112
- "execution_count": null,
113
- "outputs": []
114
  },
115
  {
116
  "cell_type": "code",
 
 
 
 
 
 
117
  "source": [
118
  "#@title ##Choose HF model to download\n",
119
  "#@markdown ###Repo should be formatted as user/repo\n",
@@ -124,16 +114,16 @@
124
  "repo_url = \"mistralai/Mistral-7B-Instruct-v0.2\" # @param {type:\"string\"}\n",
125
  "model = repo_url.replace(\"/\", \"_\")\n",
126
  "!python download-model.py {repo_url}"
127
- ],
128
- "metadata": {
129
- "cellView": "form",
130
- "id": "NI1LUMD7H-Zx"
131
- },
132
- "execution_count": null,
133
- "outputs": []
134
  },
135
  {
136
  "cell_type": "code",
 
 
 
 
 
 
137
  "source": [
138
  "#@title Quantize the model\n",
139
  "#@markdown ###Takes ~13 minutes to start quantizing first time, then quantization will last based on model size\n",
@@ -153,22 +143,22 @@
153
  " dsd = 'true'\n",
154
  " dataset = dataset_url.split(\"/\")[-1]\n",
155
  "#@markdown To use a calibration dataset, enter the huggingface resolve url. Right click the download button and copy the link. Afterwards, paste the link into dataset_url.\n",
156
- "#@markdown ![Example Image](https://huggingface.co/Anthonyg5005/hf-scripts/resolve/main/Screenshot%202024-03-17%20011855.png \"Copy from download button\")\n",
157
  "if Calibrate == True:\n",
158
  " quant = f\"convert.py -i models/{model} -o {model}-exl2-{BPW}bpw-WD -cf {model}-exl2-{BPW}bpw -c {dataset} -b {BPW}\"\n",
159
  "else:\n",
160
  " quant = f\"convert.py -i models/{model} -o {model}-exl2-{BPW}bpw-WD -cf {model}-exl2-{BPW}bpw -b {BPW}\"\n",
161
  "!python {quant}"
162
- ],
163
- "metadata": {
164
- "id": "8anbEbGyNmBI",
165
- "cellView": "form"
166
- },
167
- "execution_count": null,
168
- "outputs": []
169
  },
170
  {
171
  "cell_type": "code",
 
 
 
 
 
 
172
  "source": [
173
  "#@title Upload to huggingface privately\n",
174
  "#@markdown You may also set it to public but I'd recommend waiting for my next ipynb that will create mutliple quants and place them all into individual branches.\n",
@@ -179,13 +169,23 @@
179
  "create_repo(f\"{whoami().get('name', None)}/{model}-exl2-{BPW}bpw\", private=True)\n",
180
  "HfApi().upload_folder(folder_path=f\"{model}-exl2-{BPW}bpw\", repo_id=f\"{whoami().get('name', None)}/{model}-exl2-{BPW}bpw\", repo_type=\"model\", commit_message=\"Upload from Colab automation\")\n",
181
  "print(f\"uploaded to {whoami().get('name', None)}/{model}-exl2-{BPW}bpw\")"
182
- ],
183
- "metadata": {
184
- "cellView": "form",
185
- "id": "XORLS2uPrbma"
186
- },
187
- "execution_count": null,
188
- "outputs": []
189
  }
190
- ]
191
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  "cells": [
3
  {
4
  "cell_type": "markdown",
5
+ "metadata": {
6
+ "id": "Ku0ezvyD42ng"
7
+ },
8
  "source": [
9
  "#Quantizing huggingface models to exl2\n",
10
  "This version of my exl2 quantize colab creates a single quantizaion to upload privatly.\\\n",
11
  "To calculate an estimate for VRAM size use: [NyxKrage/LLM-Model-VRAM-Calculator](https://huggingface.co/spaces/NyxKrage/LLM-Model-VRAM-Calculator)\\\n",
12
  "Not all models and architectures are compatible with exl2."
13
+ ]
 
 
 
14
  },
15
  {
16
  "cell_type": "code",
 
35
  },
36
  {
37
  "cell_type": "code",
38
+ "execution_count": null,
39
+ "metadata": {
40
+ "cellView": "form",
41
+ "id": "8Hl3fQmRLybp"
42
+ },
43
+ "outputs": [],
44
  "source": [
45
  "#@title Login to HF (Required to upload files)\n",
46
  "#@markdown From my Colab/Kaggle login script on [Anthonyg5005/hf-scripts](https://huggingface.co/Anthonyg5005/hf-scripts/blob/main/HF%20Login%20Snippet%20Kaggle.py)\n",
 
94
  " login(input(\"Enter your HuggingFace (WRITE) token: \"))\n",
95
  " continue\n",
96
  " break"
97
+ ]
 
 
 
 
 
 
98
  },
99
  {
100
  "cell_type": "code",
101
+ "execution_count": null,
102
+ "metadata": {
103
+ "cellView": "form",
104
+ "id": "NI1LUMD7H-Zx"
105
+ },
106
+ "outputs": [],
107
  "source": [
108
  "#@title ##Choose HF model to download\n",
109
  "#@markdown ###Repo should be formatted as user/repo\n",
 
114
  "repo_url = \"mistralai/Mistral-7B-Instruct-v0.2\" # @param {type:\"string\"}\n",
115
  "model = repo_url.replace(\"/\", \"_\")\n",
116
  "!python download-model.py {repo_url}"
117
+ ]
 
 
 
 
 
 
118
  },
119
  {
120
  "cell_type": "code",
121
+ "execution_count": null,
122
+ "metadata": {
123
+ "cellView": "form",
124
+ "id": "8anbEbGyNmBI"
125
+ },
126
+ "outputs": [],
127
  "source": [
128
  "#@title Quantize the model\n",
129
  "#@markdown ###Takes ~13 minutes to start quantizing first time, then quantization will last based on model size\n",
 
143
  " dsd = 'true'\n",
144
  " dataset = dataset_url.split(\"/\")[-1]\n",
145
  "#@markdown To use a calibration dataset, enter the huggingface resolve url. Right click the download button and copy the link. Afterwards, paste the link into dataset_url.\n",
146
+ "#@markdown ![Example Image](https://huggingface.co/Anthonyg5005/hf-scripts/resolve/main/ipynb/dataset-example.jpg \"Copy from download button\")\n",
147
  "if Calibrate == True:\n",
148
  " quant = f\"convert.py -i models/{model} -o {model}-exl2-{BPW}bpw-WD -cf {model}-exl2-{BPW}bpw -c {dataset} -b {BPW}\"\n",
149
  "else:\n",
150
  " quant = f\"convert.py -i models/{model} -o {model}-exl2-{BPW}bpw-WD -cf {model}-exl2-{BPW}bpw -b {BPW}\"\n",
151
  "!python {quant}"
152
+ ]
 
 
 
 
 
 
153
  },
154
  {
155
  "cell_type": "code",
156
+ "execution_count": null,
157
+ "metadata": {
158
+ "cellView": "form",
159
+ "id": "XORLS2uPrbma"
160
+ },
161
+ "outputs": [],
162
  "source": [
163
  "#@title Upload to huggingface privately\n",
164
  "#@markdown You may also set it to public but I'd recommend waiting for my next ipynb that will create mutliple quants and place them all into individual branches.\n",
 
169
  "create_repo(f\"{whoami().get('name', None)}/{model}-exl2-{BPW}bpw\", private=True)\n",
170
  "HfApi().upload_folder(folder_path=f\"{model}-exl2-{BPW}bpw\", repo_id=f\"{whoami().get('name', None)}/{model}-exl2-{BPW}bpw\", repo_type=\"model\", commit_message=\"Upload from Colab automation\")\n",
171
  "print(f\"uploaded to {whoami().get('name', None)}/{model}-exl2-{BPW}bpw\")"
172
+ ]
 
 
 
 
 
 
173
  }
174
+ ],
175
+ "metadata": {
176
+ "accelerator": "GPU",
177
+ "colab": {
178
+ "gpuType": "T4",
179
+ "provenance": []
180
+ },
181
+ "kernelspec": {
182
+ "display_name": "Python 3",
183
+ "name": "python3"
184
+ },
185
+ "language_info": {
186
+ "name": "python"
187
+ }
188
+ },
189
+ "nbformat": 4,
190
+ "nbformat_minor": 0
191
+ }
EXL2_Private_Quant_V3.ipynb β†’ ipynb/EXL2_Private_Quant_V3.ipynb RENAMED
@@ -1,23 +1,10 @@
1
  {
2
- "nbformat": 4,
3
- "nbformat_minor": 0,
4
- "metadata": {
5
- "colab": {
6
- "provenance": [],
7
- "gpuType": "T4"
8
- },
9
- "kernelspec": {
10
- "name": "python3",
11
- "display_name": "Python 3"
12
- },
13
- "language_info": {
14
- "name": "python"
15
- },
16
- "accelerator": "GPU"
17
- },
18
  "cells": [
19
  {
20
  "cell_type": "markdown",
 
 
 
21
  "source": [
22
  "#Quantizing huggingface models to exl2\n",
23
  "This version of my exl2 quantize colab creates a single quantizaion to upload privatly.\\\n",
@@ -25,10 +12,7 @@
25
  "Not all models and architectures are compatible with exl2.\\\n",
26
  "I've only tested with llama-7b and mistral-7b, not sure if higher size models work with free colab.\\\n",
27
  "More stuff in [Anthonyg5005/hf-scripts](https://huggingface.co/Anthonyg5005/hf-scripts)"
28
- ],
29
- "metadata": {
30
- "id": "Ku0ezvyD42ng"
31
- }
32
  },
33
  {
34
  "cell_type": "code",
@@ -54,6 +38,12 @@
54
  },
55
  {
56
  "cell_type": "code",
 
 
 
 
 
 
57
  "source": [
58
  "#@title Login to HF (Required to upload files)\n",
59
  "#@markdown From my Colab/Kaggle login script on [Anthonyg5005/hf-scripts](https://huggingface.co/Anthonyg5005/hf-scripts/blob/main/HF%20Login%20Snippet%20Kaggle.py)\n",
@@ -107,16 +97,16 @@
107
  " login(input(\"Enter your HuggingFace (WRITE) token: \"))\n",
108
  " continue\n",
109
  " break"
110
- ],
111
- "metadata": {
112
- "cellView": "form",
113
- "id": "8Hl3fQmRLybp"
114
- },
115
- "execution_count": null,
116
- "outputs": []
117
  },
118
  {
119
  "cell_type": "code",
 
 
 
 
 
 
120
  "source": [
121
  "#@title ##Choose HF model to download\n",
122
  "#@markdown ###Repo should be formatted as user/repo\n",
@@ -135,17 +125,17 @@
135
  " !mv models/{model}-st models/{model}\n",
136
  " print(\"Finished converting\")\n",
137
  "#@markdown If model files are stored in a pytorch .bin extention then enable convert_safetensors above.\\\n",
138
- "#@markdown ![Example Image](https://huggingface.co/Anthonyg5005/hf-scripts/resolve/cc906d1e41e80ac2e01dae68c6ad61eb5cbcd253/pytorch-example.jpg \"File extension is .bin\")"
139
- ],
140
- "metadata": {
141
- "cellView": "form",
142
- "id": "NI1LUMD7H-Zx"
143
- },
144
- "execution_count": null,
145
- "outputs": []
146
  },
147
  {
148
  "cell_type": "code",
 
 
 
 
 
 
149
  "source": [
150
  "#@title Quantize the model\n",
151
  "#@markdown ###Takes ~13 minutes to start quantizing first time, then quantization will last based on model size\n",
@@ -166,7 +156,7 @@
166
  " dataset = dataset_url.split(\"/\")[-1]\n",
167
  " dataset_jtp = dataset.split(\".\")[0]\n",
168
  "#@markdown To use a calibration dataset, enter the huggingface resolve url. Right click the download button and copy the link. Afterwards, paste the link into dataset_url. So far only supports public datasets.\\\n",
169
- "#@markdown ![Example Image](https://huggingface.co/Anthonyg5005/hf-scripts/resolve/cc906d1e41e80ac2e01dae68c6ad61eb5cbcd253/dataset-example.jpg \"Copy from download button\")\\\n",
170
  "#@markdown If dataset is jsonl then convert to parquet. (Not always reliable, must be formatted correctly)\n",
171
  "convert_parquet = False # @param {type:\"boolean\"}\n",
172
  "if convert_parquet == True:\n",
@@ -195,23 +185,23 @@
195
  " jsonl_to_parquet(dataset, f\"{dataset_jtp}.parquet\") #GitHub Copilot generated\n",
196
  " dataset = f\"{dataset_jtp}.parquet\"\n",
197
  "#@markdown Quantizing only allows for parquet datasets to be used. Enable convert_parquet if your dataset ends in a .jsonl extention.\\\n",
198
- "#@markdown ![Example Image](https://huggingface.co/Anthonyg5005/hf-scripts/resolve/37359e9521d5e2e05f6365fc8643712c19768f94/jsonl-example.jpg \"File extension is .jsonl\")\\\n",
199
  "#@markdown pippa is used as an example in this image. This dataset contains content that is not suitable for users under 18. This dataset also may or may not be against colab TOS. It won't be allowed under free colab usage although you're able to use it with paid compute units.\n",
200
  "if Calibrate == True:\n",
201
  " quant = f\"convert.py -i models/{model} -o {model}-exl2-{BPW}bpw-WD -cf {model}-exl2-{BPW}bpw -c {dataset} -b {BPW}\"\n",
202
  "else:\n",
203
  " quant = f\"convert.py -i models/{model} -o {model}-exl2-{BPW}bpw-WD -cf {model}-exl2-{BPW}bpw -b {BPW}\"\n",
204
  "!python {quant}"
205
- ],
206
- "metadata": {
207
- "id": "8anbEbGyNmBI",
208
- "cellView": "form"
209
- },
210
- "execution_count": null,
211
- "outputs": []
212
  },
213
  {
214
  "cell_type": "code",
 
 
 
 
 
 
215
  "source": [
216
  "#@title Upload to huggingface privately\n",
217
  "#@markdown You may also set it to public but I'd recommend waiting for my next ipynb that will create mutliple quants and place them all into individual branches.\n",
@@ -222,13 +212,23 @@
222
  "create_repo(f\"{whoami().get('name', None)}/{model}-exl2-{BPW}bpw\", private=True)\n",
223
  "HfApi().upload_folder(folder_path=f\"{model}-exl2-{BPW}bpw\", repo_id=f\"{whoami().get('name', None)}/{model}-exl2-{BPW}bpw\", repo_type=\"model\", commit_message=\"Upload from Colab automation\")\n",
224
  "print(f\"uploaded to https://huggingface.co/{whoami().get('name', None)}/{model}-exl2-{BPW}bpw\")"
225
- ],
226
- "metadata": {
227
- "cellView": "form",
228
- "id": "XORLS2uPrbma"
229
- },
230
- "execution_count": null,
231
- "outputs": []
232
  }
233
- ]
234
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  "cells": [
3
  {
4
  "cell_type": "markdown",
5
+ "metadata": {
6
+ "id": "Ku0ezvyD42ng"
7
+ },
8
  "source": [
9
  "#Quantizing huggingface models to exl2\n",
10
  "This version of my exl2 quantize colab creates a single quantizaion to upload privatly.\\\n",
 
12
  "Not all models and architectures are compatible with exl2.\\\n",
13
  "I've only tested with llama-7b and mistral-7b, not sure if higher size models work with free colab.\\\n",
14
  "More stuff in [Anthonyg5005/hf-scripts](https://huggingface.co/Anthonyg5005/hf-scripts)"
15
+ ]
 
 
 
16
  },
17
  {
18
  "cell_type": "code",
 
38
  },
39
  {
40
  "cell_type": "code",
41
+ "execution_count": null,
42
+ "metadata": {
43
+ "cellView": "form",
44
+ "id": "8Hl3fQmRLybp"
45
+ },
46
+ "outputs": [],
47
  "source": [
48
  "#@title Login to HF (Required to upload files)\n",
49
  "#@markdown From my Colab/Kaggle login script on [Anthonyg5005/hf-scripts](https://huggingface.co/Anthonyg5005/hf-scripts/blob/main/HF%20Login%20Snippet%20Kaggle.py)\n",
 
97
  " login(input(\"Enter your HuggingFace (WRITE) token: \"))\n",
98
  " continue\n",
99
  " break"
100
+ ]
 
 
 
 
 
 
101
  },
102
  {
103
  "cell_type": "code",
104
+ "execution_count": null,
105
+ "metadata": {
106
+ "cellView": "form",
107
+ "id": "NI1LUMD7H-Zx"
108
+ },
109
+ "outputs": [],
110
  "source": [
111
  "#@title ##Choose HF model to download\n",
112
  "#@markdown ###Repo should be formatted as user/repo\n",
 
125
  " !mv models/{model}-st models/{model}\n",
126
  " print(\"Finished converting\")\n",
127
  "#@markdown If model files are stored in a pytorch .bin extention then enable convert_safetensors above.\\\n",
128
+ "#@markdown ![Example Image](https://huggingface.co/Anthonyg5005/hf-scripts/resolve/main/ipynb/pytorch-example.jpg \"File extension is .bin\")"
129
+ ]
 
 
 
 
 
 
130
  },
131
  {
132
  "cell_type": "code",
133
+ "execution_count": null,
134
+ "metadata": {
135
+ "cellView": "form",
136
+ "id": "8anbEbGyNmBI"
137
+ },
138
+ "outputs": [],
139
  "source": [
140
  "#@title Quantize the model\n",
141
  "#@markdown ###Takes ~13 minutes to start quantizing first time, then quantization will last based on model size\n",
 
156
  " dataset = dataset_url.split(\"/\")[-1]\n",
157
  " dataset_jtp = dataset.split(\".\")[0]\n",
158
  "#@markdown To use a calibration dataset, enter the huggingface resolve url. Right click the download button and copy the link. Afterwards, paste the link into dataset_url. So far only supports public datasets.\\\n",
159
+ "#@markdown ![Example Image](https://huggingface.co/Anthonyg5005/hf-scripts/resolve/main/ipynb/dataset-example.jpg \"Copy from download button\")\\\n",
160
  "#@markdown If dataset is jsonl then convert to parquet. (Not always reliable, must be formatted correctly)\n",
161
  "convert_parquet = False # @param {type:\"boolean\"}\n",
162
  "if convert_parquet == True:\n",
 
185
  " jsonl_to_parquet(dataset, f\"{dataset_jtp}.parquet\") #GitHub Copilot generated\n",
186
  " dataset = f\"{dataset_jtp}.parquet\"\n",
187
  "#@markdown Quantizing only allows for parquet datasets to be used. Enable convert_parquet if your dataset ends in a .jsonl extention.\\\n",
188
+ "#@markdown ![Example Image](https://huggingface.co/Anthonyg5005/hf-scripts/resolve/main/ipynb/jsonl-example.jpg \"File extension is .jsonl\")\\\n",
189
  "#@markdown pippa is used as an example in this image. This dataset contains content that is not suitable for users under 18. This dataset also may or may not be against colab TOS. It won't be allowed under free colab usage although you're able to use it with paid compute units.\n",
190
  "if Calibrate == True:\n",
191
  " quant = f\"convert.py -i models/{model} -o {model}-exl2-{BPW}bpw-WD -cf {model}-exl2-{BPW}bpw -c {dataset} -b {BPW}\"\n",
192
  "else:\n",
193
  " quant = f\"convert.py -i models/{model} -o {model}-exl2-{BPW}bpw-WD -cf {model}-exl2-{BPW}bpw -b {BPW}\"\n",
194
  "!python {quant}"
195
+ ]
 
 
 
 
 
 
196
  },
197
  {
198
  "cell_type": "code",
199
+ "execution_count": null,
200
+ "metadata": {
201
+ "cellView": "form",
202
+ "id": "XORLS2uPrbma"
203
+ },
204
+ "outputs": [],
205
  "source": [
206
  "#@title Upload to huggingface privately\n",
207
  "#@markdown You may also set it to public but I'd recommend waiting for my next ipynb that will create mutliple quants and place them all into individual branches.\n",
 
212
  "create_repo(f\"{whoami().get('name', None)}/{model}-exl2-{BPW}bpw\", private=True)\n",
213
  "HfApi().upload_folder(folder_path=f\"{model}-exl2-{BPW}bpw\", repo_id=f\"{whoami().get('name', None)}/{model}-exl2-{BPW}bpw\", repo_type=\"model\", commit_message=\"Upload from Colab automation\")\n",
214
  "print(f\"uploaded to https://huggingface.co/{whoami().get('name', None)}/{model}-exl2-{BPW}bpw\")"
215
+ ]
 
 
 
 
 
 
216
  }
217
+ ],
218
+ "metadata": {
219
+ "accelerator": "GPU",
220
+ "colab": {
221
+ "gpuType": "T4",
222
+ "provenance": []
223
+ },
224
+ "kernelspec": {
225
+ "display_name": "Python 3",
226
+ "name": "python3"
227
+ },
228
+ "language_info": {
229
+ "name": "python"
230
+ }
231
+ },
232
+ "nbformat": 4,
233
+ "nbformat_minor": 0
234
+ }
dataset-example.jpg β†’ ipynb/dataset-example.jpg RENAMED
File without changes
jsonl-example.jpg β†’ ipynb/jsonl-example.jpg RENAMED
File without changes
pytorch-example.jpg β†’ ipynb/pytorch-example.jpg RENAMED
File without changes