alexmarques commited on
Commit
3d4d6c9
·
verified ·
1 Parent(s): ad4a83e

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +226 -0
README.md ADDED
@@ -0,0 +1,226 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ license: apache-2.0
4
+ pipeline_tag: text-generation
5
+ base_model:
6
+ - Qwen/Qwen3-1.7B
7
+ tags:
8
+ - neuralmagic
9
+ - redhat
10
+ - llmcompressor
11
+ - quantized
12
+ - FP8
13
+ ---
14
+
15
+ # Qwen3-1.7B-FP8-dynamic
16
+
17
+ ## Model Overview
18
+ - **Model Architecture:** Qwen3ForCausalLM
19
+ - **Input:** Text
20
+ - **Output:** Text
21
+ - **Model Optimizations:**
22
+ - **Activation quantization:** FP8
23
+ - **Weight quantization:** FP8
24
+ - **Intended Use Cases:**
25
+ - Reasoning.
26
+ - Function calling.
27
+ - Subject matter experts via fine-tuning.
28
+ - Multilingual instruction following.
29
+ - Translation.
30
+ - **Out-of-scope:** Use in any manner that violates applicable laws or regulations (including trade compliance laws).
31
+ - **Release Date:** 05/02/2025
32
+ - **Version:** 1.0
33
+ - **Model Developers:** RedHat (Neural Magic)
34
+
35
+ ### Model Optimizations
36
+
37
+ This model was obtained by quantizing activations and weights of [Qwen3-1.7B](https://huggingface.co/Qwen/Qwen3-1.7B) to FP8 data type.
38
+ This optimization reduces the number of bits used to represent weights and activations from 16 to 8, reducing GPU memory requirements (by approximately 50%) and increasing matrix-multiply compute throughput (by approximately 2x).
39
+ Weight quantization also reduces disk size requirements by approximately 50%.
40
+
41
+ Only weights and activations of the linear operators within transformers blocks are quantized.
42
+ Weights are quantized with a symmetric static per-channel scheme, whereas activations are quantized with a symmetric dynamic per-token scheme.
43
+ The [llm-compressor](https://github.com/vllm-project/llm-compressor) library is used for quantization.
44
+
45
+
46
+ ## Deployment
47
+
48
+ This model can be deployed efficiently using the [vLLM](https://docs.vllm.ai/en/latest/) backend, as shown in the example below.
49
+
50
+ ```python
51
+ from vllm import LLM, SamplingParams
52
+ from transformers import AutoTokenizer
53
+
54
+ model_id = "RedHatAI/Qwen3-1.7B-FP8-dynamic"
55
+ number_gpus = 1
56
+ sampling_params = SamplingParams(temperature=0.6, top_p=0.95, top_k=20, min_p=0, max_tokens=256)
57
+
58
+ messages = [
59
+ {"role": "user", "content": prompt}
60
+ ]
61
+
62
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
63
+
64
+ messages = [{"role": "user", "content": "Give me a short introduction to large language model."}]
65
+
66
+ prompts = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
67
+
68
+ llm = LLM(model=model_id, tensor_parallel_size=number_gpus)
69
+
70
+ outputs = llm.generate(prompts, sampling_params)
71
+
72
+ generated_text = outputs[0].outputs[0].text
73
+ print(generated_text)
74
+ ```
75
+
76
+ vLLM aslo supports OpenAI-compatible serving. See the [documentation](https://docs.vllm.ai/en/latest/) for more details.
77
+
78
+ ## Creation
79
+
80
+ <details>
81
+ <summary>Creation details</summary>
82
+ This model was created with [llm-compressor](https://github.com/vllm-project/llm-compressor) by running the code snippet below.
83
+
84
+
85
+ ```python
86
+ from llmcompressor.modifiers.quantization import QuantizationModifier
87
+ from llmcompressor.transformers import oneshot
88
+ from transformers import AutoModelForCausalLM, AutoTokenizer
89
+
90
+ # Load model
91
+ model_stub = "Qwen/Qwen3-1.7B"
92
+ model_name = model_stub.split("/")[-1]
93
+
94
+ model = AutoModelForCausalLM.from_pretrained(model_stub)
95
+
96
+ tokenizer = AutoTokenizer.from_pretrained(model_stub)
97
+
98
+ # Configure the quantization algorithm and scheme
99
+ recipe = QuantizationModifier(
100
+ ignore=["lm_head"],
101
+ targets="Linear",
102
+ scheme="FP8_dynamic",
103
+ )
104
+
105
+ # Apply quantization
106
+ oneshot(
107
+ model=model,
108
+ recipe=recipe,
109
+ )
110
+
111
+ # Save to disk in compressed-tensors format
112
+ save_path = model_name + "-FP8-dynamic"
113
+ model.save_pretrained(save_path)
114
+ tokenizer.save_pretrained(save_path)
115
+ print(f"Model and tokenizer saved to: {save_path}")
116
+ ```
117
+ </details>
118
+
119
+
120
+
121
+ ## Evaluation
122
+
123
+ The model was evaluated on the OpenLLM leaderboard tasks (version 1), using [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness) and [vLLM](https://docs.vllm.ai/en/stable/).
124
+
125
+ <details>
126
+ <summary>Evaluation details</summary>
127
+
128
+ ```
129
+ lm_eval \
130
+ --model vllm \
131
+ --model_args pretrained="RedHatAI/Qwen3-1.7B-FP8-dynamic",dtype=auto,gpu_memory_utilization=0.5,max_model_len=8192,enable_chunk_prefill=True,tensor_parallel_size=2 \
132
+ --tasks openllm \
133
+ --apply_chat_template\
134
+ --fewshot_as_multiturn \
135
+ --batch_size auto
136
+ ```
137
+ </details>
138
+
139
+ ### Accuracy
140
+
141
+ <table>
142
+ <tr>
143
+ <th>Category
144
+ </th>
145
+ <th>Benchmark
146
+ </th>
147
+ <th>Qwen3-1.7B
148
+ </th>
149
+ <th>Qwen3-1.7B-FP8-dynamic<br>(this model)
150
+ </th>
151
+ <th>Recovery
152
+ </th>
153
+ </tr>
154
+ <tr>
155
+ <td rowspan="7" ><strong>OpenLLM v1</strong>
156
+ </td>
157
+ <td>MMLU (5-shot)
158
+ </td>
159
+ <td>56.82
160
+ </td>
161
+ <td>56.02
162
+ </td>
163
+ <td>98.6%
164
+ </td>
165
+ </tr>
166
+ <tr>
167
+ <td>ARC Challenge (25-shot)
168
+ </td>
169
+ <td>43.00
170
+ </td>
171
+ <td>42.83
172
+ </td>
173
+ <td>99.6%
174
+ </td>
175
+ </tr>
176
+ <tr>
177
+ <td>GSM-8K (5-shot, strict-match)
178
+ </td>
179
+ <td>43.67
180
+ </td>
181
+ <td>41.47
182
+ </td>
183
+ <td>95.0%
184
+ </td>
185
+ </tr>
186
+ <tr>
187
+ <td>Hellaswag (10-shot)
188
+ </td>
189
+ <td>48.08
190
+ </td>
191
+ <td>48.11
192
+ </td>
193
+ <td>100.1%
194
+ </td>
195
+ </tr>
196
+ <tr>
197
+ <td>Winogrande (5-shot)
198
+ </td>
199
+ <td>58.01
200
+ </td>
201
+ <td>57.70
202
+ </td>
203
+ <td>99.5%
204
+ </td>
205
+ </tr>
206
+ <tr>
207
+ <td>TruthfulQA (0-shot, mc2)
208
+ </td>
209
+ <td>49.35
210
+ </td>
211
+ <td>48.60
212
+ </td>
213
+ <td>98.5%
214
+ </td>
215
+ </tr>
216
+ <tr>
217
+ <td><strong>Average</strong>
218
+ </td>
219
+ <td><strong>49.82</strong>
220
+ </td>
221
+ <td><strong>49.12</strong>
222
+ </td>
223
+ <td><strong>98.6%</strong>
224
+ </td>
225
+ </tr>
226
+ </table>