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
+6 -3
View File
@@ -564,7 +564,8 @@ def _engram_head_shard_weight_loader(
param: torch.nn.Parameter, loaded_weight: torch.Tensor
) -> None:
"""Load this rank's complete head buckets. ue8m0 scales arrive as
float8_e8m0fnu; keep the raw bytes (the param stores uint8)."""
float8_e8m0fnu; keep the raw bytes (the param stores uint8).
"""
part_rows = param.shape[0]
if loaded_weight.dtype == torch.float8_e8m0fnu:
loaded_weight = loaded_weight.view(torch.uint8)
@@ -739,7 +740,8 @@ class ParallelEngramEmbedding(nn.Module):
def forward(self, indices: torch.Tensor) -> torch.Tensor:
"""indices: [num_tokens, n_hash_cols] -> [num_tokens, n_hash_cols, dim]
bf16, gathered from all shards for this replica's tokens."""
bf16, gathered from all shards for this replica's tokens.
"""
out = torch.empty(
(indices.shape[0], self.part_n_hash_cols, self.dim),
dtype=torch.bfloat16,
@@ -1000,7 +1002,8 @@ class Engram(nn.Module):
) -> torch.Tensor:
"""hidden_states: [T, hc_mult, dim]; hash_ids: [T, n_hash_cols] (all
tokens, pre sequence-parallel shard); token_mask: [T], False shuts
the gate so those positions pass through untouched."""
the gate so those positions pass through untouched.
"""
kv = self.wkv(self.embed(hash_ids).flatten(-2))
num_kv_tokens = hash_ids.shape[0]
assert token_mask is None or token_mask.shape == (num_kv_tokens,)
@@ -82,7 +82,8 @@ def num_image_tokens(n_llm_h: int, n_llm_w: int) -> int:
def solve_resize_ratio(height, width, patch_size, downsample_ratio, max_n_token):
"""Largest aspect-preserving pixel size whose token grid still fits in
max_n_token. Returns (best_height, best_width)."""
max_n_token. Returns (best_height, best_width).
"""
r = height / width
max_w_float = math.sqrt((max_n_token - 2) / r + 0.25) - 0.5
max_h_float = max_w_float * r
@@ -105,7 +106,8 @@ def safe_resize(
height, width, best_height, best_width, patch_size, downsample_ratio, max_n_token
):
"""Shrink the pixel size until the image costs at most max_n_token LLM
tokens."""
tokens.
"""
n_llm_h, n_llm_w = llm_grid(best_height, best_width, patch_size, downsample_ratio)
if num_image_tokens(n_llm_h, n_llm_w) > max_n_token:
best_height, best_width = solve_resize_ratio(
@@ -171,7 +173,8 @@ def image_token_types(n_llm_h: int, n_llm_w: int) -> torch.Tensor:
class DeepseekV4VLImageProcessor:
"""Per-image transform (the PIL-input equivalent of the reference
``load_image``)."""
``load_image``).
"""
def __init__(self, config: DeepseekV41Config) -> None:
super().__init__()
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""
Triton kernels for DeepseekV4 paged K-cache management and sparse-attention index
"""Triton kernels for DeepseekV4 paged K-cache management and sparse-attention index
preparation.
- quantize_and_insert_k_cache: quantize bf16 K to UE8M0 FP8 and insert into
@@ -76,8 +75,7 @@ def quantize_and_insert_k_kernel(
n_quant_blocks: tl.constexpr, # 8 (7 real + 1 padding)
use_fnuz: tl.constexpr = False,
):
"""
Quantize K tensor and insert into paged K cache.
"""Quantize K tensor and insert into paged K cache.
K Cache block layout (block_size=64 tokens):
- [0, 64*576): Token data, each token has 448 fp8 + 128 bf16
@@ -251,8 +249,7 @@ def quantize_and_insert_k_cache(
use_fnuz: bool = False,
bytes_per_token: int = V4_BYTES_PER_TOKEN,
):
"""
Quantize K tensor and insert into paged K cache.
"""Quantize K tensor and insert into paged K cache.
``bytes_per_token`` picks the record (see the module header): the V4 one,
or V4.1's all-dims MXFP8 one.
@@ -58,6 +58,7 @@ def fused_save_compress_norm(
rms_norm_eps: RMSNorm epsilon.
compress_ratio: Group size, either 1 or 2.
latent_out: BF16 [tokens, 512], written only at valid group boundaries.
"""
assert compress_ratio in (1, 2)
assert kv_score.dtype == torch.float32
@@ -46,11 +46,13 @@ def indexer_k_norm_rope_store(
cos_sin_cache: [max_pos, rope_head_dim] GPT-J layout (cos half, then
sin half), from the layer's compress-RoPE instance.
rms_norm_weight: [128] k_norm weight.
rms_norm_eps: Epsilon of the k_norm RMSNorm.
k_cache: uint8 paged indexer cache [num_blocks, block_size, row_bytes].
kv_slot_mapping: [num_tokens] slots in the indexer cache (-1 = skip).
compress_ratio: group size; keys are emitted at group boundaries.
use_fp4_cache: MXFP4 (2 nibbles/byte + ue8m0 per 32) when True, else
per-token FP8 with a single fp32 scale.
"""
num_tokens = kv_slot_mapping.numel()
assert k_pre.ndim == 2 and k_pre.shape[1] == 128