TheBloke commited on
Commit
ce33f4d
1 Parent(s): edf9bd9

Initial GPTQ model commit

Browse files
Files changed (1) hide show
  1. README.md +113 -28
README.md CHANGED
@@ -45,11 +45,12 @@ pip3 install git+https://github.com/huggingface/transformers
45
 
46
  If using a UI like text-generation-webui, make sure to do this in the Python environment of text-generation-webui.
47
 
 
48
 
49
  ## Repositories available
50
 
51
  * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/Llama-2-70B-chat-GPTQ)
52
- * [Original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/meta-llama/Llama-2-70b-chat-hf)
53
 
54
  ## Prompt template: Llama-2-Chat
55
 
@@ -67,14 +68,14 @@ Each separate quant is in a different branch. See below for instructions on fet
67
 
68
  | Branch | Bits | Group Size | Act Order (desc_act) | File Size | ExLlama Compatible? | Made With | Description |
69
  | ------ | ---- | ---------- | -------------------- | --------- | ------------------- | --------- | ----------- |
70
- | main | 4 | None | True | 35.33 GB | False | AutoGPTQ | Most compatible option. Good inference speed in AutoGPTQ and GPTQ-for-LLaMa. Lower inference quality than other options. |
71
- | gptq-4bit-32g-actorder_True | 4 | 32 | False | Still processing | True | AutoGPTQ | 4-bit, with Act Order and group size. 32g gives highest possible inference quality, with maximum VRAM usage. Poor AutoGPTQ CUDA speed. |
72
- | gptq-4bit-64g-actorder_True | 4 | 64 | False | Still processing | True | AutoGPTQ | 4-bit, with Act Order and group size. 64g uses less VRAM than 32g, but with slightly lower accuracy. Poor AutoGPTQ CUDA speed. |
73
- | gptq-4bit-128g-actorder_True | 4 | 128 | False | 36.65 GB | True | AutoGPTQ | 4-bit, with Act Order and group size. 128g uses even less VRAM, but with slightly lower accuracy. Poor AutoGPTQ CUDA speed. |
74
- | gptq-3bit--1g-actorder_True | 3 | None | False | Still processing | False | AutoGPTQ | 3-bit, with Act Order and no group size. Lowest possible VRAM requirements. May be lower quality than 3-bit 128g. |
75
- | gptq-3bit-128g-actorder_False | 3 | 128 | False | Still processing | False | AutoGPTQ | 3-bit, with group size 128g but no act-order. Slightly higher VRAM requirements than 3-bit None. |
76
- | gptq-3bit-128g-actorder_True | 3 | 128 | False | Still processing | False | AutoGPTQ | 3-bit, with group size 128g and act-order. Higher quality than 128g-False but poor AutoGPTQ CUDA speed. |
77
- | gptq-3bit-64g-actorder_True | 3 | 64 | False | Still processing | False | AutoGPTQ | 3-bit, with group size 64g and act-order. Highest quality 3-bit option. Poor AutoGPTQ CUDA speed. |
78
 
79
  ## How to download from branches
80
 
@@ -91,38 +92,44 @@ Please make sure you're using the latest version of [text-generation-webui](http
91
 
92
  It is strongly recommended to use the text-generation-webui one-click-installers unless you know how to make a manual install.
93
 
94
- Remember to update Transformers to the latest Github version:
 
95
  ```
96
  pip3 install git+https://github.com/huggingface/transformers
97
  ```
98
 
99
- ExLlama is not currently compatible with Llama 2 70B.
100
 
101
  1. Click the **Model tab**.
102
- 2. Under **Download custom model or LoRA**, enter `TheBloke/Llama-2-70B-chat-GPTQ`.
103
  - To download from a specific branch, enter for example `TheBloke/Llama-2-70B-chat-GPTQ:gptq-4bit-32g-actorder_True`
104
  - see Provided Files above for the list of branches for each option.
105
  3. Click **Download**.
106
  4. The model will start downloading. Once it's finished it will say "Done"
107
- 5. In the top left, click the refresh icon next to **Model**.
108
- 6. In the **Model** dropdown, choose the model you just downloaded: `Llama-2-70B-chat-GPTQ`
109
- 7. The model will automatically load, and is now ready for use!
110
- 8. If you want any custom settings, set them and then click **Save settings for this model** followed by **Reload the Model** in the top right.
111
- * Note that you do not need to set GPTQ parameters any more. These are set automatically from the file `quantize_config.json`.
112
- 9. Once you're ready, click the **Text Generation tab** and enter a prompt to get started!
 
113
 
114
  ## How to use this GPTQ model from Python code
115
 
116
  First make sure you have [AutoGPTQ](https://github.com/PanQiWei/AutoGPTQ) installed:
117
 
118
- `GITHUB_ACTIONS=true pip install auto-gptq`
 
 
119
 
120
- Also update Transformers to the latest Github version:
121
 
122
  ```
123
  pip3 install git+https://github.com/huggingface/transformers
124
  ```
125
 
 
 
126
  Then try the following example code:
127
 
128
  ```python
@@ -130,16 +137,17 @@ from transformers import AutoTokenizer, pipeline, logging
130
  from auto_gptq import AutoGPTQForCausalLM, BaseQuantizeConfig
131
 
132
  model_name_or_path = "TheBloke/Llama-2-70B-chat-GPTQ"
133
- model_basename = "gptq_model-4bit--1g"
134
 
135
  use_triton = False
136
 
137
  tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True)
138
 
139
  model = AutoGPTQForCausalLM.from_quantized(model_name_or_path,
140
- model_basename=model_basename
 
141
  use_safetensors=True,
142
- trust_remote_code=True,
143
  device="cuda:0",
144
  use_triton=use_triton,
145
  quantize_config=None)
@@ -150,16 +158,17 @@ To download from a specific branch, use the revision parameter, as in this examp
150
  model = AutoGPTQForCausalLM.from_quantized(model_name_or_path,
151
  revision="gptq-4bit-32g-actorder_True",
152
  model_basename=model_basename,
 
153
  use_safetensors=True,
154
- trust_remote_code=True,
155
  device="cuda:0",
156
  quantize_config=None)
157
  """
158
 
159
  prompt = "Tell me about AI"
160
- prompt_template=f'''System: You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature. If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.
161
- User: {prompt}
162
- Assistant:
163
  '''
164
 
165
  print("\n\n*** Generate:")
@@ -191,7 +200,83 @@ print(pipe(prompt_template)[0]['generated_text'])
191
 
192
  The files provided will work with AutoGPTQ (CUDA and Triton modes), GPTQ-for-LLaMa (only CUDA has been tested), and Occ4m's GPTQ-for-LLaMa fork.
193
 
194
- ExLlama does not currently work with Llama 2 70B models.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195
 
196
  <!-- footer start -->
197
  ## Discord
 
45
 
46
  If using a UI like text-generation-webui, make sure to do this in the Python environment of text-generation-webui.
47
 
48
+ Note that at the time of writing, ExLlama is not yet compatible with the Llama 2 70B models, but support is coming soon.
49
 
50
  ## Repositories available
51
 
52
  * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/Llama-2-70B-chat-GPTQ)
53
+ * [Original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/TheBloke/Llama-2-70B-chat-fp16)
54
 
55
  ## Prompt template: Llama-2-Chat
56
 
 
68
 
69
  | Branch | Bits | Group Size | Act Order (desc_act) | File Size | ExLlama Compatible? | Made With | Description |
70
  | ------ | ---- | ---------- | -------------------- | --------- | ------------------- | --------- | ----------- |
71
+ | main | 4 | 128 | False | 35332232264.00 GB | False | AutoGPTQ | Most compatible option. Good inference speed in AutoGPTQ and GPTQ-for-LLaMa. Lower inference quality than other options. |
72
+ | gptq-4bit-32g-actorder_True | 4 | 32 | True | 40.66 GB | False | AutoGPTQ | 4-bit, with Act Order and group size. 32g gives highest possible inference quality, with maximum VRAM usage. Poor AutoGPTQ CUDA speed. |
73
+ | gptq-4bit-64g-actorder_True | 4 | 64 | True | 37.99 GB | False | AutoGPTQ | 4-bit, with Act Order and group size. 64g uses less VRAM than 32g, but with slightly lower accuracy. Poor AutoGPTQ CUDA speed. |
74
+ | gptq-4bit-128g-actorder_True | 4 | 128 | True | 36.65 GB | False | AutoGPTQ | 4-bit, with Act Order and group size. 128g uses even less VRAM, but with slightly lower accuracy. Poor AutoGPTQ CUDA speed. |
75
+ | gptq-3bit--1g-actorder_True | 3 | None | True | 26.78 GB | False | AutoGPTQ | 3-bit, with Act Order and no group size. Lowest possible VRAM requirements. May be lower quality than 3-bit 128g. |
76
+ | gptq-3bit-128g-actorder_False | 3 | 128 | False | 28.03 GB | False | AutoGPTQ | 3-bit, with group size 128g but no act-order. Slightly higher VRAM requirements than 3-bit None. |
77
+ | gptq-3bit-128g-actorder_True | 3 | 128 | True | 28.03 GB | False | AutoGPTQ | 3-bit, with group size 128g and act-order. Higher quality than 128g-False but poor AutoGPTQ CUDA speed. |
78
+ | gptq-3bit-64g-actorder_True | 3 | 64 | True | 29.30 GB | False | AutoGPTQ | 3-bit, with group size 64g and act-order. Highest quality 3-bit option. Poor AutoGPTQ CUDA speed. |
79
 
80
  ## How to download from branches
81
 
 
92
 
93
  It is strongly recommended to use the text-generation-webui one-click-installers unless you know how to make a manual install.
94
 
95
+ Before trying the model, first update Transformers to the latest Github code:
96
+
97
  ```
98
  pip3 install git+https://github.com/huggingface/transformers
99
  ```
100
 
101
+ ExLlama is not currently compatible with Llama 2 70B but support is expected soon.
102
 
103
  1. Click the **Model tab**.
104
+ 2. Under **Download custom model or LoRA**, enter `%%REPO_GPTQ`.
105
  - To download from a specific branch, enter for example `TheBloke/Llama-2-70B-chat-GPTQ:gptq-4bit-32g-actorder_True`
106
  - see Provided Files above for the list of branches for each option.
107
  3. Click **Download**.
108
  4. The model will start downloading. Once it's finished it will say "Done"
109
+ 5. Set Loader to AutoGPTQ or GPTQ-for-LLaMA
110
+ - If you use AutoGPTQ, make sure "No inject fused attention" is ticked
111
+ 6. In the top left, click the refresh icon next to **Model**.
112
+ 7. In the **Model** dropdown, choose the model you just downloaded: `TheBloke/Llama-2-70B-chat-GPTQ`
113
+ 8. The model will automatically load, and is now ready for use!
114
+ 9. Then click **Save settings for this model** followed by **Reload the Model** in the top right to make sure your settings are persisted.
115
+ 10. Once you're ready, click the **Text Generation tab** and enter a prompt to get started!
116
 
117
  ## How to use this GPTQ model from Python code
118
 
119
  First make sure you have [AutoGPTQ](https://github.com/PanQiWei/AutoGPTQ) installed:
120
 
121
+ ```
122
+ GITHUB_ACTIONS=true pip3 install auto-gptq
123
+ ```
124
 
125
+ You also need the latest Transformers code from Github:
126
 
127
  ```
128
  pip3 install git+https://github.com/huggingface/transformers
129
  ```
130
 
131
+ You must set `inject_fused_attention=False` as shown below.
132
+
133
  Then try the following example code:
134
 
135
  ```python
 
137
  from auto_gptq import AutoGPTQForCausalLM, BaseQuantizeConfig
138
 
139
  model_name_or_path = "TheBloke/Llama-2-70B-chat-GPTQ"
140
+ model_basename = "gptq_model-4bit-128g"
141
 
142
  use_triton = False
143
 
144
  tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True)
145
 
146
  model = AutoGPTQForCausalLM.from_quantized(model_name_or_path,
147
+ model_basename=model_basename,
148
+ inject_fused_attention=False, # Required for Llama 2 70B model at this time.
149
  use_safetensors=True,
150
+ trust_remote_code=False,
151
  device="cuda:0",
152
  use_triton=use_triton,
153
  quantize_config=None)
 
158
  model = AutoGPTQForCausalLM.from_quantized(model_name_or_path,
159
  revision="gptq-4bit-32g-actorder_True",
160
  model_basename=model_basename,
161
+ inject_fused_attention=False, # Required for Llama 2 70B model at this time.
162
  use_safetensors=True,
163
+ trust_remote_code=False,
164
  device="cuda:0",
165
  quantize_config=None)
166
  """
167
 
168
  prompt = "Tell me about AI"
169
+ prompt_template=f'''SYSTEM: You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature. If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.
170
+ USER: {prompt}
171
+ ASSISTANT:
172
  '''
173
 
174
  print("\n\n*** Generate:")
 
200
 
201
  The files provided will work with AutoGPTQ (CUDA and Triton modes), GPTQ-for-LLaMa (only CUDA has been tested), and Occ4m's GPTQ-for-LLaMa fork.
202
 
203
+ ExLlama is not currently compatible with Llama 2 70B models, but support is coming soon. Please see the Provided Files table above for per-file compatibility.
204
+
205
+ <!-- footer start -->
206
+ ## Discord
207
+
208
+ For further support, and discussions on these models and AI in general, join us at:
209
+
210
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
211
+
212
+ ## Thanks, and how to contribute.
213
+
214
+ Thanks to the [chirper.ai](https://chirper.ai) team!
215
+
216
+ I've had a lot of people ask if they can contribute. I enjoy providing models and helping people, and would love to be able to spend even more time doing it, as well as expanding into new projects like fine tuning/training.
217
+
218
+ If you're able and willing to contribute it will be most gratefully received and will help me to keep providing more models, and to start work on new AI projects.
219
+
220
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
221
+
222
+ * Patreon: https://patreon.com/TheBlokeAI
223
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
224
+
225
+ **Special thanks to**: Luke from CarbonQuill, Aemon Algiz.
226
+
227
+ **Patreon special mentions**: Space Cruiser, Nikolai Manek, Sam, Chris McCloskey, Rishabh Srivastava, Kalila, Spiking Neurons AB, Khalefa Al-Ahmad, WelcomeToTheClub, Chadd, Lone Striker, Viktor Bowallius, Edmond Seymore, Ai Maven, Chris Smitley, Dave, Alexandros Triantafyllidis, Luke @flexchar, Elle, ya boyyy, Talal Aujan, Alex , Jonathan Leane, Deep Realms, Randy H, subjectnull, Preetika Verma, Joseph William Delisle, Michael Levine, chris gileta, K, Oscar Rangel, LangChain4j, Trenton Dambrowitz, Eugene Pentland, Johann-Peter Hartmann, Femi Adebogun, Illia Dulskyi, senxiiz, Daniel P. Andersen, Sean Connelly, Artur Olbinski, RoA, Mano Prime, Derek Yates, Raven Klaugh, David Flickinger, Willem Michiel, Pieter, Willian Hasse, vamX, Luke Pendergrass, webtim, Ghost , Rainer Wilmers, Nathan LeClaire, Will Dee, Cory Kujawski, John Detwiler, Fred von Graf, biorpg, Iucharbius , Imad Khwaja, Pierre Kircher, terasurfer , Asp the Wyvern, John Villwock, theTransient, zynix , Gabriel Tamborski, Fen Risland, Gabriel Puliatti, Matthew Berman, Pyrater, SuperWojo, Stephen Murray, Karl Bernard, Ajan Kanaga, Greatston Gnanesh, Junyu Yang.
228
+
229
+ Thank you to all my generous patrons and donaters!
230
+
231
+ <!-- footer end -->
232
+
233
+ # Original model card: Meta's Llama 2 70B Chat
234
+
235
+
236
+ <!-- header start -->
237
+ <div style="width: 100%;">
238
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
239
+ </div>
240
+ <div style="display: flex; justify-content: space-between; width: 100%;">
241
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
242
+ <p><a href="https://discord.gg/theblokeai">Chat & support: my new Discord server</a></p>
243
+ </div>
244
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
245
+ <p><a href="https://www.patreon.com/TheBlokeAI">Want to contribute? TheBloke's Patreon page</a></p>
246
+ </div>
247
+ </div>
248
+ <!-- header end -->
249
+
250
+ # Meta's Llama 2 70B Chat fp16
251
+
252
+ These files are fp16 pytorch model files for [Meta's Llama 2 70B Chat](https://huggingface.co/meta-llama/Llama-2-70b-chat-hf).
253
+
254
+ They were produced by downloading the PTH files from Meta, and then converting to HF format using the latest Transformers 4.32.0.dev0, from Git, with the Llama 2 PR included: https://github.com/huggingface/transformers/pull/24891.
255
+
256
+ Command to convert was:
257
+ ```
258
+ python3 /workspace/venv/pytorch2/lib/python3.10/site-packages/transformers/models/llama/convert_llama_weights_to_hf.py --input_dir /workspace/git/llama/download --model_size 70B --output_dir /workspace/process/llama-2-70b-chat/source --safe_serialization true
259
+ ```
260
+
261
+ The files were saved in Safetensors format.
262
+
263
+ I am uploading this repo because I initially tried to create GPTQs using the [Meta Llama 2 70B Chat HF repo](https://huggingface.co/meta-llama/Llama-2-70b-chat-hf), but got strange errors that suggested the weights were not correct. But converting from the PTH files using the latest `convert_llama_weights_to_hf.py` script worked fine.
264
+
265
+ Many thanks to William Beauchamp from [Chai](https://chai-research.com/) for providing the hardware for these quantisations!
266
+
267
+ ## Repositories available
268
+
269
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/Llama-2-70B-chat-GPTQ)
270
+ * [Original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/meta-llama/Llama-2-70b-chat-hf)
271
+ * [My fp16 conversion of the unquantised PTH model files](https://huggingface.co/TheBloke/Llama-2-70B-chat-fp16)
272
+
273
+ ## Prompt template: Llama-2-Chat
274
+
275
+ ```
276
+ System: You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature. If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.
277
+ User: {prompt}
278
+ Assistant:
279
+ ```
280
 
281
  <!-- footer start -->
282
  ## Discord