vllm.model_executor.models.qwen2_vl
¶
Inference-only Qwen2-VL model compatible with HuggingFace weights.
Classes:
-
Qwen2VLForConditionalGeneration– -
Qwen2VLImageEmbeddingInputs–Dimensions:
-
Qwen2VLImagePixelInputs–Dimensions:
-
Qwen2VLProcessingInfo– -
Qwen2VLVideoEmbeddingInputs–Dimensions:
-
Qwen2VLVideoPixelInputs–Dimensions:
Qwen2VLForConditionalGeneration
¶
Bases: Module, SupportsMultiModal, SupportsLoRA, SupportsPP, SupportsMRoPE, Qwen2VLEncoderCudaGraphMixin
Methods:
-
forward–Run forward pass for Qwen2-VL.
-
get_mm_mapping–Get the module prefix in multimodal models.
-
iter_mm_grid_thw–Iterate over multimodal features and yield grid information.
forward(input_ids, positions, intermediate_tensors=None, inputs_embeds=None, **kwargs)
¶
Run forward pass for Qwen2-VL.
Parameters:
-
(input_ids¶Tensor | None) –Flattened (concatenated) input_ids corresponding to a batch.
-
(positions¶Tensor) –Flattened (concatenated) position ids corresponding to a batch. NOTE: If mrope is enabled (default setting for Qwen2-VL opensource models), the shape will be
(3, seq_len), otherwise it will be(seq_len,). -
(intermediate_tensors¶IntermediateTensors | None, default:None) –Intermediate tensors from prior forward pass.
-
(inputs_embeds¶Tensor | None, default:None) –Optional tensor of input embeddings.
-
(**kwargs¶object, default:{}) –Multimodal inputs for this batch, forwarded to the multimodal embedding path.
get_mm_mapping()
¶
Get the module prefix in multimodal models.
iter_mm_grid_thw(mm_features)
¶
Qwen2VLImageEmbeddingInputs
¶
Bases: TensorSchema
Dimensions
- nf: Number of image features
- hs: Hidden size
- ni: Number of images
Historical context
- image_embeds shape: (num_image_features, hidden_size)
- num_image_features varies based on the number and resolution of the images.
- hidden_size must match the hidden size of language model backbone.
- image_grid_thw shape: (num_images, 3) in (grid_t, grid_h, grid_w) format
Qwen2VLImagePixelInputs
¶
Bases: TensorSchema
Dimensions
- np: The total number of patches over each image over each prompt in the batch
- ni: Number of images
- cps: Number of channels * patch_size * patch_size
Historical context
- pixel_values shape: (num_patches, num_channels * patch_size * patch_size)
- image_grid_thw shape: (num_images, 3) in (grid_t, grid_h, grid_w) format
Qwen2VLProcessingInfo
¶
Bases: BaseProcessingInfo
_complete_mm_processor_size_aliases(mm_kwargs)
staticmethod
¶
Complete missing Qwen-VL size aliases.
Qwen-VL accepts size.shortest_edge / min_pixels and
size.longest_edge / max_pixels as equivalent controls. When
only one representation is provided with a non-None value, add the
missing equivalent representation. If both are already present, leave
them unchanged even when their values conflict.
Apply this independently to the flat kwargs and to each existing
images_kwargs / videos_kwargs mapping. Values are not propagated
between these mappings.
_get_vision_size(mm_kwargs, default_size=None)
staticmethod
¶
Resolve Qwen-VL vision size kwargs with optional processor defaults.
size overrides any processor defaults, then min_pixels and
max_pixels override the corresponding size edges.
_merge_and_resolve_mm_processor_kwargs(mm_kwargs)
¶
Merge configured and request Qwen-VL mm_processor_kwargs.
Request-side size.shortest_edge / min_pixels and
size.longest_edge / max_pixels aliases are completed before the
merge so request precedence is preserved across equivalent
representations.
Qwen2VLVideoEmbeddingInputs
¶
Bases: TensorSchema
Dimensions
- nf: Number of video features
- hs: Hidden size
- nv: Number of videos
Historical context
- video_embeds shape: (num_video_features, hidden_size)
- num_video_features varies based on the number and resolution of the videos.
- hidden_size must match the hidden size of language model backbone.
- video_grid_thw shape: (num_videos, 3) in (grid_t, grid_h, grid_w) format
Qwen2VLVideoPixelInputs
¶
Bases: TensorSchema
Dimensions
- np: The total number of patches over each video over each prompt in the batch
- ctps: Number of channels * temporal_patch_size * patch_size * patch_size
- nv: Number of videos
Historical context
- pixel_values_videos shape: (num_patches, num_channels * temporal_patch_size * patch_size * patch_size)
- video_grid_thw shape: (num_videos, 3) in (grid_t, grid_h, grid_w) format