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:
co-authored by
Claude Opus 5
parent
804e5377aa
commit
8c1557a79c
@@ -161,8 +161,7 @@ def _pad_flashinfer_cu_seqlens_buffer(
|
||||
|
||||
|
||||
class Qwen2_5_VLImagePixelInputs(TensorSchema):
|
||||
"""
|
||||
Dimensions:
|
||||
"""Dimensions:
|
||||
- np: Number of patches
|
||||
- ni: Number of images
|
||||
- cps: Number of channels * patch_size * patch_size
|
||||
@@ -188,8 +187,7 @@ class Qwen2_5_VLImagePixelInputs(TensorSchema):
|
||||
|
||||
|
||||
class Qwen2_5_VLImageEmbeddingInputs(TensorSchema):
|
||||
"""
|
||||
Dimensions:
|
||||
"""Dimensions:
|
||||
- nf: Number of image features
|
||||
- hs: Hidden size
|
||||
- ni: Number of images
|
||||
@@ -222,8 +220,7 @@ Qwen2_5_VLImageInputs: TypeAlias = (
|
||||
|
||||
|
||||
class Qwen2_5_VLVideoPixelInputs(TensorSchema):
|
||||
"""
|
||||
Dimensions:
|
||||
"""Dimensions:
|
||||
- np: Number of patches
|
||||
- nv: Number of videos
|
||||
- ctps: Number of channels * temporal_patch_size * patch_size *
|
||||
@@ -262,8 +259,7 @@ class Qwen2_5_VLVideoPixelInputs(TensorSchema):
|
||||
|
||||
|
||||
class Qwen2_5_VLVideoEmbeddingInputs(TensorSchema):
|
||||
"""
|
||||
Dimensions:
|
||||
"""Dimensions:
|
||||
- nf: Number of video features
|
||||
- hs: Hidden size
|
||||
- nv: Number of videos
|
||||
@@ -916,8 +912,8 @@ class Qwen2_5_VisionTransformer(nn.Module):
|
||||
cu_window_seqlens (needed for CUDA graph capture to
|
||||
cover worst-case replay scenarios).
|
||||
device: Device to place tensors on. Defaults to self.device.
|
||||
"""
|
||||
|
||||
"""
|
||||
if device is None:
|
||||
device = self.device
|
||||
metadata: dict[str, torch.Tensor] = {}
|
||||
@@ -1261,14 +1257,14 @@ class Qwen2_5_VLForConditionalGeneration(
|
||||
def iter_mm_grid_thw(
|
||||
self, mm_features: list[MultiModalFeatureSpec]
|
||||
) -> Iterator[tuple[int, int, int, int, float]]:
|
||||
"""
|
||||
Iterate over multimodal features and yield grid information.
|
||||
"""Iterate over multimodal features and yield grid information.
|
||||
|
||||
Args:
|
||||
mm_features: List of multimodal feature specifications
|
||||
|
||||
Yields:
|
||||
Tuple of (offset, grid_t, grid_h, grid_w, t_factor) for each frame/image
|
||||
|
||||
"""
|
||||
spatial_merge_size = self.config.vision_config.spatial_merge_size
|
||||
tokens_per_second = getattr(self.config.vision_config, "tokens_per_second", 1.0)
|
||||
@@ -1462,8 +1458,7 @@ class Qwen2_5_VLForConditionalGeneration(
|
||||
image_embeds_split: tuple[torch.Tensor, ...],
|
||||
image_input: Qwen2_5_VLImageInputs,
|
||||
) -> tuple[torch.Tensor, ...]:
|
||||
"""
|
||||
Append mrope positions for each for images.
|
||||
"""Append mrope positions for each for images.
|
||||
This is necessary to recover correct mrope
|
||||
positions after video pruning
|
||||
|
||||
@@ -1476,6 +1471,7 @@ class Qwen2_5_VLForConditionalGeneration(
|
||||
Tuple of image embeddings for each image item.
|
||||
Resulting embeddings will have extra 4 channels for
|
||||
computed mrope positions.
|
||||
|
||||
"""
|
||||
merge_size = self.visual.spatial_merge_size
|
||||
grid_thw = image_input["image_grid_thw"]
|
||||
@@ -1522,8 +1518,7 @@ class Qwen2_5_VLForConditionalGeneration(
|
||||
video_embeds_split: tuple[torch.Tensor, ...],
|
||||
video_input: Qwen2_5_VLVideoInputs,
|
||||
) -> tuple[torch.Tensor, ...]:
|
||||
"""
|
||||
Prunes video embeddings via Efficient Video Sampling (EVS)
|
||||
"""Prunes video embeddings via Efficient Video Sampling (EVS)
|
||||
and then appends mrope positions for each retained embeddings
|
||||
|
||||
Args:
|
||||
@@ -1534,6 +1529,7 @@ class Qwen2_5_VLForConditionalGeneration(
|
||||
Tuple of video embeddings for each video item.
|
||||
Resulting embeddings will have extra 4 channels for
|
||||
computed mrope positions.
|
||||
|
||||
"""
|
||||
grid_thw = video_input["video_grid_thw"]
|
||||
assert grid_thw.ndim == 2
|
||||
@@ -1584,8 +1580,7 @@ class Qwen2_5_VLForConditionalGeneration(
|
||||
mrope_positions: torch.LongTensor,
|
||||
num_computed_tokens: int,
|
||||
) -> tuple[Sequence[torch.Tensor], torch.Tensor, int]:
|
||||
"""
|
||||
Update part of input mrope positions (starting with
|
||||
"""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
|
||||
@@ -1602,6 +1597,7 @@ class Qwen2_5_VLForConditionalGeneration(
|
||||
Returns:
|
||||
Tuple of (multimodal_embeddings, mrope_positions,
|
||||
mrope_position_delta).
|
||||
|
||||
"""
|
||||
image_token_id = self.config.image_token_id
|
||||
video_token_id = self.config.video_token_id
|
||||
@@ -2018,8 +2014,10 @@ class Qwen2_5_VLForConditionalGeneration(
|
||||
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: Intermediate tensors from prior forward pass.
|
||||
inputs_embeds: Optional tensor of input embeddings.
|
||||
|
||||
"""
|
||||
if intermediate_tensors is not None:
|
||||
inputs_embeds = None
|
||||
|
||||
@@ -2042,9 +2040,7 @@ class Qwen2_5_VLForConditionalGeneration(
|
||||
return loader.load_weights(weights, mapper=self.hf_to_vllm_mapper)
|
||||
|
||||
def get_mm_mapping(self) -> MultiModelKeys:
|
||||
"""
|
||||
Get the module prefix in multimodal models
|
||||
"""
|
||||
"""Get the module prefix in multimodal models."""
|
||||
return MultiModelKeys.from_string_field(
|
||||
language_model="language_model",
|
||||
connector="visual.merger.",
|
||||
|
||||
Reference in New Issue
Block a user