Lin-K76 commited on
Commit
ae670a1
1 Parent(s): 7f1a735

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +181 -14
README.md CHANGED
@@ -7,22 +7,189 @@ tags:
7
  # Mixtral-8x22B-Instruct-v0.1-FP8
8
 
9
  ## Model Overview
10
- Mixtral-8x22B-Instruct-v0.1 quantized to FP8 weights and activations using per-tensor quantization, ready for inference with vLLM >= 0.5.0.
 
 
 
 
 
 
 
 
 
 
11
 
12
- ## Usage and Creation
13
- Produced using [AutoFP8 with calibration samples from ultrachat](https://github.com/neuralmagic/AutoFP8/blob/147fa4d9e1a90ef8a93f96fc7d9c33056ddc017a/example_dataset.py).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
  ## Evaluation
16
 
17
- ### Open LLM Leaderboard evaluation scores
18
- | | Mixtral-8x22B-Instruct-v0.1 | Mixtral-8x22B-Instruct-v0.1-FP8<br>(this model) |
19
- | :------------------: | :----------------------: | :------------------------------------------------: |
20
- | arc-c<br>25-shot (acc_norm) | 72.70 | 72.53 |
21
- | hellaswag<br>10-shot (acc_norm) | 89.08 | 88.10 |
22
- | mmlu<br>5-shot | 77.77 | 76.08 |
23
- | truthfulqa<br>0-shot (acc) | 68.14 | 66.32 |
24
- | winogrande<br>5-shot (acc) | 85.16 | 84.37 |
25
- | gsm8k<br>5-shot (strict-match) | 82.03 | 83.40 |
26
- | **Average<br>Accuracy** | **79.15** | **78.47** |
27
- | **Recovery** | **100%** | **99.14%** |
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  # Mixtral-8x22B-Instruct-v0.1-FP8
8
 
9
  ## Model Overview
10
+ - **Model Architecture:** Mixtral-8x22B-Instruct-v0.1
11
+ - **Input:** Text
12
+ - **Output:** Text
13
+ - **Model Optimizations:**
14
+ - **Weight quantization:** FP8
15
+ - **Activation quantization:** FP8
16
+ - **Intended Use Cases:** Intended for commercial and research use in English. Similarly to [Meta-Llama-3-7B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3-7B-Instruct), this models is intended for assistant-like chat.
17
+ - **Out-of-scope:** Use in any manner that violates applicable laws or regulations (including trade compliance laws). Use in languages other than English.
18
+ - **Release Date:** 6/8/2024
19
+ - **Version:** 1.0
20
+ - **Model Developers:** Neural Magic
21
 
22
+ Quantized version of [Mixtral-8x22B-Instruct-v0.1](mistralai/Mixtral-8x22B-Instruct-v0.1).
23
+ It achieves an average score of 78.47 on the [OpenLLM](https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard) benchmark (version 1), whereas the unquantized model achieves 79.15.
24
+
25
+ ### Model Optimizations
26
+
27
+ This model was obtained by quantizing the weights and activations of [Mixtral-8x22B-Instruct-v0.1](mistralai/Mixtral-8x22B-Instruct-v0.1) to FP8 data type, ready for inference with vLLM >= 0.5.0.
28
+ This optimization reduces the number of bits per parameter from 16 to 8, reducing the disk size and GPU memory requirements by approximately 50%.
29
+
30
+ Only the weights and activations of the linear operators within transformers blocks are quantized. Symmetric per-channel quantization is applied, in which a linear scaling per output dimension maps the FP8 representations of the quantized weights and activations.
31
+ [AutoFP8](https://github.com/neuralmagic/AutoFP8) is used for quantization with 512 sequences of UltraChat.
32
+
33
+ ## Deployment
34
+
35
+ ### Use with vLLM
36
+
37
+ This model can be deployed efficiently using the [vLLM](https://docs.vllm.ai/en/latest/) backend, as shown in the example below.
38
+
39
+ ```python
40
+ from vllm import LLM, SamplingParams
41
+ from transformers import AutoTokenizer
42
+
43
+ model_id = "neuralmagic/Mixtral-8x22B-Instruct-v0.1-FP8"
44
+
45
+ sampling_params = SamplingParams(temperature=0.6, top_p=0.9, max_tokens=256)
46
+
47
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
48
+
49
+ messages = [
50
+ {"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
51
+ {"role": "user", "content": "Who are you?"},
52
+ ]
53
+
54
+ prompts = tokenizer.apply_chat_template(messages, tokenize=False)
55
+
56
+ llm = LLM(model=model_id)
57
+
58
+ outputs = llm.generate(prompts, sampling_params)
59
+
60
+ generated_text = outputs[0].outputs[0].text
61
+ print(generated_text)
62
+ ```
63
+
64
+ vLLM aslo supports OpenAI-compatible serving. See the [documentation](https://docs.vllm.ai/en/latest/) for more details.
65
+
66
+ ## Creation
67
+
68
+ This model was created by applying [AutoFP8 with calibration samples from ultrachat](https://github.com/neuralmagic/AutoFP8/blob/147fa4d9e1a90ef8a93f96fc7d9c33056ddc017a/example_dataset.py) with block_sparse_moe.gate layers kept at original precision, as presented in the code snipet below.
69
+ Although AutoFP8 was used for this particular model, Neural Magic is transitioning to using [llm-compressor](https://github.com/vllm-project/llm-compressor) which supports several quantization schemes and models not supported by AutoFP8.
70
+
71
+ ```python
72
+ from datasets import load_dataset
73
+ from transformers import AutoTokenizer
74
+
75
+ from auto_fp8 import AutoFP8ForCausalLM, BaseQuantizeConfig
76
+
77
+ pretrained_model_dir = "mistralai/Mixtral-8x22B-Instruct-v0.1"
78
+ quantized_model_dir = "Mixtral-8x22B-Instruct-v0.1-FP8"
79
+
80
+ tokenizer = AutoTokenizer.from_pretrained(pretrained_model_dir, use_fast=True, model_max_length=4096)
81
+ tokenizer.pad_token = tokenizer.eos_token
82
+
83
+ ds = load_dataset("mgoin/ultrachat_2k", split="train_sft").select(range(512))
84
+ examples = [tokenizer.apply_chat_template(batch["messages"], tokenize=False) for batch in ds]
85
+ examples = tokenizer(examples, padding=True, truncation=True, return_tensors="pt").to("cuda")
86
+
87
+ quantize_config = BaseQuantizeConfig(
88
+ quant_method="fp8",
89
+ activation_scheme="static"
90
+ ignore_patterns=["re:.*lm_head", "re:.*block_sparse_moe.gate"],
91
+ )
92
+
93
+ model = AutoFP8ForCausalLM.from_pretrained(
94
+ pretrained_model_dir, quantize_config=quantize_config
95
+ )
96
+ model.quantize(examples)
97
+ model.save_quantized(quantized_model_dir)
98
+ ```
99
 
100
  ## Evaluation
101
 
102
+ The model was evaluated on the [OpenLLM](https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard) leaderboard tasks (version 1) with the [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness/tree/383bbd54bc621086e05aa1b030d8d4d5635b25e6) (commit 383bbd54bc621086e05aa1b030d8d4d5635b25e6) and the [vLLM](https://docs.vllm.ai/en/stable/) engine, using the following command:
103
+ ```
104
+ lm_eval \
105
+ --model vllm \
106
+ --model_args pretrained="neuralmagic/Mixtral-8x22B-Instruct-v0.1-FP8",dtype=auto,gpu_memory_utilization=0.4,add_bos_token=True,max_model_len=4096 \
107
+ --tasks openllm \
108
+ --batch_size auto
109
+ ```
110
+
111
+ ### Accuracy
 
112
 
113
+ #### Open LLM Leaderboard evaluation scores
114
+ <table>
115
+ <tr>
116
+ <td><strong>Benchmark</strong>
117
+ </td>
118
+ <td><strong>Mixtral-8x22B-Instruct-v0.1</strong>
119
+ </td>
120
+ <td><strong>Mixtral-8x22B-Instruct-v0.1-FP8(this model)</strong>
121
+ </td>
122
+ <td><strong>Recovery</strong>
123
+ </td>
124
+ </tr>
125
+ <tr>
126
+ <td>MMLU (5-shot)
127
+ </td>
128
+ <td>77.77
129
+ </td>
130
+ <td>76.08
131
+ </td>
132
+ <td>97.82%
133
+ </td>
134
+ </tr>
135
+ <tr>
136
+ <td>ARC Challenge (25-shot)
137
+ </td>
138
+ <td>72.70
139
+ </td>
140
+ <td>72.53
141
+ </td>
142
+ <td>99.76%
143
+ </td>
144
+ </tr>
145
+ <tr>
146
+ <td>GSM-8K (5-shot, strict-match)
147
+ </td>
148
+ <td>82.03
149
+ </td>
150
+ <td>83.40
151
+ </td>
152
+ <td>101.6%
153
+ </td>
154
+ </tr>
155
+ <tr>
156
+ <td>Hellaswag (10-shot)
157
+ </td>
158
+ <td>89.08
159
+ </td>
160
+ <td>88.10
161
+ </td>
162
+ <td>98.89%
163
+ </td>
164
+ </tr>
165
+ <tr>
166
+ <td>Winogrande (5-shot)
167
+ </td>
168
+ <td>85.16
169
+ </td>
170
+ <td>84.37
171
+ </td>
172
+ <td>99.07%
173
+ </td>
174
+ </tr>
175
+ <tr>
176
+ <td>TruthfulQA (0-shot)
177
+ </td>
178
+ <td>68.14
179
+ </td>
180
+ <td>66.32
181
+ </td>
182
+ <td>97.32%
183
+ </td>
184
+ </tr>
185
+ <tr>
186
+ <td><strong>Average</strong>
187
+ </td>
188
+ <td><strong>79.15</strong>
189
+ </td>
190
+ <td><strong>78.47</strong>
191
+ </td>
192
+ <td><strong>99.14%</strong>
193
+ </td>
194
+ </tr>
195
+ </table>