Add pydocstyle to the ruff rules (#52136)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <hej.mellor@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Harry Mellor
2026-09-16 16:44:29 +00:00
committed by GitHub
co-authored by Claude Opus 5
parent 804e5377aa
commit 8c1557a79c
2002 changed files with 15024 additions and 14269 deletions
+18 -11
View File
@@ -1,7 +1,8 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""Implementation of Siglip2VisionModel intended to be only used
within a vision language model."""
within a vision language model.
"""
from collections.abc import Iterable
@@ -61,6 +62,7 @@ class Siglip2VisionEmbeddings(nn.Module):
Returns:
(1, total_tokens, embed_dim) packed embeddings.
"""
assert spatial_shapes.device.type == "cpu", (
"Expected `spatial_shapes` on CPU to avoid device-to-host sync in "
@@ -113,6 +115,7 @@ class Siglip2VisionEmbeddings(nn.Module):
Returns:
(total_tokens, embed_dim) packed positional embeddings, concatenated
in the same order as `lengths_list`.
"""
assert spatial_shapes.device.type == "cpu"
@@ -155,7 +158,7 @@ class Siglip2VisionEmbeddings(nn.Module):
class Siglip2Attention(nn.Module):
"""Multi-headed attention from 'Attention Is All You Need' paper"""
"""Multi-headed attention from 'Attention Is All You Need' paper."""
def __init__(
self,
@@ -304,11 +307,11 @@ class Siglip2EncoderLayer(nn.Module):
cu_seqlens: torch.Tensor,
max_seqlen: int | torch.Tensor,
) -> torch.Tensor:
"""
Args:
hidden_states: Input tensor of shape (batch, seq_len, embed_dim).
cu_seqlens: Cumulative sequence lengths tensor.
max_seqlen: Maximum sequence length.
"""Args:
hidden_states: Input tensor of shape (batch, seq_len, embed_dim).
cu_seqlens: Cumulative sequence lengths tensor.
max_seqlen: Maximum sequence length.
"""
residual = hidden_states
@@ -328,12 +331,12 @@ class Siglip2EncoderLayer(nn.Module):
class Siglip2Encoder(nn.Module):
"""
Transformer encoder consisting of `config.num_hidden_layers`
"""Transformer encoder consisting of `config.num_hidden_layers`
self attention layers. Each layer is a [`Siglip2EncoderLayer`].
Args:
config: PretrainedConfig
"""
def __init__(
@@ -430,8 +433,7 @@ class Siglip2VisionTransformer(nn.Module):
max_seqlen: torch.Tensor,
select_layers: list[int] | None = None,
) -> torch.Tensor:
r"""
spatial_shapes (`torch.LongTensor` of shape `(batch_size, 2)`):
r"""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`):
@@ -500,10 +502,15 @@ class Siglip2Model(torch.nn.Module):
"""Forward pass through the vision model.
Args:
pixel_values_packed: Packed pixel values for all images.
spatial_shapes: Per-image spatial dimensions.
cu_seqlens: Cumulative sequence lengths of the packed images.
max_seqlen: Longest image sequence in the batch.
select_layers: 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.
"""
return self.vision_model(
pixel_values_packed=pixel_values_packed,