reed-meyerson commited on
Commit
73fa5a3
·
verified ·
1 Parent(s): 0a7560d

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +310 -0
README.md ADDED
@@ -0,0 +1,310 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ license: apache-2.0
4
+ license_link: https://huggingface.co/Qwen/Qwen3.5-9B/blob/main/LICENSE
5
+ pipeline_tag: image-text-to-text
6
+ tags:
7
+ - int8
8
+ - vllm
9
+ - llm-compressor
10
+ - compressed-tensors
11
+ base_model: Qwen/Qwen3.5-9B
12
+ ---
13
+
14
+ # Qwen3.5-9B-quantized.w8a8
15
+
16
+ ## Model Overview
17
+ - **Model Architecture:** Qwen/Qwen3.5-9B
18
+ - **Input:** Text / Image
19
+ - **Output:** Text
20
+ - **Model Optimizations:**
21
+ - **Weight quantization:** INT8
22
+ - **Activation quantization:** INT8
23
+ - **Model size:** 14 GB (reduced from 18 GB in BF16)
24
+ - **Release Date:** 2026-04-16
25
+ - **Version:** 1.0
26
+ - **Model Developers:** RedHatAI
27
+
28
+ This model is a quantized version of [Qwen/Qwen3.5-9B](https://huggingface.co/Qwen/Qwen3.5-9B). Evaluation results and reproduction steps are provided below.
29
+
30
+ ### Model Optimizations
31
+
32
+ This model was obtained by quantizing the weights and activations of [Qwen/Qwen3.5-9B](https://huggingface.co/Qwen/Qwen3.5-9B) to INT8 data type, ready for inference with vLLM.
33
+
34
+ This optimization reduces the model weights from 18 GB to 14 GB on disk (~22% reduction). The reduction is less than the theoretical 50% because the vision encoder remains in BF16.
35
+
36
+ Only the weights and activations of the linear operators within transformer blocks are quantized using [LLM Compressor](https://github.com/vllm-project/llm-compressor). The vision encoder is not quantized.
37
+
38
+ ## Deployment
39
+
40
+ ### Use with vLLM
41
+
42
+ 1. Initialize vLLM server:
43
+
44
+ **Multimodal (vision + text):**
45
+ ```bash
46
+ vllm serve RedHatAI/Qwen3.5-9B-quantized.w8a8 \
47
+ --reasoning-parser qwen3 \
48
+ --max-model-len 262144
49
+ ```
50
+
51
+ **Text-only (lower memory):**
52
+ ```bash
53
+ vllm serve RedHatAI/Qwen3.5-9B-quantized.w8a8 \
54
+ --reasoning-parser qwen3 \
55
+ --max-model-len 262144 \
56
+ --language-model-only
57
+ ```
58
+
59
+ 2. Send requests to the server:
60
+
61
+ ```python
62
+ from openai import OpenAI
63
+
64
+ openai_api_key = "EMPTY"
65
+ openai_api_base = "http://localhost:8000/v1"
66
+
67
+ client = OpenAI(
68
+ api_key=openai_api_key,
69
+ base_url=openai_api_base,
70
+ )
71
+
72
+ model = "RedHatAI/Qwen3.5-9B-quantized.w8a8"
73
+
74
+ messages = [
75
+ {"role": "user", "content": "Explain quantum mechanics clearly and concisely."},
76
+ ]
77
+
78
+ outputs = client.chat.completions.create(
79
+ model=model,
80
+ messages=messages,
81
+ )
82
+
83
+ generated_text = outputs.choices[0].message.content
84
+ print(generated_text)
85
+ ```
86
+
87
+ ## Creation
88
+
89
+ This model was created by applying [LLM Compressor](https://github.com/vllm-project/llm-compressor) with calibration samples from [Open-Platypus](https://huggingface.co/datasets/garage-bAInd/Open-Platypus), as presented in the code snippet below.
90
+
91
+ <details>
92
+
93
+ ```python
94
+ from compressed_tensors.utils import save_mtp_tensors_to_checkpoint
95
+ from datasets import load_dataset
96
+ from llmcompressor import oneshot
97
+ from llmcompressor.modifiers.quantization import GPTQModifier
98
+ from transformers import AutoProcessor, AutoTokenizer, Qwen3_5ForConditionalGeneration
99
+
100
+ MODEL_ID = "Qwen/Qwen3.5-9B"
101
+ NUM_CALIBRATION_SAMPLES = 512
102
+ MAX_SEQUENCE_LENGTH = 2048
103
+
104
+ IGNORE_LAYERS = [
105
+ "re:.*lm_head",
106
+ "re:.*embed_tokens$",
107
+ "re:.*visual.*",
108
+ "re:.*model.visual.*",
109
+ "re:.*linear_attn.*",
110
+ ]
111
+
112
+ model = Qwen3_5ForConditionalGeneration.from_pretrained(MODEL_ID, dtype="auto")
113
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
114
+ processor = AutoProcessor.from_pretrained(MODEL_ID)
115
+
116
+ ds = load_dataset("garage-bAInd/Open-Platypus", split=f"train[:{NUM_CALIBRATION_SAMPLES}]")
117
+ ds = ds.shuffle(seed=42)
118
+
119
+ def preprocess(ex):
120
+ text = ex["instruction"]
121
+ if ex.get("input"):
122
+ text += "\n" + ex["input"]
123
+ return {"text": text}
124
+
125
+ def tokenize(sample):
126
+ return tokenizer(
127
+ sample["text"],
128
+ padding=False,
129
+ max_length=MAX_SEQUENCE_LENGTH,
130
+ truncation=True,
131
+ add_special_tokens=False,
132
+ )
133
+
134
+ ds = ds.map(preprocess).map(tokenize, remove_columns=ds.column_names)
135
+
136
+ recipe = GPTQModifier(
137
+ targets="Linear",
138
+ scheme="W8A8",
139
+ sequential_targets=["Qwen3_5DecoderLayer"],
140
+ ignore=IGNORE_LAYERS,
141
+ dampening_frac=0.01,
142
+ )
143
+
144
+ oneshot(
145
+ model=model,
146
+ dataset=ds,
147
+ recipe=recipe,
148
+ max_seq_length=MAX_SEQUENCE_LENGTH,
149
+ num_calibration_samples=NUM_CALIBRATION_SAMPLES,
150
+ )
151
+
152
+ model.save_pretrained("Qwen3.5-9B-quantized.w8a8", save_compressed=True)
153
+ processor.save_pretrained("Qwen3.5-9B-quantized.w8a8")
154
+ save_mtp_tensors_to_checkpoint(source_model=MODEL_ID, dest_dir="Qwen3.5-9B-quantized.w8a8")
155
+ ```
156
+
157
+ <details>
158
+ <summary>Package versions</summary>
159
+
160
+ - `llm-compressor==0.10.1.dev44+g437f8afe`
161
+ - `compressed-tensors==0.14.1a20260325`
162
+ - `transformers==5.3.0`
163
+ - `vllm==0.18.1`
164
+ - `lm-eval` — `neuralmagic/lm-evaluation-harness@741f1d8` (branch: `mmlu-pro-chat-variant`)
165
+ - `lighteval` — `neuralmagic/lighteval@6f0f351` (branch: `eldar-fix-litellm`)
166
+
167
+ </details>
168
+
169
+ </details>
170
+
171
+ ## Evaluation
172
+
173
+ This model was evaluated on GSM8k-Platinum, MMLU-Pro, IFEval, Math 500, AIME 2025, and GPQA Diamond using [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness) and [lighteval](https://github.com/huggingface/lighteval), with inference served via vLLM.
174
+
175
+ ### Accuracy
176
+
177
+ <table>
178
+ <thead>
179
+ <tr>
180
+ <th>Category</th>
181
+ <th>Benchmark</th>
182
+ <th>Qwen/Qwen3.5-9B</th>
183
+ <th>RedHatAI/Qwen3.5-9B-quantized.w8a8</th>
184
+ <th>Recovery</th>
185
+ </tr>
186
+ </thead>
187
+ <tbody>
188
+ <tr>
189
+ <td rowspan="4"><b>Instruction Following</b></td>
190
+ <td>GSM8k-Platinum (0-shot)</td>
191
+ <td>94.4%</td>
192
+ <td>94.3%</td>
193
+ <td>99.9%</td>
194
+ </tr>
195
+ <tr>
196
+ <td>MMLU-Pro (0-shot)</td>
197
+ <td>82.4%</td>
198
+ <td>82.0%</td>
199
+ <td>99.4%</td>
200
+ </tr>
201
+ <tr>
202
+ <td>IFEval — prompt strict (0-shot)</td>
203
+ <td>89.5%</td>
204
+ <td>89.6%</td>
205
+ <td>100.1%</td>
206
+ </tr>
207
+ <tr>
208
+ <td>IFEval — instruction strict (0-shot)</td>
209
+ <td>92.5%</td>
210
+ <td>92.4%</td>
211
+ <td>100.0%</td>
212
+ </tr>
213
+ <tr>
214
+ <td rowspan="3"><b>Reasoning</b></td>
215
+ <td>Math 500 (0-shot)</td>
216
+ <td>85.2%</td>
217
+ <td>85.3%</td>
218
+ <td>100.2%</td>
219
+ </tr>
220
+ <tr>
221
+ <td>AIME 2025 (0-shot)</td>
222
+ <td>85.4%</td>
223
+ <td>85.4%</td>
224
+ <td>100.0%</td>
225
+ </tr>
226
+ <tr>
227
+ <td>GPQA Diamond (0-shot)</td>
228
+ <td>82.2%</td>
229
+ <td>82.3%</td>
230
+ <td>100.2%</td>
231
+ </tr>
232
+ </tbody>
233
+ </table>
234
+
235
+ ### Reproduction
236
+
237
+ The results were obtained using the following commands. GSM8k-Platinum, MMLU-Pro, IFEval, Math 500, and GPQA Diamond were each run 3 times with different seeds and results averaged. AIME 2025 was run 8 times. The vLLM server was started with `--language-model-only` for all evaluations.
238
+
239
+ <details>
240
+
241
+ #### GSM8k-Platinum (lm-eval, 0-shot, 3 repetitions)
242
+ ```bash
243
+ lm_eval --model local-chat-completions \
244
+ --tasks gsm8k_platinum_cot_llama \
245
+ --model_args "model=RedHatAI/Qwen3.5-9B-quantized.w8a8,max_length=96000,base_url=http://0.0.0.0:8000/v1/chat/completions,num_concurrent=100,max_retries=3,tokenized_requests=False,tokenizer_backend=None,timeout=3600" \
246
+ --num_fewshot 0 \
247
+ --apply_chat_template \
248
+ --output_path results_gsm8k_platinum.json \
249
+ --seed <SEED> \
250
+ --gen_kwargs "do_sample=True,temperature=1.0,top_p=0.95,top_k=20,min_p=0.0,presence_penalty=1.5,repetition_penalty=1.0,max_gen_toks=65536,seed=<SEED>"
251
+ ```
252
+ Seeds used: 42, 1234, 4158
253
+
254
+ #### MMLU-Pro (lm-eval, 0-shot, 3 repetitions)
255
+ ```bash
256
+ lm_eval --model local-chat-completions \
257
+ --tasks mmlu_pro_chat \
258
+ --model_args "model=RedHatAI/Qwen3.5-9B-quantized.w8a8,max_length=96000,base_url=http://0.0.0.0:8000/v1/chat/completions,num_concurrent=100,max_retries=3,tokenized_requests=False,tokenizer_backend=None,timeout=3600" \
259
+ --num_fewshot 0 \
260
+ --apply_chat_template \
261
+ --output_path results_mmlu_pro.json \
262
+ --seed <SEED> \
263
+ --gen_kwargs "do_sample=True,temperature=1.0,top_p=0.95,top_k=20,min_p=0.0,presence_penalty=1.5,repetition_penalty=1.0,max_gen_toks=65536,seed=<SEED>"
264
+ ```
265
+ Seeds used: 42, 1234, 4158
266
+
267
+ #### IFEval (lm-eval, 0-shot, 3 repetitions)
268
+ ```bash
269
+ lm_eval --model local-chat-completions \
270
+ --tasks ifeval \
271
+ --model_args "model=RedHatAI/Qwen3.5-9B-quantized.w8a8,max_length=96000,base_url=http://0.0.0.0:8000/v1/chat/completions,num_concurrent=100,max_retries=3,tokenized_requests=False,tokenizer_backend=None,timeout=3600" \
272
+ --num_fewshot 0 \
273
+ --apply_chat_template \
274
+ --output_path results_ifeval.json \
275
+ --seed <SEED> \
276
+ --gen_kwargs "do_sample=True,temperature=1.0,top_p=0.95,top_k=20,min_p=0.0,presence_penalty=1.5,repetition_penalty=1.0,max_gen_toks=65536,seed=<SEED>"
277
+ ```
278
+ Seeds used: 42, 1234, 4158
279
+
280
+ #### Math 500 (lighteval, 0-shot, 3 repetitions)
281
+ ```bash
282
+ lighteval endpoint litellm \
283
+ "model_name=hosted_vllm/RedHatAI/Qwen3.5-9B-quantized.w8a8,provider=hosted_vllm,base_url=http://0.0.0.0:8000/v1,timeout=3600,concurrent_requests=100,generation_parameters={temperature:1.0,max_new_tokens:65536,top_p:0.95,top_k:20,min_p:0.0,presence_penalty:1.5,repetition_penalty:1.0,seed:<SEED>}" \
284
+ "math_500@k=1@n=1|0" \
285
+ --output-dir results_math500 \
286
+ --save-details
287
+ ```
288
+ Seeds used: 42, 1234, 4158
289
+
290
+ #### AIME 2025 (lighteval, 0-shot, 8 repetitions)
291
+ ```bash
292
+ lighteval endpoint litellm \
293
+ "model_name=hosted_vllm/RedHatAI/Qwen3.5-9B-quantized.w8a8,provider=hosted_vllm,base_url=http://0.0.0.0:8000/v1,timeout=3600,concurrent_requests=100,generation_parameters={temperature:1.0,max_new_tokens:65536,top_p:0.95,top_k:20,min_p:0.0,presence_penalty:1.5,repetition_penalty:1.0,seed:<SEED>}" \
294
+ "aime25@k=1@n=1|0" \
295
+ --output-dir results_aime25 \
296
+ --save-details
297
+ ```
298
+ Seeds used: 42, 1234, 1356, 3344, 4158, 5322, 5678, 9843
299
+
300
+ #### GPQA Diamond (lighteval, 0-shot, 3 repetitions)
301
+ ```bash
302
+ lighteval endpoint litellm \
303
+ "model_name=hosted_vllm/RedHatAI/Qwen3.5-9B-quantized.w8a8,provider=hosted_vllm,base_url=http://0.0.0.0:8000/v1,timeout=3600,concurrent_requests=100,generation_parameters={temperature:1.0,max_new_tokens:65536,top_p:0.95,top_k:20,min_p:0.0,presence_penalty:1.5,repetition_penalty:1.0,seed:<SEED>}" \
304
+ "gpqa:diamond@k=1@n=1|0" \
305
+ --output-dir results_gpqa_diamond \
306
+ --save-details
307
+ ```
308
+ Seeds used: 42, 1234, 4158
309
+
310
+ </details>