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
+13 -1
View File
@@ -98,7 +98,8 @@ def _kpool_softmax_rotate_write_cache_kernel(
BLOCK_D: tl.constexpr,
):
"""One program per pool. softmax(slot_score+ape)-weighted sum of slot_k ->
Hadamard-128 -> per-vector fp8 absmax quant -> write to cache at ``loc``."""
Hadamard-128 -> per-vector fp8 absmax quant -> write to cache at ``loc``.
"""
row = tl.program_id(0)
do_write = True
if HAS_WRITE_MASK:
@@ -212,6 +213,13 @@ def kpool_compress_and_write_cache(
slot_score: ``[n_pools, pool_size, head_dim]`` — per-token gate score.
ape: ``[pool_size, head_dim]`` fp32 — per-slot position bias.
loc: ``[n_pools]`` int64 — flat physical slot per pool.
pool_size: Number of tokens compressed into one cache entry.
head_dim: Indexer head dimension.
write_mask: ``[n_pools]`` bool — pools to write, or None for all.
round_scale: Round each fp8 scale down to a power of two.
return_compressed: Also return the compressed K and scales.
write_cache: Write the compressed result into ``kv_cache``.
"""
assert slot_k.ndim == 3
assert slot_score.shape == slot_k.shape
@@ -592,6 +600,10 @@ def kpool_decode_update_and_maybe_write_cache_batched(
ape: ``[pool_size, head_dim]`` fp32.
slot_mapping: ``[num_requests, next_n]`` int32.
positions: ``[num_requests, next_n]`` int32.
pool_size: Number of tokens compressed into one cache entry.
head_dim: Indexer head dimension.
round_scale: Round each fp8 scale down to a power of two.
"""
num_requests, next_n = key.shape[0], key.shape[1]
if num_requests == 0 or next_n == 0:
@@ -564,8 +564,7 @@ def fused_recurrent_gated_delta_rule(
num_accepted_tokens: torch.Tensor | None = None,
use_qk_l2norm_in_kernel: bool = False,
) -> tuple[torch.Tensor, torch.Tensor]:
r"""
Args:
r"""Args:
q (torch.Tensor):
queries of shape `[B, T, H, K]`.
k (torch.Tensor):
@@ -627,6 +626,7 @@ def fused_recurrent_gated_delta_rule(
initial_state=h0,
cu_seqlens=cu_seqlens
)
"""
if cu_seqlens is not None and q.shape[0] != 1:
raise ValueError(
+17 -12
View File
@@ -406,19 +406,24 @@ def chunk_kda_scaled_dot_kkt_fwd(
chunk_size: int = FLA_CHUNK_SIZE,
output_dtype: torch.dtype = torch.float32,
) -> tuple[torch.Tensor, torch.Tensor]:
r"""
Compute beta * K * K^T.
r"""Compute beta * K * K^T.
Args:
q (torch.Tensor):
The query tensor of shape `[B, T, H, K]`.
k (torch.Tensor):
The key tensor of shape `[B, T, H, K]`.
beta (torch.Tensor):
The beta tensor of shape `[B, T, H]`.
gk (torch.Tensor):
The cumulative sum of the gate tensor of shape `[B, T, H, K]` applied to the key tensor. Default: `None`.
scale (float):
Scale applied to the query-key products. Default: `None`.
cu_seqlens (torch.Tensor):
The cumulative sequence lengths of the input tensor.
Default: None
chunk_indices (torch.Tensor):
Precomputed chunk indices for `cu_seqlens`. Default: `None`.
chunk_size (int):
The chunk size. Default: 64.
output_dtype (torch.dtype):
@@ -426,6 +431,7 @@ def chunk_kda_scaled_dot_kkt_fwd(
Returns:
beta * K * K^T of shape `[B, T, H, BT]` where `BT` is the chunk size.
"""
B, T, H, K = k.shape
assert K <= 256
@@ -1318,16 +1324,15 @@ def fused_kda_gate(
safe_gate: bool = False,
lower_bound: float | None = -5.0,
) -> torch.Tensor:
"""
Forward pass for KDA gate:
input g: [..., H*D]
param A: [H] or [1, 1, H, 1]
beta: softplus beta parameter (softplus branch only)
threshold: softplus threshold parameter (softplus branch only)
safe_gate: when False (default) compute y = -exp(A)*softplus(g+g_bias);
when True compute the bounded y = lower_bound*sigmoid(exp(A)*(g+g_bias))
lower_bound: floor for the safe_gate branch (default -5.0)
return : [..., H, D]
"""Forward pass for KDA gate:
input g: [..., H*D]
param A: [H] or [1, 1, H, 1]
beta: softplus beta parameter (softplus branch only)
threshold: softplus threshold parameter (softplus branch only)
safe_gate: when False (default) compute y = -exp(A)*softplus(g+g_bias);
when True compute the bounded y = lower_bound*sigmoid(exp(A)*(g+g_bias))
lower_bound: floor for the safe_gate branch (default -5.0)
return : [..., H, D]
"""
orig_shape = g.shape[:-1]