vllm.model_executor.models.kimi_k25_vit ¶
Vision tower implementation for Kimi-K2.5 model.
This module provides the vision encoder components for Kimi-K2.5, including 3D patch embedding, RoPE position embedding, and temporal pooling for video chunks.
Classes:
-
KimiK25MultiModalProjector–Multi-modal projector with patch merging for Kimi-K2.5.
-
Learnable2DInterpPosEmbDivided_fixed–2D learnable position embedding with temporal extension.
-
MLP2–Two-layer MLP with tensor parallel support.
-
MoonViT3dEncoder–Full encoder stack for MoonViT 3D.
-
MoonViT3dPretrainedModel–Main vision tower model.
-
MoonViTEncoderLayer–Single encoder layer for MoonViT with TP/DP support.
-
MoonVision3dPatchEmbed–3D patch embedding for vision tower.
-
Rope2DPosEmbRepeated–2D rotary position embedding with multi-resolution support.
Functions:
-
build_image_merge_gather_idx–Build packed spatial-merge indices for image-only CUDA graphs.
-
get_1d_sincos_pos_embed–Generate 1D sincos positional embedding.
-
get_1d_sincos_pos_embed_from_grid–Generate 1D sincos positional embedding from grid positions.
-
mm_projector_forward–Apply MM projector to vision tower outputs.
-
tpool_patch_merger–Temporal pooling patch merger.
-
tpool_patch_merger_packed–Apply the image-only spatial merge using precomputed tensor indices.
-
vision_tower_forward–DP-sharded vision tower forward with mrope.
KimiK25MultiModalProjector ¶
Bases: Module
Multi-modal projector with patch merging for Kimi-K2.5.
Source code in vllm/model_executor/models/kimi_k25_vit.py
Learnable2DInterpPosEmbDivided_fixed ¶
Bases: Module
2D learnable position embedding with temporal extension.
Source code in vllm/model_executor/models/kimi_k25_vit.py
MLP2 ¶
Bases: Module
Two-layer MLP with tensor parallel support.
Source code in vllm/model_executor/models/kimi_k25_vit.py
MoonViT3dEncoder ¶
Bases: Module
Full encoder stack for MoonViT 3D.
Source code in vllm/model_executor/models/kimi_k25_vit.py
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 | |
MoonViT3dPretrainedModel ¶
Bases: Module
Main vision tower model.
Uses KimiK25VisionConfig directly from transformers_utils/configs/kimi_k25.py.
Methods:
-
forward–Args:
-
prepare_encoder_cudagraph_metadata–Precompute fixed-buffer metadata for image encoder CUDA graphs.
Source code in vllm/model_executor/models/kimi_k25_vit.py
695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 | |
forward(pixel_values, grid_thws, *, encoder_metadata=None) ¶
Parameters:
-
(pixel_values¶Tensor) –The input pixel values.
-
(grid_thws¶Tensor) –Temporal, height and width.
Returns:
-
Tensor–torch.Tensor: The output tokens.
Source code in vllm/model_executor/models/kimi_k25_vit.py
prepare_encoder_cudagraph_metadata(grid_thw_list, *, max_batch_size, max_seqlen_override=None, device) ¶
Precompute fixed-buffer metadata for image encoder CUDA graphs.
Source code in vllm/model_executor/models/kimi_k25_vit.py
MoonViTEncoderLayer ¶
Bases: Module
Single encoder layer for MoonViT with TP/DP support.
Methods:
-
attention_qkvpacked–Compute self-attention with packed QKV.
Source code in vllm/model_executor/models/kimi_k25_vit.py
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 | |
attention_qkvpacked(x, cu_seqlens, rope_freqs_cis, max_seqlen=None, sequence_lengths=None) ¶
Compute self-attention with packed QKV.
Parameters:
Source code in vllm/model_executor/models/kimi_k25_vit.py
MoonVision3dPatchEmbed ¶
Bases: Module
3D patch embedding for vision tower.
Source code in vllm/model_executor/models/kimi_k25_vit.py
Rope2DPosEmbRepeated ¶
Bases: Module
2D rotary position embedding with multi-resolution support.
Methods:
-
get_freqs_cis–Args:
Source code in vllm/model_executor/models/kimi_k25_vit.py
_precompute_freqs_cis(device) ¶
Calculate the cis(freqs) for each position in the 2D grid.
Source code in vllm/model_executor/models/kimi_k25_vit.py
get_freqs_cis(grid_thws, device) ¶
Parameters:
Returns:
-
freqs_cis(Tensor) –tensor of shape (sum(t * height * width), dim//2)
Source code in vllm/model_executor/models/kimi_k25_vit.py
build_image_merge_gather_idx(grid_thws, merge_kernel_size) ¶
Build packed spatial-merge indices for image-only CUDA graphs.
Source code in vllm/model_executor/models/kimi_k25_vit.py
get_1d_sincos_pos_embed(embed_dim, t_size, cls_token=False) ¶
Generate 1D sincos positional embedding.
Source code in vllm/model_executor/models/kimi_k25_vit.py
get_1d_sincos_pos_embed_from_grid(embed_dim, pos) ¶
Generate 1D sincos positional embedding from grid positions.
Source code in vllm/model_executor/models/kimi_k25_vit.py
mm_projector_forward(mm_projector, vt_output) ¶
Apply MM projector to vision tower outputs.
Source code in vllm/model_executor/models/kimi_k25_vit.py
tpool_patch_merger(x, grid_thws, merge_kernel_size=(2, 2)) ¶
Temporal pooling patch merger.
Source code in vllm/model_executor/models/kimi_k25_vit.py
tpool_patch_merger_packed(x, merge_gather_idx) ¶
Apply the image-only spatial merge using precomputed tensor indices.
vision_tower_forward(vision_tower, pixel_values, grid_thw, mm_projector, use_data_parallel) ¶
DP-sharded vision tower forward with mrope.
Uses vLLM's standard data parallelism utility to shard the batch across available GPUs, enabling parallel processing of vision features.