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
+19 -26
View File
@@ -645,7 +645,8 @@ def test_mamba_groups_support_mixed_specs_in_uniform_group():
def _make_staging_ctx(max_num_reqs: int, device: torch.device) -> MagicMock:
"""Build a MambaSpecDecodeGPUContext stand-in exposing only the four
per-request staging buffers touched by stage_postprocess_inputs_to_gpu."""
per-request staging buffers touched by stage_postprocess_inputs_to_gpu.
"""
ctx = MagicMock()
ctx.mamba_state_idx_buf = _MockCpuGpuBuffer(max_num_reqs, torch.int32, device)
ctx.num_scheduled_tokens_buf = _MockCpuGpuBuffer(max_num_reqs, torch.int32, device)
@@ -657,7 +658,8 @@ def _make_staging_ctx(max_num_reqs: int, device: torch.device) -> MagicMock:
def test_stage_postprocess_inputs_to_gpu_fills_pinned_views():
"""stage_postprocess_inputs_to_gpu writes each request's state_idx and
scheduled/computed/draft counts into slot `i` for `req_ids[i]`, leaves
slots past `num_reqs` untouched, and mirrors the values to the GPU buffers."""
slots past `num_reqs` untouched, and mirrors the values to the GPU buffers.
"""
device = torch.device("cpu")
max_num_reqs = 8
ctx = _make_staging_ctx(max_num_reqs, device)
@@ -729,7 +731,8 @@ def test_stage_postprocess_inputs_to_gpu_fills_pinned_views():
def test_stage_postprocess_inputs_to_gpu_asserts_on_missing_state_idx():
"""If preprocess_mamba didn't populate mamba_state_idx for a req in the
batch, staging must fail loudly rather than silently writing a stale index."""
batch, staging must fail loudly rather than silently writing a stale index.
"""
device = torch.device("cpu")
ctx = _make_staging_ctx(max_num_reqs=4, device=device)
scheduler_output = _make_postprocess_scheduler_output(
@@ -807,7 +810,8 @@ def _run_gpu_postprocess(
device: torch.device,
) -> None:
"""Initialize the GPU context against `block_table`, run the fused
postprocess kernel for `req_ids`, and synchronize."""
postprocess kernel for `req_ids`, and synchronize.
"""
def t(values):
return torch.tensor(values, dtype=torch.int32, device=device)
@@ -867,8 +871,7 @@ class TestPostprocessMambaFusedKernel:
torch.testing.assert_close(state, expected, rtol=0, atol=0)
def test_matches_python_postprocess_mamba(self, device, test_config):
"""
Golden test: GPU kernel produces identical results to Python impl.
"""Golden test: GPU kernel produces identical results to Python impl.
This test:
1. Sets up identical initial state for both paths
@@ -1146,8 +1149,7 @@ class TestPostprocessMambaFusedKernel:
)
def test_block_table_with_realistic_stride(self, device, test_config):
"""
Test kernel with realistic block table strides.
"""Test kernel with realistic block table strides.
In real usage, the block table is pre-allocated with shape
[max_num_reqs, max_num_blocks_per_req] and then sliced to
@@ -1275,8 +1277,7 @@ class TestPostprocessMambaFusedKernel:
def test_src_addr_equals_dst_addr_skips_copy_and_sets_accepted_to_1(
self, device, test_config
):
"""
Test the ``src_addr == dst_addr`` early-return path in
"""Test the ``src_addr == dst_addr`` early-return path in
postprocess_mamba_fused_kernel matches Python behavior.
When src_addr == dst_addr (source and destination memory addresses are
@@ -1419,8 +1420,7 @@ class TestPostprocessMambaFusedKernel:
def test_same_block_idx_with_offset_copies_then_sets_accepted_to_1(
self, device, test_config
):
"""
Test the ``src_block_idx == dest_block_idx`` post-copy update in
"""Test the ``src_block_idx == dest_block_idx`` post-copy update in
postprocess_mamba_fused_kernel matches Python behavior.
When src_block_idx == dest_block_idx but accept_token_bias > 0, both
@@ -1583,8 +1583,7 @@ class TestPostprocessMambaFusedKernel:
def test_different_block_idx_copies_without_setting_accepted_to_1(
self, device, test_config
):
"""
Test that neither special-case path triggers when
"""Test that neither special-case path triggers when
src_block_idx != dest_block_idx, and GPU matches Python behavior.
When copying between different blocks:
@@ -1716,8 +1715,7 @@ class TestPostprocessMambaFusedKernel:
def test_prefix_caching_shared_block_does_not_set_accepted_to_1(
self, device, test_config
):
"""
Regression test: with prefix caching, different logical block indices
"""Regression test: with prefix caching, different logical block indices
can map to the same physical block. The kernel must NOT set
num_accepted_tokens to 1 in that case.
@@ -1849,8 +1847,7 @@ class TestPostprocessMambaFusedKernel:
)
def test_prefix_caching_nonsequential_block_ids_boundary(self, device, test_config):
"""
Regression test: non-sequential physical block IDs under prefix caching
"""Regression test: non-sequential physical block IDs under prefix caching
with the needs_copy boundary at exact equality.
Under PC, the block allocator assigns physical block IDs in arbitrary
@@ -2000,8 +1997,7 @@ class TestPostprocessMambaFusedKernel:
assert input_batch_py.num_accepted_tokens_cpu[1] == num_accepted_tokens[1]
def test_prefix_caching_mixed_shared_and_distinct_blocks(self, device, test_config):
"""
Regression test: mixed batch under prefix caching where some requests
"""Regression test: mixed batch under prefix caching where some requests
have shared physical blocks (aliased) and others have distinct blocks,
with the needs_copy boundary at various positions.
@@ -2166,8 +2162,7 @@ class TestPostprocessMambaFusedKernel:
def test_pc_aliased_blocks_skip_must_use_logical_idx_not_addr(
self, device, test_config
):
"""
Regression test for 6466ce0d vs 959ca0fd: the kernel's early-return
"""Regression test for 6466ce0d vs 959ca0fd: the kernel's early-return
guard must compare logical block indices, not physical addresses.
Under prefix caching, different logical blocks (src_block_idx=0,
@@ -2299,8 +2294,7 @@ class TestPostprocessMambaFusedKernel:
)
def test_as_strided_temporal_copy_size(self, device, test_config):
"""
Regression test for 240723d46: temporal copy_size must be
"""Regression test for 240723d46: temporal copy_size must be
inner_size * elem_size, not state_block_stride.
In production (gpu_model_runner.py), conv and temporal states share
@@ -2458,8 +2452,7 @@ class TestPostprocessMambaFusedKernel:
)
def test_temporal_copy_with_bias_ge_2(self, device, test_config):
"""
Coverage test for the temporal-state block-table stride arithmetic
"""Coverage test for the temporal-state block-table stride arithmetic
when ``accept_token_bias >= 2``.
The kernel computes, for temporal (non-conv) states::