shubhrapandit commited on
Commit
661ab35
·
verified ·
1 Parent(s): 0843f89

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +389 -0
README.md ADDED
@@ -0,0 +1,389 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - vllm
4
+ - vision
5
+ - fp8
6
+ license: apache-2.0
7
+ license_link: >-
8
+ https://huggingface.co/datasets/choosealicense/licenses/blob/main/markdown/apache-2.0.md
9
+ language:
10
+ - en
11
+ base_model: mgoin/pixtral-12b
12
+ library_name: transformers
13
+ ---
14
+
15
+ # pixtral-12b-FP8-Dynamic
16
+
17
+ ## Model Overview
18
+ - **Model Architecture:** mgoin/pixtral-12b
19
+ - **Input:** Vision-Text
20
+ - **Output:** Text
21
+ - **Model Optimizations:**
22
+ - **Weight quantization:** FP8
23
+ - **Activation quantization:** FP8
24
+ - **Release Date:** 2/24/2025
25
+ - **Version:** 1.0
26
+ - **Model Developers:** Neural Magic
27
+
28
+ Quantized version of [mgoin/pixtral-12b](https://huggingface.co/mgoin/pixtral-12b).
29
+
30
+ ### Model Optimizations
31
+
32
+ This model was obtained by quantizing the weights of [mgoin/pixtral-12b](https://huggingface.co/mgoin/pixtral-12b) to FP8 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-12b-FP8-Dynamic",
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.transformers import oneshot
84
+ from llmcompressor.transformers.tracing import TraceableLlavaForConditionalGeneration
85
+ from llmcompressor.modifiers.quantization import QuantizationModifier
86
+ import os
87
+
88
+ # Load model.
89
+ model_id = mgoin/pixtral-12b
90
+ model = TraceableLlavaForConditionalGeneration.from_pretrained(
91
+ model_id, device_map="auto", torch_dtype="auto"
92
+ )
93
+ processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
94
+
95
+ # Recipe
96
+ recipe = [
97
+ QuantizationModifier(
98
+ targets="Linear",
99
+ scheme="FP8_DYNAMIC",
100
+ sequential_targets=["MistralDecoderLayer"],
101
+ ignore=["re:.*lm_head", "re:vision_tower.*", "re:multi_modal_projector.*"],
102
+ ),
103
+ ]
104
+
105
+ SAVE_DIR=f"{model_id.split('/')[1]}-FP8-Dynamic"
106
+
107
+ # Perform oneshot
108
+ oneshot(
109
+ model=model,
110
+ recipe=recipe,
111
+ trust_remote_code_model=True,
112
+ output_dir=SAVE_DIR
113
+ )
114
+
115
+
116
+ ```
117
+ </details>
118
+
119
+ ## Evaluation
120
+
121
+ 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:
122
+
123
+ <details>
124
+ <summary>Evaluation Commands</summary>
125
+
126
+ ```
127
+ ```
128
+
129
+ </details>
130
+
131
+ ### Accuracy
132
+
133
+ ## Inference Performance
134
+
135
+
136
+ 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.
137
+ 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).
138
+
139
+ <details>
140
+ <summary>Benchmarking Command</summary>
141
+ ```
142
+ guidellm --model neuralmagic/pixtral-12b-FP8-Dynamic --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
143
+ ```
144
+
145
+ </details>
146
+
147
+ ### Single-stream performance (measured with vLLM version 0.7.2)
148
+
149
+ <table border="1" class="dataframe">
150
+ <thead>
151
+ <tr>
152
+ <th></th>
153
+ <th></th>
154
+ <th></th>
155
+ <th style="text-align: center;" colspan="2" >Document Visual Question Answering<br>1680W x 2240H<br>64/128</th>
156
+ <th style="text-align: center;" colspan="2" >Visual Reasoning <br>640W x 480H<br>128/128</th>
157
+ <th style="text-align: center;" colspan="2" >Image Captioning<br>480W x 360H<br>0/128</th>
158
+ </tr>
159
+ <tr>
160
+ <th>Hardware</th>
161
+ <th>Model</th>
162
+ <th>Average Cost Reduction</th>
163
+ <th>Latency (s)</th>
164
+ <th>QPD</th>
165
+ <th>Latency (s)th>
166
+ <th>QPD</th>
167
+ <th>Latency (s)</th>
168
+ <th>QPD</th>
169
+ </tr>
170
+ </thead>
171
+ <tbody style="text-align: center">
172
+ <tr>
173
+ <th rowspan="3" valign="top">A6000x1</th>
174
+ <th>mgoin/pixtral-12b</th>
175
+ <td></td>
176
+ <td>5.7</td>
177
+ <td>796</td>
178
+ <td>4.8</td>
179
+ <td>929</td>
180
+ <td>4.7</td>
181
+ <td>964</td>
182
+ </tr>
183
+ <tr>
184
+ <th>neuralmagic/pixtral-12b-quantized.w8a8</th>
185
+ <td>1.55</td>
186
+ <td>3.7</td>
187
+ <td>1220</td>
188
+ <td>3.1</td>
189
+ <td>1437</td>
190
+ <td>3.0</td>
191
+ <td>1511</td>
192
+ </tr>
193
+ <tr>
194
+ <th>neuralmagic/pixtral-12b-quantized.w4a16</th>
195
+ <td>2.16</td>
196
+ <td>3.2</td>
197
+ <td>1417</td>
198
+ <td>2.1</td>
199
+ <td>2093</td>
200
+ <td>1.9</td>
201
+ <td>2371</td>
202
+ </tr>
203
+ <tr>
204
+ <th rowspan="3" valign="top">A100x1</th>
205
+ <th>mgoin/pixtral-12b</th>
206
+ <td></td>
207
+ <td>3.0</td>
208
+ <td>676</td>
209
+ <td>2.4</td>
210
+ <td>825</td>
211
+ <td>2.3</td>
212
+ <td>859</td>
213
+ </tr>
214
+ <tr>
215
+ <th>neuralmagic/pixtral-12b-quantized.w8a8</th>
216
+ <td>1.38</td>
217
+ <td>2.2</td>
218
+ <td>904</td>
219
+ <td>1.7</td>
220
+ <td>1159</td>
221
+ <td>1.7</td>
222
+ <td>1201</td>
223
+ </tr>
224
+ <tr>
225
+ <th>neuralmagic/pixtral-12b-quantized.w4a16</th>
226
+ <td>1.83</td>
227
+ <td>1.8</td>
228
+ <td>1096</td>
229
+ <td>1.3</td>
230
+ <td>1557</td>
231
+ <td>1.2</td>
232
+ <td>1702</td>
233
+ </tr>
234
+ <tr>
235
+ <th rowspan="3" valign="top">H100x1</th>
236
+ <th>mgoin/pixtral-12b</th>
237
+ <td></td>
238
+ <td>1.8</td>
239
+ <td>595</td>
240
+ <td>1.5</td>
241
+ <td>732</td>
242
+ <td>1.4</td>
243
+ <td>764</td>
244
+ </tr>
245
+ <tr>
246
+ <th>neuralmagic/pixtral-12b-FP8-Dynamic</th>
247
+ <td>1.35</td>
248
+ <td>1.4</td>
249
+ <td>767</td>
250
+ <td>1.1</td>
251
+ <td>1008</td>
252
+ <td>1.0</td>
253
+ <td>1056</td>
254
+ </tr>
255
+ <tr>
256
+ <th>neuralmagic/pixtral-12b-quantized.w4a16</th>
257
+ <td>1.37</td>
258
+ <td>1.4</td>
259
+ <td>787</td>
260
+ <td>1.1</td>
261
+ <td>1018</td>
262
+ <td>1.0</td>
263
+ <td>1065</td>
264
+ </tr>
265
+ </tbody>
266
+ </table>
267
+
268
+
269
+
270
+ ### Multi-stream asynchronous performance (measured with vLLM version 0.7.2)
271
+
272
+ <table border="1" class="dataframe">
273
+ <thead>
274
+ <tr>
275
+ <th></th>
276
+ <th></th>
277
+ <th></th>
278
+ <th style="text-align: center;" colspan="2" >Document Visual Question Answering<br>1680W x 2240H<br>64/128</th>
279
+ <th style="text-align: center;" colspan="2" >Visual Reasoning <br>640W x 480H<br>128/128</th>
280
+ <th style="text-align: center;" colspan="2" >Image Captioning<br>480W x 360H<br>0/128</th>
281
+ </tr>
282
+ <tr>
283
+ <th>Hardware</th>
284
+ <th>Model</th>
285
+ <th>Average Cost Reduction</th>
286
+ <th>Maximum throughput (QPS)</th>
287
+ <th>QPD</th>
288
+ <th>Maximum throughput (QPS)</th>
289
+ <th>QPD</th>
290
+ <th>Maximum throughput (QPS)</th>
291
+ <th>QPD</th>
292
+ </tr>
293
+ </thead>
294
+ <tbody style="text-align: center">
295
+ <tr>
296
+ <th rowspan="3" valign="top">A6000x1</th>
297
+ <th>mgoin/pixtral-12b</th>
298
+ <td></td>
299
+ <td>0.6</td>
300
+ <td>2632</td>
301
+ <td>0.9</td>
302
+ <td>4108</td>
303
+ <td>1.1</td>
304
+ <td>4774</td>
305
+ </tr>
306
+ <tr>
307
+ <th>neuralmagic/pixtral-12b-quantized.w8a8</th>
308
+ <td>1.50</td>
309
+ <td>0.9</td>
310
+ <td>3901</td>
311
+ <td>1.4</td>
312
+ <td>6160</td>
313
+ <td>1.6</td>
314
+ <td>7292</td>
315
+ </tr>
316
+ <tr>
317
+ <th>neuralmagic/pixtral-12b-quantized.w4a16</th>
318
+ <td>1.41</td>
319
+ <td>0.6</td>
320
+ <td>2890</td>
321
+ <td>1.3</td>
322
+ <td>5758</td>
323
+ <td>1.8</td>
324
+ <td>8312</td>
325
+ </tr>
326
+ <tr>
327
+ <th rowspan="3" valign="top">A100x1</th>
328
+ <th>mgoin/pixtral-12b</th>
329
+ <td></td>
330
+ <td>1.1</td>
331
+ <td>2291</td>
332
+ <td>1.8</td>
333
+ <td>3670</td>
334
+ <td>2.1</td>
335
+ <td>4284</td>
336
+ </tr>
337
+ <tr>
338
+ <th>neuralmagic/pixtral-12b-quantized.w8a8</th>
339
+ <td>1.38</td>
340
+ <td>1.5</td>
341
+ <td>3096</td>
342
+ <td>2.5</td>
343
+ <td>5076</td>
344
+ <td>3.0</td>
345
+ <td>5965</td>
346
+ </tr>
347
+ <tr>
348
+ <th>neuralmagic/pixtral-12b-quantized.w4a16</th>
349
+ <td>1.40</td>
350
+ <td>1.4</td>
351
+ <td>2728</td>
352
+ <td>2.6</td>
353
+ <td>5133</td>
354
+ <td>3.5</td>
355
+ <td>6943</td>
356
+ </tr>
357
+ <tr>
358
+ <th rowspan="3" valign="top">H100x1</th>
359
+ <th>BF16</th>
360
+ <td></td>
361
+ <td>2.6</td>
362
+ <td>2877</td>
363
+ <td>4.0</td>
364
+ <td>4372</td>
365
+ <td>4.7</td>
366
+ <td>5095</td>
367
+ </tr>
368
+ <tr>
369
+ <th>neuralmagic/pixtral-12b-FP8-Dynamic</th>
370
+ <td>1.33</td>
371
+ <td>3.4</td>
372
+ <td>3753</td>
373
+ <td>5.4</td>
374
+ <td>5862</td>
375
+ <td>6.3</td>
376
+ <td>6917</td>
377
+ </tr>
378
+ <tr>
379
+ <th>neuralmagic/pixtral-12b-quantized.w4a16</th>
380
+ <td>1.22</td>
381
+ <td>2.8</td>
382
+ <td>3115</td>
383
+ <td>5.0</td>
384
+ <td>5511</td>
385
+ <td>6.2</td>
386
+ <td>6777</td>
387
+ </tr>
388
+ </tbody>
389
+ </table>