vllm.model_executor.models.gemma3_mm ¶
Classes:
-
Gemma3ForConditionalGeneration– -
Gemma3ImagePixelInputs–Dimensions:
Gemma3ForConditionalGeneration ¶
Bases: Module, SupportsMultiModal, SupportsPP, SupportsLoRA
Methods:
-
get_mm_mapping–Get the module prefix in multimodal models
-
get_num_mm_connector_tokens–Calculate the number of tokens output by the multimodal connector.
-
get_num_mm_encoder_tokens–Calculate the number of tokens output by the vision encoder.
Source code in vllm/model_executor/models/gemma3_mm.py
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 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 | |
get_mm_mapping() ¶
Get the module prefix in multimodal models
Source code in vllm/model_executor/models/gemma3_mm.py
get_num_mm_connector_tokens(num_vision_tokens) ¶
Calculate the number of tokens output by the multimodal connector.
The connector applies projection and normalization but maintains the token count for Gemma3.
Parameters:
Returns:
-
int–Number of tokens after connector processing
Source code in vllm/model_executor/models/gemma3_mm.py
get_num_mm_encoder_tokens(num_image_tokens) ¶
Calculate the number of tokens output by the vision encoder.
The vision encoder processes images into patch embeddings. For Gemma3, the relationship between prompt placeholder tokens and actual vision encoder output tokens depends on the patch grid size.
Parameters:
-
(num_image_tokens¶int) –Number of image placeholder tokens in the prompt (typically mm_tokens_per_image per image)
Returns:
-
int–Number of tokens output by the vision encoder
Source code in vllm/model_executor/models/gemma3_mm.py
Gemma3ImagePixelInputs ¶
Bases: TensorSchema
Dimensions
- p: Number of patches total (over each image over each prompt in the batch)
- c: Number of channels (3)
- h: Height of each patch
- w: Width of each patch
- bn: Batch size * number of images