krishnateja95 commited on
Commit
6a2ea1f
·
verified ·
1 Parent(s): c0b8869

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +274 -0
README.md ADDED
@@ -0,0 +1,274 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ pipeline_tag: text-generation
4
+ tags:
5
+ - fp8
6
+ - quantized
7
+ - llm-compressor
8
+ - compressed-tensors
9
+ - red hat
10
+ base_model:
11
+ - Qwen/Qwen3-30B-A3B
12
+ ---
13
+
14
+
15
+ # Qwen3-30B-A3B-FP8-block
16
+
17
+ ## Model Overview
18
+ - **Model Architecture:** Qwen3MoeForCausalLM
19
+ - **Input:** Text
20
+ - **Output:** Text
21
+ - **Model Optimizations:**
22
+ - **Weight quantization:** FP8
23
+ - **Activation quantization:** FP8
24
+ - **Release Date:**
25
+ - **Version:** 1.0
26
+ - **Model Developers:**: Red Hat
27
+
28
+ Quantized version of [Qwen/Qwen3-30B-A3B](https://huggingface.co/Qwen/Qwen3-30B-A3B).
29
+
30
+ ### Model Optimizations
31
+
32
+ This model was obtained by quantizing the weights and activations of [Qwen/Qwen3-30B-A3B](https://huggingface.co/Qwen/Qwen3-30B-A3B) to FP8 data type.
33
+ This optimization reduces the number of bits per parameter from 16 to 8, reducing the disk size and GPU memory requirements by approximately 50%.
34
+ Only the weights and activations of the linear operators within transformers blocks of the language model are quantized.
35
+
36
+ ## Deployment
37
+
38
+ ### Use with vLLM
39
+
40
+ 1. Initialize vLLM server:
41
+ ```
42
+ vllm serve RedHatAI/Qwen3-30B-A3B-FP8-BLOCK --tensor_parallel_size 4
43
+ ```
44
+
45
+ 2. Send requests to the server:
46
+
47
+ ```python
48
+ from openai import OpenAI
49
+
50
+ # Modify OpenAI's API key and API base to use vLLM's API server.
51
+ openai_api_key = "EMPTY"
52
+ openai_api_base = "http://<your-server-host>:8000/v1"
53
+
54
+ client = OpenAI(
55
+ api_key=openai_api_key,
56
+ base_url=openai_api_base,
57
+ )
58
+
59
+ model = "RedHatAI/Qwen3-30B-A3B-FP8-BLOCK"
60
+
61
+ messages = [
62
+ {"role": "user", "content": "Explain quantum mechanics clearly and concisely."},
63
+ ]
64
+
65
+ outputs = client.chat.completions.create(
66
+ model=model,
67
+ messages=messages,
68
+ )
69
+
70
+ generated_text = outputs.choices[0].message.content
71
+ print(generated_text)
72
+ ```
73
+
74
+ ## Creation
75
+
76
+ This model was quantized using the [llm-compressor](https://github.com/vllm-project/llm-compressor) library as shown below.
77
+
78
+ <details>
79
+ <summary>Creation details</summary>
80
+
81
+ ```python
82
+ from transformers import AutoProcessor, Qwen3MoeForCausalLM
83
+
84
+ from llmcompressor import oneshot
85
+ from llmcompressor.modeling import replace_modules_for_calibration
86
+ from llmcompressor.modifiers.quantization import QuantizationModifier
87
+
88
+ MODEL_ID = "Qwen/Qwen3-30B-A3B"
89
+
90
+ # Load model.
91
+ model = Qwen3ForCausalLM.from_pretrained(MODEL_ID, dtype="auto")
92
+ processor = AutoProcessor.from_pretrained(MODEL_ID)
93
+ model = replace_modules_for_calibration(model)
94
+
95
+ # Configure the quantization algorithm and scheme.
96
+ # In this case, we:
97
+ # * quantize the weights to fp8 with per-block quantization
98
+ # * quantize the activations to fp8 with dynamic token activations
99
+ recipe = QuantizationModifier(
100
+ targets="Linear",
101
+ scheme="FP8_BLOCK",
102
+ ignore=["lm_head"],
103
+ )
104
+
105
+ # Apply quantization.
106
+ oneshot(model=model, recipe=recipe)
107
+
108
+ # Save to disk in compressed-tensors format.
109
+ SAVE_DIR = MODEL_ID.rstrip("/").split("/")[-1] + "-FP8-block"
110
+ model.save_pretrained(SAVE_DIR)
111
+ processor.save_pretrained(SAVE_DIR)
112
+ ```
113
+ </details>
114
+
115
+ ## Evaluation
116
+
117
+
118
+ The model was evaluated on the OpenLLM leaderboard task, using [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness).
119
+ [vLLM](https://docs.vllm.ai/en/stable/) was used for all evaluations.
120
+
121
+ <details>
122
+ <summary>Evaluation details</summary>
123
+
124
+ **Openllm V1**
125
+ ```
126
+ lm_eval \
127
+ --model vllm \
128
+ --model_args pretrained="RedHatAI/Qwen3-30B-A3B-FP8-BLOCK",dtype=auto,add_bos_token=True,max_model_len=16384,tensor_parallel_size=2,gpu_memory_utilization=0.9,enable_chunked_prefill=True,trust_remote_code=True \
129
+ --tasks openllm \
130
+ --write_out \
131
+ --batch_size auto \
132
+ --show_config
133
+ ```
134
+
135
+
136
+ **Openllm V2**
137
+ ```
138
+ lm_eval \
139
+ --model vllm \
140
+ --model_args pretrained="RedHatAI/Qwen3-30B-A3B-FP8-BLOCK",dtype=auto,add_bos_token=False,max_model_len=16384,tensor_parallel_size=2,gpu_memory_utilization=0.7,disable_log_stats=True,enable_chunked_prefill=True,trust_remote_code=True \
141
+ --tasks leaderboard \
142
+ --apply_chat_template \
143
+ --fewshot_as_multiturn \
144
+ --write_out \
145
+ --batch_size auto \
146
+ --show_config
147
+ ```
148
+
149
+
150
+ **Coding Benchmarks**
151
+
152
+ ```
153
+ evalplus.evaluate --model "RedHatAI/Qwen3-30B-A3B-FP8-BLOCK" \
154
+ --dataset "humaneval" \
155
+ --backend vllm \
156
+ --tp 2 \
157
+ --greedy
158
+
159
+ evalplus.evaluate --model "RedHatAI/Qwen3-30B-A3B-FP8-BLOCK" \
160
+ --dataset "mbpp" \
161
+ --backend vllm \
162
+ --tp 2 \
163
+ --greedy
164
+
165
+ ```
166
+
167
+ </details>
168
+
169
+
170
+
171
+
172
+
173
+ ### Accuracy
174
+ <table>
175
+ <thead>
176
+ <tr>
177
+ <th>Category</th>
178
+ <th>Metric</th>
179
+ <th>Qwen/Qwen3-30B-A3B</th>
180
+ <th>RedHatAI/Qwen3-30B-A3B-FP8-BLOCK</th>
181
+ <th>Recovery (%)</th>
182
+ </tr>
183
+ </thead>
184
+ <tbody>
185
+ <!-- OpenLLM Leaderboard V1 -->
186
+ <tr>
187
+ <td rowspan="7"><b>OpenLLM V1</b></td>
188
+ <td>ARC-Challenge (Acc-Norm, 25-shot)</td>
189
+ <td>69.28</td>
190
+ <td>69.88</td>
191
+ <td>100.86</td>
192
+ </tr>
193
+ <tr>
194
+ <td>GSM8K (Strict-Match, 5-shot)</td>
195
+ <td>89.99</td>
196
+ <td>89.16</td>
197
+ <td>99.07</td>
198
+ </tr>
199
+ <tr>
200
+ <td>HellaSwag (Acc-Norm, 10-shot)</td>
201
+ <td>77.64</td>
202
+ <td>77.41</td>
203
+ <td>99.71</td>
204
+ </tr>
205
+ <tr>
206
+ <td>MMLU (Acc, 5-shot)</td>
207
+ <td>79.50</td>
208
+ <td>79.37</td>
209
+ <td>99.84</td>
210
+ </tr>
211
+ <tr>
212
+ <td>TruthfulQA (MC2, 0-shot)</td>
213
+ <td>53.20</td>
214
+ <td>53.93</td>
215
+ <td>101.38</td>
216
+ </tr>
217
+ <tr>
218
+ <td>Winogrande (Acc, 5-shot)</td>
219
+ <td>72.30</td>
220
+ <td>72.69</td>
221
+ <td>100.55</td>
222
+ </tr>
223
+ <tr>
224
+ <td><b>Average Score</b></td>
225
+ <td><b>73.65</b></td>
226
+ <td><b>73.74</b></td>
227
+ <td><b>100.12</b></td>
228
+ </tr>
229
+ <!-- OpenLLM Leaderboard V2 -->
230
+ <tr>
231
+ <td rowspan="7"><b>OpenLLM V2</b></td>
232
+ <td>IFEval (Inst Level Strict Acc, 0-shot)</td>
233
+ <td>48.68</td>
234
+ <td>47.84</td>
235
+ <td>98.28</td>
236
+ </tr>
237
+ <tr>
238
+ <td>BBH (Acc-Norm, 3-shot)</td>
239
+ <td>32.46</td>
240
+ <td>32.06</td>
241
+ <td>98.77</td>
242
+ </tr>
243
+ <tr>
244
+ <td>Math-Hard (Exact-Match, 4-shot)</td>
245
+ <td>18.81</td>
246
+ <td>18.96</td>
247
+ <td>100.80</td>
248
+ </tr>
249
+ <tr>
250
+ <td>GPQA (Acc-Norm, 0-shot)</td>
251
+ <td>24.16</td>
252
+ <td>24.75</td>
253
+ <td>102.43</td>
254
+ </tr>
255
+ <tr>
256
+ <td>MUSR (Acc-Norm, 0-shot)</td>
257
+ <td>38.62</td>
258
+ <td>40.48</td>
259
+ <td>104.79</td>
260
+ </tr>
261
+ <tr>
262
+ <td>MMLU-Pro (Acc, 5-shot)</td>
263
+ <td>23.15</td>
264
+ <td>25.66</td>
265
+ <td>110.80</td>
266
+ </tr>
267
+ <tr>
268
+ <td><b>Average Score</b></td>
269
+ <td><b>30.98</b></td>
270
+ <td><b>31.62</b></td>
271
+ <td><b>102.07</b></td>
272
+ </tr>
273
+ </tbody>
274
+ </table>