vllm.model_executor.models.pixtral ¶
PatchMerger ¶
Bases: Module
Learned merging of spatial_merge_size ** 2 patches
Source code in vllm/model_executor/models/pixtral.py
permute ¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x | Tensor | (N, D) where N is flattened and concatenated patch tokens for all images | required |
image_sizes | list[tuple[int, int]] | list of tuple of (height, width) in tokens for each image | required |
Returns: image_features: reorders patch tokens so each grid of (spatial_merge_size, spatial_merge_size) is contiguous. now (N / spatial_merge_size ** 2, D * spatial_merge_size ** 2)
Source code in vllm/model_executor/models/pixtral.py
PixtralForConditionalGeneration ¶
Bases: Module, SupportsLoRA, SupportsMultiModal, SupportsPP
Source code in vllm/model_executor/models/pixtral.py
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 | |
forward ¶
forward(
input_ids: Tensor | None,
positions: Tensor,
intermediate_tensors: IntermediateTensors | None = None,
inputs_embeds: Tensor | None = None,
**kwargs: object,
) -> Tensor | IntermediateTensors
Run forward pass for pixtral.
Source code in vllm/model_executor/models/pixtral.py
PixtralHFVisionModel ¶
Bases: Module
Source code in vllm/model_executor/models/pixtral.py
1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 | |
forward ¶
forward(
pixel_values: list[Tensor],
*,
select_layers: list[int] | None = None,
feature_select_strategy: VisionFeatureSelectStrategy
| None = None,
) -> tuple[Tensor, ...]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pixel_values | list[Tensor] | Each image to be processed will be a separate tensor in pixel_values. This means it will be a list of tensors because multiple requests batched can have multiple images, each with their own shape potentially | required |
select_layers | list[int] | None | Layer indices whose features should be concatenated and used as the visual encoder output. If none are provided, the last layer is used. | None |
Returns:
| Name | Type | Description |
|---|---|---|
image_features | tuple[Tensor, ...] | tensor of token features for all tokens of all images of shape (N_toks, D) |
Source code in vllm/model_executor/models/pixtral.py
1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 | |
PixtralImagePixelInputs ¶
Bases: TensorSchema
Dimensions
- bn: Batch size * number of images
- c: Number of channels (3)
- h: Height of each image
- w: Width of each image
The result of stacking ImageEncoding.tokens from each prompt.
Source code in vllm/model_executor/models/pixtral.py
PixtralProcessorAdapter ¶
Provide a HF-compatible interface for mistral_common.tokens.tokenizers.multimodal.ImageEncoder.
Source code in vllm/model_executor/models/pixtral.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
VisionTransformer ¶
Bases: Module
Source code in vllm/model_executor/models/pixtral.py
804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 | |
forward ¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images | list[Tensor] | list of N_img images of variable sizes, each of shape (C, H, W) | required |
Returns: image_features: tensor of token features for all tokens of all images of shape (N_toks, D)
Source code in vllm/model_executor/models/pixtral.py
_reshape_for_broadcast ¶
freqs_cis: complex - (seq_len, head_dim / 2) x: complex - (bsz, seq_len, head_dim / 2)
Source code in vllm/model_executor/models/pixtral.py
precompute_freqs_cis_2d ¶
2D complex tensor of shape (height, width, dim // 2)
to be indexed by (height, width) position tuples