Skip to content

vllm.model_executor.models.minicpmv

Inference-only MiniCPM-V model compatible with HuggingFace weights.

Classes:

MiniCPMV

Bases: MiniCPMVBaseModel, SupportsMultiModal, SupportsLoRA

Different versions of MiniCPMV use different visual encoders and LLMs, which is not conducive to the current integration logic of LoRA and bitsandbytes in vLLM. Therefore, it is necessary to separate them.

MiniCPMVBaseModel

Bases: Module, SupportsMultiModal, SupportsPP

The abstract class of MiniCPMV can only be inherited, but cannot be instantiated.

Methods:

get_mm_mapping()

Get the module prefix in multimodal models.

MiniCPMVImageEmbeddingInputs

Bases: TensorSchema

Dimensions: - bn: Batch size * number of images - ns: Number of slices - hs: Hidden size (must match language model backbone)

MiniCPMVImagePixelInputs

Bases: TensorSchema

Dimensions: - bns: Batch size * number of images * number of slices - bn: Batch size * number of images - c: Number of channels - h: Height - w: Width

MiniCPMVMultiModalProcessor

Bases: BaseMultiModalProcessor[_I]

_apply_prompt_updates(token_ids, mm_prompt_updates)

Apply multi-modal prompt updates to token IDs.

Resampler4_5

Bases: Resampler2_5

Methods:

get_1d_sincos_pos_embed_from_temporal_size(embed_dim, pos)

embed_dim: output dimension for each position pos: a list of positions to be encoded: size (M,) out: (M, D)

_MiniCPMVEncoderCudaGraphMixin

Bases: MiniCPMVBaseModel, SupportsEncoderCudaGraph

SupportsEncoderCudaGraph for MiniCPM-V Idefics2 + resampler (not 2.0).

Methods:

_mcpmv_patch_grid_keys()

Ordered patch-grid keys (nb_h, nb_w) for the capture axis.

_mcpmv_resolve_patch_grid(tgt_sizes, slice_counts, indices)

Smallest patch-grid key covering all selected items.

_mcpmv_select_items(mm_kwargs, indices)

Slice mm_kwargs for indices; also returns the patch-grid key.

encoder_eager_forward(mm_kwargs, path='default')

Eager encoder path; returns (total_tokens, embed_dim) like encoder_cudagraph_forward.

_mcpmv_normalize_tgt_sizes(tgt_sizes, slice_counts)

Normalize tgt_sizes to shape (total_slices, 2).

_mcpmv_pack_flat_pixels(slices, *, pixel_height, pixel_width, max_num_slices, device, dtype, patch_size, tgt_sizes)

Pack slice tensors into a fixed (max_num_slices, 3*H*W) buffer.