vllm.model_executor.models.pixtral
¶
Classes:
-
PatchMerger–Learned merging of spatial_merge_size ** 2 patches.
-
PixtralForConditionalGeneration– -
PixtralHFVisionModel– -
PixtralImagePixelInputs–Dimensions:
-
VisionTransformer–
Functions:
-
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
1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 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 | |
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
341 342 343 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 | |
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
1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 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 | |
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
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 | |
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
950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 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 | |
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
_reshape_for_broadcast(freqs_cis, x)
¶
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
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