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
+21 -12
View File
@@ -133,8 +133,7 @@ class CorrectAttnCPOutKernel(VllmTritonJitKernel["CorrectAttnCPOutKernel.Compile
N_ROUNDED: tl.constexpr,
IS_BASE_E: tl.constexpr,
):
"""
Apply the all-gathered lses to correct each local rank's attention
"""Apply the all-gathered lses to correct each local rank's attention
output. we still need perform a cross-rank reduction to obtain the
final attention output.
@@ -147,6 +146,17 @@ class CorrectAttnCPOutKernel(VllmTritonJitKernel["CorrectAttnCPOutKernel.Compile
Pointer to output tensor of shape [ B, H, D ]
vlse_ptr (triton.PointerType):
Pointer to output tensor of shape [ B, H ]
outputs_stride_B (int): Batch stride of ``outputs_ptr``
outputs_stride_H (int): Head stride of ``outputs_ptr``
outputs_stride_D (int): Head-dim stride of ``outputs_ptr``
lses_stride_N (int): Rank stride of ``lses_ptr``
lses_stride_B (int): Batch stride of ``lses_ptr``
lses_stride_H (int): Head stride of ``lses_ptr``
lse_idx (int): Index of this rank's lse within the all-gathered tensor
HEAD_DIM: Head dimension, as a constexpr
N_ROUNDED: Rank count rounded to a power of two, as a constexpr
IS_BASE_E: Whether the lses are natural-log based, as a constexpr
"""
batch_idx = tl.program_id(axis=0).to(tl.int64)
head_idx = tl.program_id(axis=1).to(tl.int64)
@@ -376,9 +386,11 @@ def correct_attn_out(
lses: Tensor of shape [ N, B, H ]
cp_rank: Current rank in the context-parallel group
ctx: Triton context to avoid recompilation
is_lse_base_on_e: Whether the lses use base e rather than base 2
Returns:
Tuple of (out, lse) with corrected attention and final log-sum-exp.
"""
if ctx is None:
ctx = CPTritonContext()
@@ -431,8 +443,7 @@ def _cp_lse_common(
seq_lens: torch.Tensor | None = None,
query_start_loc: torch.Tensor | None = None,
):
"""
cp_attn_out: [ B, H, D ]
"""cp_attn_out: [ B, H, D ]
cp_attn_lse: [ B, H ]
"""
if cp_group.world_size == 1:
@@ -466,8 +477,7 @@ def cp_lse_ag_out_rs(
seq_lens: torch.Tensor | None = None,
query_start_loc: torch.Tensor | None = None,
):
"""
cp_attn_out: [ B, H, D ]
"""cp_attn_out: [ B, H, D ]
cp_attn_lse: [ B, H ]
"""
out, lse = _cp_lse_common(
@@ -499,8 +509,7 @@ def cp_lse_ag_out_ar(
seq_lens: torch.Tensor | None = None,
query_start_loc: torch.Tensor | None = None,
):
"""
cp_attn_out: [ B, H, D ]
"""cp_attn_out: [ B, H, D ]
cp_attn_lse: [ B, H ]
"""
out, lse = _cp_lse_common(
@@ -528,8 +537,7 @@ def _lse_weighted_combine(
return_lse: bool = False,
is_lse_base_on_e: bool = True,
) -> torch.Tensor | tuple[torch.Tensor, torch.Tensor]:
"""
CPU reference implementation for LSE-weighted combination.
"""CPU reference implementation for LSE-weighted combination.
This is a pure PyTorch implementation used for testing and validation.
@@ -545,6 +553,7 @@ def _lse_weighted_combine(
Returns:
Combined output [B, H, D], and optionally global LSE [B, H]
"""
N, B, H, D = outputs.shape
@@ -936,8 +945,7 @@ def dcp_a2a_lse_reduce(
seq_lens: torch.Tensor | None = None,
query_start_loc: torch.Tensor | None = None,
) -> torch.Tensor | tuple[torch.Tensor, torch.Tensor]:
"""
Combine partial attention outputs across DCP ranks using All-to-All.
"""Combine partial attention outputs across DCP ranks using All-to-All.
The output and LSE are packed into a single output-dtype buffer, sent
with one All-to-All, then unpacked and combined with exact LSE weighting.
@@ -955,6 +963,7 @@ def dcp_a2a_lse_reduce(
Returns:
Combined output [B, H/N, D] (head-scattered)
If return_lse=True, also returns global_lse [B, H/N]
"""
world_size = cp_group.world_size