shubhrapandit commited on
Commit
25e2a5d
·
verified ·
1 Parent(s): 91b1203

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +369 -0
README.md ADDED
@@ -0,0 +1,369 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - w4a16
4
+ - int4
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.w4a16
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:** INT4
23
+ - **Activation quantization:** FP16
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 INT4 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.w4a16",
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
+ from compressed_tensors.quantization import QuantizationArgs, QuantizationType, QuantizationStrategy, ActivationOrdering, QuantizationScheme
87
+
88
+
89
+ # Load model.
90
+ model_id = "nm-testing/Pixtral-Large-Instruct-2411-hf"
91
+ model = TraceableLlavaForConditionalGeneration.from_pretrained(
92
+ model_id, device_map="auto", torch_dtype="auto"
93
+ )
94
+ processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
95
+
96
+ # Oneshot arguments
97
+ DATASET_ID = "flickr30k"
98
+ DATASET_SPLIT = {"calibration": "test[:512]"}
99
+ NUM_CALIBRATION_SAMPLES = 512
100
+ MAX_SEQUENCE_LENGTH = 2048
101
+ dampening_frac=0.01
102
+
103
+ # Define a oneshot data collator for multimodal inputs.
104
+ def data_collator(batch):
105
+ assert len(batch) == 1
106
+ return {
107
+ "input_ids": torch.LongTensor(batch[0]["input_ids"]),
108
+ "attention_mask": torch.tensor(batch[0]["attention_mask"]),
109
+ "pixel_values": torch.tensor(batch[0]["pixel_values"]),
110
+ }
111
+
112
+ recipe = GPTQModifier(
113
+ targets="Linear",
114
+ config_groups={
115
+ "config_group": QuantizationScheme(
116
+ targets=["Linear"],
117
+ weights=QuantizationArgs(
118
+ num_bits=4,
119
+ type=QuantizationType.INT,
120
+ strategy=QuantizationStrategy.GROUP,
121
+ group_size=128,
122
+ symmetric=True,
123
+ dynamic=False,
124
+ actorder=ActivationOrdering.WEIGHT,
125
+ ),
126
+ ),
127
+ },
128
+ sequential_targets=["MistralDecoderLayer"],
129
+ ignore=["re:.*lm_head", "re:vision_tower.*", "re:multi_modal_projector.*"],
130
+ update_size=NUM_CALIBRATION_SAMPLES,
131
+ dampening_frac=dampening_frac,
132
+ )
133
+
134
+ SAVE_DIR=f"{model_id.split('/')[1]}-quantized.w4a16"
135
+
136
+ # Perform oneshot
137
+ oneshot(
138
+ model=model,
139
+ tokenizer=model_id,
140
+ dataset=DATASET_ID,
141
+ splits=DATASET_SPLIT,
142
+ recipe=recipe,
143
+ max_seq_length=MAX_SEQUENCE_LENGTH,
144
+ num_calibration_samples=NUM_CALIBRATION_SAMPLES,
145
+ trust_remote_code_model=True,
146
+ data_collator=data_collator,
147
+ output_dir=SAVE_DIR
148
+ )
149
+
150
+ ```
151
+ </details>
152
+
153
+ ## Evaluation
154
+
155
+ 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:
156
+
157
+ <details>
158
+ <summary>Evaluation Commands</summary>
159
+
160
+ ```
161
+ ```
162
+
163
+ </details>
164
+
165
+ ### Accuracy
166
+
167
+ ## Inference Performance
168
+
169
+
170
+ 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.
171
+ 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).
172
+
173
+ <details>
174
+ <summary>Benchmarking Command</summary>
175
+ ```
176
+ guidellm --model nm-testing/Pixtral-Large-Instruct-2411-hf-quantized.w4a16 --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
177
+ ```
178
+
179
+ </details>
180
+
181
+ ### Single-stream performance (measured with vLLM version 0.7.2)
182
+
183
+ <table border="1" class="dataframe">
184
+ <thead>
185
+ <tr>
186
+ <th></th>
187
+ <th></th>
188
+ <th></th>
189
+ <th style="text-align: center;" colspan="2" >Document Visual Question Answering<br>1680W x 2240H<br>64/128</th>
190
+ <th style="text-align: center;" colspan="2" >Visual Reasoning <br>640W x 480H<br>128/128</th>
191
+ <th style="text-align: center;" colspan="2" >Image Captioning<br>480W x 360H<br>0/128</th>
192
+ </tr>
193
+ <tr>
194
+ <th>Hardware</th>
195
+ <th>Model</th>
196
+ <th>Average Cost Reduction</th>
197
+ <th>Latency (s)</th>
198
+ <th>QPD</th>
199
+ <th>Latency (s)th>
200
+ <th>QPD</th>
201
+ <th>Latency (s)</th>
202
+ <th>QPD</th>
203
+ </tr>
204
+ </thead>
205
+ <tbody style="text-align: center">
206
+ <tr>
207
+ <td>A100x4</td>
208
+ <td>nm-testing/Pixtral-Large-Instruct-2411-hf</td>
209
+ <td></td>
210
+ <td>7.5</td>
211
+ <td>67</td>
212
+ <td>6.5</td>
213
+ <td>77</td>
214
+ <td>6.4</td>
215
+ <td>79</td>
216
+ </tr>
217
+ <tr>
218
+ <td>A100x2</td>
219
+ <td>nm-testing/Pixtral-Large-Instruct-2411-hf-quantized.w8a8</td>
220
+ <td>1.86</td>
221
+ <td>8.1</td>
222
+ <td>124</td>
223
+ <td>7.1</td>
224
+ <td>142</td>
225
+ <td>6.8</td>
226
+ <td>148</td>
227
+ </tr>
228
+ <tr>
229
+ <td>A100x2</td>
230
+ <td>nm-testing/Pixtral-Large-Instruct-2411-hf-quantized.w4a16</td>
231
+ <td>2.52</td>
232
+ <td>6.9</td>
233
+ <td>147</td>
234
+ <td>5.1</td>
235
+ <td>199</td>
236
+ <td>4.5</td>
237
+ <td>221</td>
238
+ </tr>
239
+ <tr>
240
+ <td>H100x4</td>
241
+ <td>nm-testing/Pixtral-Large-Instruct-2411-hf</td>
242
+ <td></td>
243
+ <td>4.4</td>
244
+ <td>67</td>
245
+ <td>3.9</td>
246
+ <td>74</td>
247
+ <td>3.7</td>
248
+ <td>79</td>
249
+ </tr>
250
+ <tr>
251
+ <td>H100x2</td>
252
+ <td>nm-testing/Pixtral-Large-Instruct-2411-hf-FP8-Dynamic</td>
253
+ <td>1.82</td>
254
+ <td>4.7</td>
255
+ <td>120</td>
256
+ <td>4.1</td>
257
+ <td>137</td>
258
+ <td>3.9</td>
259
+ <td>145</td>
260
+ </tr>
261
+ <tr>
262
+ <td>H100x2</td>
263
+ <td>nm-testing/Pixtral-Large-Instruct-2411-hf-quantized.w4a16</td>
264
+ <td>1.87</td>
265
+ <td>4.7</td>
266
+ <td>120</td>
267
+ <td>3.9</td>
268
+ <td>144</td>
269
+ <td>3.8</td>
270
+ <td>149</td>
271
+ </tr>
272
+ </tbody>
273
+ </table>
274
+
275
+
276
+
277
+ ### Multi-stream asynchronous performance (measured with vLLM version 0.7.2)
278
+
279
+ <table border="1" class="dataframe">
280
+ <thead>
281
+ <tr>
282
+ <th></th>
283
+ <th></th>
284
+ <th></th>
285
+ <th style="text-align: center;" colspan="2" >Document Visual Question Answering<br>1680W x 2240H<br>64/128</th>
286
+ <th style="text-align: center;" colspan="2" >Visual Reasoning <br>640W x 480H<br>128/128</th>
287
+ <th style="text-align: center;" colspan="2" >Image Captioning<br>480W x 360H<br>0/128</th>
288
+ </tr>
289
+ <tr>
290
+ <th>Hardware</th>
291
+ <th>Model</th>
292
+ <th>Average Cost Reduction</th>
293
+ <th>Maximum throughput (QPS)</th>
294
+ <th>QPD</th>
295
+ <th>Maximum throughput (QPS)</th>
296
+ <th>QPD</th>
297
+ <th>Maximum throughput (QPS)</th>
298
+ <th>QPD</th>
299
+ </tr>
300
+ </thead>
301
+ <tbody style="text-align: center">
302
+ <tr>
303
+ <td>A100x4</td>
304
+ <td>nm-testing/Pixtral-Large-Instruct-2411-hf</td>
305
+ <td></td>
306
+ <td>0.4</td>
307
+ <td>222</td>
308
+ <td>0.7</td>
309
+ <td>341</td>
310
+ <td>0.8</td>
311
+ <td>399</td>
312
+ </tr>
313
+ <tr>
314
+ <td>A100x2</td>
315
+ <td>nm-testing/Pixtral-Large-Instruct-2411-hf-quantized.w8a8</td>
316
+ <td>1.70</td>
317
+ <td>0.8</td>
318
+ <td>383</td>
319
+ <td>1.1</td>
320
+ <td>571</td>
321
+ <td>1.3</td>
322
+ <td>674</td>
323
+ </tr>
324
+ <tr>
325
+ <td>A100x2</td>
326
+ <td>nm-testing/Pixtral-Large-Instruct-2411-hf-quantized.w4a16</td>
327
+ <td>1.48</td>
328
+ <td>0.5</td>
329
+ <td>276</td>
330
+ <td>1.0</td>
331
+ <td>505</td>
332
+ <td>1.4</td>
333
+ <td>680</td>
334
+ </tr>
335
+ <tr>
336
+ <td>H100x4</td>
337
+ <td>nm-testing/Pixtral-Large-Instruct-2411-hf</td>
338
+ <td></td>
339
+ <td>1.0</td>
340
+ <td>284</td>
341
+ <td>1.6</td>
342
+ <td>465</td>
343
+ <td>1.8</td>
344
+ <td>511</td>
345
+ </tr>
346
+ <tr>
347
+ <td>H100x2</td>
348
+ <td>nm-testing/Pixtral-Large-Instruct-2411-hf-FP8-Dynamic</td>
349
+ <td>1.61</td>
350
+ <td>1.7</td>
351
+ <td>467</td>
352
+ <td>2.6</td>
353
+ <td>726</td>
354
+ <td>3.2</td>
355
+ <td>908</td>
356
+ </tr>
357
+ <tr>
358
+ <td>H100x2</td>
359
+ <td>nm-testing/Pixtral-Large-Instruct-2411-hf-quantized.w4a16</td>
360
+ <td>1.33</td>
361
+ <td>1.4</td>
362
+ <td>393</td>
363
+ <td>2.2</td>
364
+ <td>634</td>
365
+ <td>2.7</td>
366
+ <td>764</td>
367
+ </tr>
368
+ </tbody>
369
+ </table>