vllm.model_executor.models.pixtral
¶
Classes:
-
PatchMerger–Learned merging of spatial_merge_size ** 2 patches.
-
PixtralForConditionalGeneration– -
PixtralHFVisionModel– -
PixtralImagePixelInputs–Dimensions:
-
VisionTransformer–
Functions:
-
apply_rotary_emb_vit–Rotate
xq/xkof shape (bsz, seq_len, n_heads, head_dim). -
pixtral_patch_embed–Normalize and project all CHW images in one matrix multiplication.
-
precompute_freqs_cis_2d–freqs_cis: 2D complex tensor of shape (height, width, dim // 2)
PatchMerger
¶
Bases: Module
Learned merging of spatial_merge_size ** 2 patches.
Methods:
-
permute–Args:
Source code in vllm/model_executor/models/pixtral.py
1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 | |
permute(x, image_sizes)
¶
Parameters:
-
(x¶Tensor) –(N, D) where N is flattened and concatenated patch tokens for all images
-
(image_sizes¶list[tuple[int, int]]) –list of tuple of (height, width) in tokens for each image
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, SupportsEagle3, SupportsMultiModal, SupportsPP
Methods:
-
forward–Run forward pass for pixtral.
Source code in vllm/model_executor/models/pixtral.py
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 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 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 | |
forward(input_ids, positions, intermediate_tensors=None, inputs_embeds=None, **kwargs)
¶
Run forward pass for pixtral.
Source code in vllm/model_executor/models/pixtral.py
PixtralHFVisionModel
¶
Bases: Module
Methods:
-
forward–Args:
Source code in vllm/model_executor/models/pixtral.py
1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 | |
forward(pixel_values, *, select_layers=None, feature_select_strategy=None)
¶
Parameters:
-
(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
-
(select_layers¶list[int] | None, default:None) –Layer indices whose features should be concatenated and used as the visual encoder output. If none are provided, the last layer is used.
Returns:
-
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
1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 | |
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
VisionTransformer
¶
Bases: Module
Methods:
-
forward–Args:
Source code in vllm/model_executor/models/pixtral.py
981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 | |
forward(images)
¶
Parameters:
Returns:
-
image_features(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
apply_rotary_emb_vit(xq, xk, freqs_cis)
¶
Rotate xq/xk of shape (bsz, seq_len, n_heads, head_dim).
freqs_cis is the real view (seq_len, head_dim / 2, 2) of the complex
frequencies.
Source code in vllm/model_executor/models/pixtral.py
pixtral_patch_embed(images, weight, input_norm)
¶
Normalize and project all CHW images in one matrix multiplication.
Source code in vllm/model_executor/models/pixtral.py
precompute_freqs_cis_2d(dim, height, width, theta)
¶
freqs_cis: 2D complex tensor of shape (height, width, dim // 2) to be indexed by (height, width) position tuples