vllm.model_executor.models.lfm2_siglip2
¶
Implementation of Siglip2VisionModel intended to be only used within a vision language model.
Classes:
-
Siglip2Attention–Multi-headed attention from 'Attention Is All You Need' paper.
-
Siglip2Encoder–Transformer encoder consisting of
config.num_hidden_layers -
Siglip2EncoderLayer– -
Siglip2Model– -
Siglip2VisionEmbeddings– -
Siglip2VisionTransformer–
Siglip2Encoder
¶
Siglip2EncoderLayer
¶
Siglip2Model
¶
Bases: Module
Methods:
-
forward–Forward pass through the vision model.
forward(pixel_values_packed, spatial_shapes, cu_seqlens, max_seqlen, select_layers=None)
¶
Forward pass through the vision model.
Parameters:
-
(pixel_values_packed¶FloatTensor) –Packed pixel values for all images.
-
(spatial_shapes¶LongTensor) –Per-image spatial dimensions.
-
(cu_seqlens¶Tensor) –Cumulative sequence lengths of the packed images.
-
(max_seqlen¶Tensor) –Longest image sequence in the batch.
-
(select_layers¶list[int] | None, default:None) –Layer indices to select hidden states from. Supports negative indices (e.g., [-2] for second-to-last). If None, returns the last layer output with post_layernorm. Multiple layers can be selected and will be concatenated.
Siglip2VisionEmbeddings
¶
Bases: Module
Methods:
-
forward–Embed patchified pixel values in packed (unpadded) form.
-
resize_positional_embeddings_packed–Resize positional embeddings per image and return a packed tensor.
forward(pixel_values_packed, spatial_shapes)
¶
Embed patchified pixel values in packed (unpadded) form.
Parameters:
-
(pixel_values_packed¶FloatTensor) –(1, total_tokens, patch_dim) or (total_tokens, patch_dim), packed in tile order.
-
(spatial_shapes¶LongTensor) –(num_tiles, 2) on CPU (height, width) per tile.
Returns:
-
Tensor–(1, total_tokens, embed_dim) packed embeddings.
resize_positional_embeddings_packed(positional_embeddings, spatial_shapes, lengths_list)
staticmethod
¶
Resize positional embeddings per image and return a packed tensor.
Parameters:
-
(positional_embeddings¶Tensor) –(height, width, embed_dim) base grid.
-
(spatial_shapes¶LongTensor) –(batch_size, 2) on CPU, (height, width) per image.
-
(lengths_list¶list[int]) –flattened token length per image (height * width).
Returns:
Siglip2VisionTransformer
¶
Bases: Module
Methods:
-
forward–spatial_shapes (
torch.LongTensorof shape(batch_size, 2)):
forward(pixel_values_packed, spatial_shapes, cu_seqlens, max_seqlen, select_layers=None)
¶
spatial_shapes (torch.LongTensor of shape (batch_size, 2)):
Tensor containing the spatial dimensions (height, width)
of the input images.
select_layers (list[int] or None, defaults to None):
Layer indices to select hidden states from. Supports negative
indices (e.g., -1 for last layer, -2 for second-to-last).
If None, returns the last layer output.