vllm.model_executor.models.qwen2_5_vl
¶
Inference-only Qwen2.5-VL model compatible with HuggingFace weights.
Classes:
-
Qwen2_5_VLForConditionalGeneration– -
Qwen2_5_VLImageEmbeddingInputs–Dimensions:
-
Qwen2_5_VLImagePixelInputs–Dimensions:
-
Qwen2_5_VLVideoEmbeddingInputs–Dimensions:
-
Qwen2_5_VLVideoPixelInputs–Dimensions:
-
Qwen2_5_VisionTransformer–
Qwen2_5_VLForConditionalGeneration
¶
Bases: Module, SupportsMultiModal, Qwen2VLEncoderCudaGraphMixin, SupportsLoRA, SupportsPP, SupportsQuant, SupportsEagle, SupportsEagle3, SupportsMultiModalPruning, SupportsMRoPE
Methods:
-
forward–Run forward pass for Qwen2.5-VL.
-
get_mm_mapping–Get the module prefix in multimodal models.
-
iter_mm_grid_thw–Iterate over multimodal features and yield grid information.
-
recompute_mrope_positions–Update part of input mrope positions (starting with
_postprocess_image_embeds_evs(image_embeds_split, image_input)
¶
_postprocess_video_embeds_evs(video_embeds_split, video_input)
¶
forward(input_ids, positions, intermediate_tensors=None, inputs_embeds=None, **kwargs)
¶
Run forward pass for Qwen2.5-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.5-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.
get_mm_mapping()
¶
Get the module prefix in multimodal models.
iter_mm_grid_thw(mm_features)
¶
recompute_mrope_positions(input_ids, multimodal_embeddings, mrope_positions, num_computed_tokens)
¶
Update part of input mrope positions (starting with num_computed_tokens index). Original mrope_positions are computed for unpruned sequence and becomes incorrect once pruning occurs, so once we prune media tokens we should reflect this in the mrope_positions before we feed it to LLM.
Parameters:
-
(input_ids¶list[int] | Tensor) –(N,) All input tokens of the prompt (Containing entire sequence).
-
(multimodal_embeddings¶Sequence[Tensor]) –Tuple of multimodal embeddings.
-
(mrope_positions¶LongTensor) –Existing mrope positions (3, N) for entire sequence
-
(num_computed_tokens¶int) –A number of computed tokens so far.
Returns:
Qwen2_5_VLImageEmbeddingInputs
¶
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
Qwen2_5_VLImagePixelInputs
¶
Bases: TensorSchema
Dimensions
- np: Number of patches
- 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.
Qwen2_5_VLVideoEmbeddingInputs
¶
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
- second_per_grid_ts: The video time interval (in seconds) for each
grid along the temporal dimension in the 3D position IDs. Returned
when
videosis notNone. - timestamps: List of timestamp values (in seconds) for each frame after merging. Length equals the temporal dimension after merging.
Qwen2_5_VLVideoPixelInputs
¶
Bases: TensorSchema
Dimensions
- np: Number of patches
- nv: Number of videos
- ctps: Number of channels * temporal_patch_size * patch_size * patch_size
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
- second_per_grid_ts: The video time interval (in seconds) for each
grid along the temporal dimension in the 3D position IDs. Returned
when
videosis notNone. - timestamps: List of timestamp values (in seconds) for each frame after merging. Length equals the temporal dimension after merging.
Qwen2_5_VisionTransformer
¶
Bases: Module
Methods:
-
prepare_encoder_metadata–Compute encoder metadata from grid_thw.
prepare_encoder_metadata(grid_thw, *, max_batch_size=None, max_frames_per_batch=None, max_window_seqs_per_batch=None, max_seqlen_override=None, max_seqlen_window_override=None, device=None)
¶
Compute encoder metadata from grid_thw.
Shared by the eager forward path, CUDA graph capture, and CUDA graph replay to avoid duplicated implementation.
Parameters:
-
(grid_thw¶Sequence[Sequence[int]]) –Grid configurations as list of [t, h, w].
-
(max_batch_size¶int | None, default:None) –If set, pad cu_seqlens to this size (needed for CUDA graph capture/replay).
-
(max_frames_per_batch¶int | None, default:None) –If set, overrides max_batch_size for cu_seqlens padding. For video inputs each item contributes T attention sequences (frames); this sizes the buffer to the total frame budget so video replays never overflow.
-
(max_window_seqs_per_batch¶int | None, default:None) –If set, pad cu_window_seqlens to this number of window sequences. This keeps cu_window_seqlens shape stable across capture/replay for CUDA graph safety.
-
(max_seqlen_override¶int | None, default:None) –If set, use this value for max_seqlen instead of computing from cu_seqlens (needed for CUDA graph capture to cover worst-case replay scenarios).
-
(max_seqlen_window_override¶int | None, default:None) –If set, use this value for window-attention max_seqlen instead of computing from cu_window_seqlens (needed for CUDA graph capture to cover worst-case replay scenarios).
-
(device¶device | None, default:None) –Device to place tensors on. Defaults to self.device.