shubhrapandit commited on
Commit
9202975
·
verified ·
1 Parent(s): c94e540

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +355 -0
README.md ADDED
@@ -0,0 +1,355 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - w8a8
4
+ - int8
5
+ - vllm
6
+ - vision
7
+ license: apache-2.0
8
+ license_link: https://huggingface.co/datasets/choosealicense/licenses/blob/main/markdown/apache-2.0.md
9
+ language:
10
+ - en
11
+ base_model: nm-testing/Pixtral-Large-Instruct-2411-hf
12
+ library_name: transformers
13
+ ---
14
+
15
+ # Pixtral-Large-Instruct-2411-hf-quantized.w8a8
16
+
17
+ ## Model Overview
18
+ - **Model Architecture:** nm-testing/Pixtral-Large-Instruct-2411-hf
19
+ - **Input:** Vision-Text
20
+ - **Output:** Text
21
+ - **Model Optimizations:**
22
+ - **Weight quantization:** INT8
23
+ - **Activation quantization:** INT8
24
+ - **Release Date:** 2/24/2025
25
+ - **Version:** 1.0
26
+ - **Model Developers:** Neural Magic
27
+
28
+ Quantized version of [nm-testing/Pixtral-Large-Instruct-2411-hf](https://huggingface.co/nm-testing/Pixtral-Large-Instruct-2411-hf/tree/main).
29
+
30
+ ### Model Optimizations
31
+
32
+ This model was obtained by quantizing the weights of [nm-testing/Pixtral-Large-Instruct-2411-hf](https://huggingface.co/nm-testing/Pixtral-Large-Instruct-2411-hf/tree/main) to INT8 data type, ready for inference with vLLM >= 0.5.2.
33
+
34
+ ## Deployment
35
+
36
+ ### Use with vLLM
37
+
38
+ This model can be deployed efficiently using the [vLLM](https://docs.vllm.ai/en/latest/) backend, as shown in the example below.
39
+
40
+ ```python
41
+ from vllm.assets.image import ImageAsset
42
+ from vllm import LLM, SamplingParams
43
+
44
+ # prepare model
45
+ llm = LLM(
46
+ model="neuralmagic/Pixtral-Large-Instruct-2411-hf-quantized.w8a8",
47
+ trust_remote_code=True,
48
+ max_model_len=4096,
49
+ max_num_seqs=2,
50
+ )
51
+
52
+ # prepare inputs
53
+ question = "What is the content of this image?"
54
+ inputs = {
55
+ "prompt": f"<|user|>\n<|image_1|>\n{question}<|end|>\n<|assistant|>\n",
56
+ "multi_modal_data": {
57
+ "image": ImageAsset("cherry_blossom").pil_image.convert("RGB")
58
+ },
59
+ }
60
+
61
+ # generate response
62
+ print("========== SAMPLE GENERATION ==============")
63
+ outputs = llm.generate(inputs, SamplingParams(temperature=0.2, max_tokens=64))
64
+ print(f"PROMPT : {outputs[0].prompt}")
65
+ print(f"RESPONSE: {outputs[0].outputs[0].text}")
66
+ print("==========================================")
67
+ ```
68
+
69
+ vLLM also supports OpenAI-compatible serving. See the [documentation](https://docs.vllm.ai/en/latest/) for more details.
70
+
71
+ ## Creation
72
+
73
+ This model was created with [llm-compressor](https://github.com/vllm-project/llm-compressor) by running the code snippet below as part a multimodal announcement blog.
74
+
75
+ <details>
76
+ <summary>Model Creation Code</summary>
77
+
78
+ ```python
79
+ import requests
80
+ import torch
81
+ from PIL import Image
82
+ from transformers import AutoProcessor
83
+ from llmcompressor.modifiers.quantization import GPTQModifier
84
+ from llmcompressor.transformers import oneshot
85
+ from llmcompressor.transformers.tracing import TraceableLlavaForConditionalGeneration
86
+
87
+ # Load model.
88
+ model_id = "nm-testing/Pixtral-Large-Instruct-2411-hf"
89
+ model = TraceableLlavaForConditionalGeneration.from_pretrained(
90
+ model_id, device_map="auto", torch_dtype="auto"
91
+ )
92
+ processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
93
+
94
+ # Oneshot arguments
95
+ DATASET_ID = "flickr30k"
96
+ DATASET_SPLIT = {"calibration": "test[:512]"}
97
+ NUM_CALIBRATION_SAMPLES = 512
98
+ MAX_SEQUENCE_LENGTH = 2048
99
+
100
+
101
+ # Define a oneshot data collator for multimodal inputs.
102
+ def data_collator(batch):
103
+ assert len(batch) == 1
104
+ return {
105
+ "input_ids": torch.LongTensor(batch[0]["input_ids"]),
106
+ "attention_mask": torch.tensor(batch[0]["attention_mask"]),
107
+ "pixel_values": torch.tensor(batch[0]["pixel_values"]),
108
+ }
109
+
110
+
111
+ # Recipe
112
+ recipe = [
113
+ GPTQModifier(
114
+ targets="Linear",
115
+ scheme="W8A8",
116
+ sequential_targets=["MistralDecoderLayer"],
117
+ ignore=["re:.*lm_head", "re:vision_tower.*", "re:multi_modal_projector.*"],
118
+ ),
119
+ ]
120
+
121
+ SAVE_DIR==f"{model_id.split('/')[1]}-quantized.w8a8"
122
+
123
+ # Perform oneshot
124
+ oneshot(
125
+ model=model,
126
+ tokenizer=model_id,
127
+ dataset=DATASET_ID,
128
+ splits=DATASET_SPLIT,
129
+ recipe=recipe,
130
+ max_seq_length=MAX_SEQUENCE_LENGTH,
131
+ num_calibration_samples=NUM_CALIBRATION_SAMPLES,
132
+ trust_remote_code_model=True,
133
+ data_collator=data_collator,
134
+ output_dir=SAVE_DIR
135
+ )
136
+ ```
137
+ </details>
138
+
139
+ ## Evaluation
140
+
141
+ The model was evaluated on OpenLLM Leaderboard [V1](https://huggingface.co/spaces/open-llm-leaderboard-old/open_llm_leaderboard), OpenLLM Leaderboard [V2](https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard#/) and on [HumanEval](https://github.com/neuralmagic/evalplus), using the following commands:
142
+
143
+ <details>
144
+ <summary>Evaluation Commands</summary>
145
+
146
+ ```
147
+ ```
148
+
149
+ </details>
150
+
151
+ ### Accuracy
152
+
153
+ ## Inference Performance
154
+
155
+
156
+ This model achieves up to xxx speedup in single-stream deployment and up to xxx speedup in multi-stream asynchronous deployment, depending on hardware and use-case scenario.
157
+ The following performance benchmarks were conducted with [vLLM](https://docs.vllm.ai/en/latest/) version 0.7.2, and [GuideLLM](https://github.com/neuralmagic/guidellm).
158
+
159
+ <details>
160
+ <summary>Benchmarking Command</summary>
161
+ ```
162
+ guidellm --model nm-testing/Pixtral-Large-Instruct-2411-hf-quantized.w8a8 --target "http://localhost:8000/v1" --data-type emulated --data prompt_tokens=<prompt_tokens>,generated_tokens=<generated_tokens>,images=<num_images>,width=<image_width>,height=<image_height> --max seconds 120 --backend aiohttp_server
163
+ ```
164
+
165
+ </details>
166
+
167
+ ### Single-stream performance (measured with vLLM version 0.7.2)
168
+
169
+ <table border="1" class="dataframe">
170
+ <thead>
171
+ <tr>
172
+ <th></th>
173
+ <th></th>
174
+ <th></th>
175
+ <th style="text-align: center;" colspan="2" >Document Visual Question Answering<br>1680W x 2240H<br>64/128</th>
176
+ <th style="text-align: center;" colspan="2" >Visual Reasoning <br>640W x 480H<br>128/128</th>
177
+ <th style="text-align: center;" colspan="2" >Image Captioning<br>480W x 360H<br>0/128</th>
178
+ </tr>
179
+ <tr>
180
+ <th>Hardware</th>
181
+ <th>Model</th>
182
+ <th>Average Cost Reduction</th>
183
+ <th>Latency (s)</th>
184
+ <th>QPD</th>
185
+ <th>Latency (s)th>
186
+ <th>QPD</th>
187
+ <th>Latency (s)</th>
188
+ <th>QPD</th>
189
+ </tr>
190
+ </thead>
191
+ <tbody style="text-align: center">
192
+ <tr>
193
+ <td>A100x4</td>
194
+ <td>nm-testing/Pixtral-Large-Instruct-2411-hf</td>
195
+ <td></td>
196
+ <td>7.5</td>
197
+ <td>67</td>
198
+ <td>6.5</td>
199
+ <td>77</td>
200
+ <td>6.4</td>
201
+ <td>79</td>
202
+ </tr>
203
+ <tr>
204
+ <td>A100x2</td>
205
+ <td>nm-testing/Pixtral-Large-Instruct-2411-hf-quantized.w8a8</td>
206
+ <td>1.86</td>
207
+ <td>8.1</td>
208
+ <td>124</td>
209
+ <td>7.1</td>
210
+ <td>142</td>
211
+ <td>6.8</td>
212
+ <td>148</td>
213
+ </tr>
214
+ <tr>
215
+ <td>A100x2</td>
216
+ <td>nm-testing/Pixtral-Large-Instruct-2411-hf-quantized.w4a16</td>
217
+ <td>2.52</td>
218
+ <td>6.9</td>
219
+ <td>147</td>
220
+ <td>5.1</td>
221
+ <td>199</td>
222
+ <td>4.5</td>
223
+ <td>221</td>
224
+ </tr>
225
+ <tr>
226
+ <td>H100x4</td>
227
+ <td>nm-testing/Pixtral-Large-Instruct-2411-hf</td>
228
+ <td></td>
229
+ <td>4.4</td>
230
+ <td>67</td>
231
+ <td>3.9</td>
232
+ <td>74</td>
233
+ <td>3.7</td>
234
+ <td>79</td>
235
+ </tr>
236
+ <tr>
237
+ <td>H100x2</td>
238
+ <td>nm-testing/Pixtral-Large-Instruct-2411-hf-FP8-Dynamic</td>
239
+ <td>1.82</td>
240
+ <td>4.7</td>
241
+ <td>120</td>
242
+ <td>4.1</td>
243
+ <td>137</td>
244
+ <td>3.9</td>
245
+ <td>145</td>
246
+ </tr>
247
+ <tr>
248
+ <td>H100x2</td>
249
+ <td>nm-testing/Pixtral-Large-Instruct-2411-hf-quantized.w4a16</td>
250
+ <td>1.87</td>
251
+ <td>4.7</td>
252
+ <td>120</td>
253
+ <td>3.9</td>
254
+ <td>144</td>
255
+ <td>3.8</td>
256
+ <td>149</td>
257
+ </tr>
258
+ </tbody>
259
+ </table>
260
+
261
+
262
+
263
+ ### Multi-stream asynchronous performance (measured with vLLM version 0.7.2)
264
+
265
+ <table border="1" class="dataframe">
266
+ <thead>
267
+ <tr>
268
+ <th></th>
269
+ <th></th>
270
+ <th></th>
271
+ <th style="text-align: center;" colspan="2" >Document Visual Question Answering<br>1680W x 2240H<br>64/128</th>
272
+ <th style="text-align: center;" colspan="2" >Visual Reasoning <br>640W x 480H<br>128/128</th>
273
+ <th style="text-align: center;" colspan="2" >Image Captioning<br>480W x 360H<br>0/128</th>
274
+ </tr>
275
+ <tr>
276
+ <th>Hardware</th>
277
+ <th>Model</th>
278
+ <th>Average Cost Reduction</th>
279
+ <th>Maximum throughput (QPS)</th>
280
+ <th>QPD</th>
281
+ <th>Maximum throughput (QPS)</th>
282
+ <th>QPD</th>
283
+ <th>Maximum throughput (QPS)</th>
284
+ <th>QPD</th>
285
+ </tr>
286
+ </thead>
287
+ <tbody style="text-align: center">
288
+ <tr>
289
+ <td>A100x4</td>
290
+ <td>nm-testing/Pixtral-Large-Instruct-2411-hf</td>
291
+ <td></td>
292
+ <td>0.4</td>
293
+ <td>222</td>
294
+ <td>0.7</td>
295
+ <td>341</td>
296
+ <td>0.8</td>
297
+ <td>399</td>
298
+ </tr>
299
+ <tr>
300
+ <td>A100x2</td>
301
+ <td>nm-testing/Pixtral-Large-Instruct-2411-hf-quantized.w8a8</td>
302
+ <td>1.70</td>
303
+ <td>0.8</td>
304
+ <td>383</td>
305
+ <td>1.1</td>
306
+ <td>571</td>
307
+ <td>1.3</td>
308
+ <td>674</td>
309
+ </tr>
310
+ <tr>
311
+ <td>A100x2</td>
312
+ <td>nm-testing/Pixtral-Large-Instruct-2411-hf-quantized.w4a16</td>
313
+ <td>1.48</td>
314
+ <td>0.5</td>
315
+ <td>276</td>
316
+ <td>1.0</td>
317
+ <td>505</td>
318
+ <td>1.4</td>
319
+ <td>680</td>
320
+ </tr>
321
+ <tr>
322
+ <td>H100x4</td>
323
+ <td>nm-testing/Pixtral-Large-Instruct-2411-hf</td>
324
+ <td></td>
325
+ <td>1.0</td>
326
+ <td>284</td>
327
+ <td>1.6</td>
328
+ <td>465</td>
329
+ <td>1.8</td>
330
+ <td>511</td>
331
+ </tr>
332
+ <tr>
333
+ <td>H100x2</td>
334
+ <td>nm-testing/Pixtral-Large-Instruct-2411-hf-FP8-Dynamic</td>
335
+ <td>1.61</td>
336
+ <td>1.7</td>
337
+ <td>467</td>
338
+ <td>2.6</td>
339
+ <td>726</td>
340
+ <td>3.2</td>
341
+ <td>908</td>
342
+ </tr>
343
+ <tr>
344
+ <td>H100x2</td>
345
+ <td>nm-testing/Pixtral-Large-Instruct-2411-hf-quantized.w4a16</td>
346
+ <td>1.33</td>
347
+ <td>1.4</td>
348
+ <td>393</td>
349
+ <td>2.2</td>
350
+ <td>634</td>
351
+ <td>2.7</td>
352
+ <td>764</td>
353
+ </tr>
354
+ </tbody>
355
+ </table>