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 -10
View File
@@ -31,8 +31,7 @@ def test_v1_generation_is_deterministic_across_batch_sizes_with_needle(
backend,
rms_norm_impl,
):
"""
Ensures that the same request (the 'needle' prompt) yields identical output
"""Ensures that the same request (the 'needle' prompt) yields identical output
whether run alone (bs=1) or mixed into a larger batch (e.g., bs=64),
using the high-level v1 LLM() API only (no manual batching).
@@ -51,6 +50,7 @@ def test_v1_generation_is_deterministic_across_batch_sizes_with_needle(
to produce a more random-sounding phrase, yet remain deterministic by
seed.
- Keep max_tokens and max_model_len bounded for speed and memory use.
"""
seed = int(os.getenv("VLLM_TEST_SEED", "12345"))
random.seed(seed)
@@ -395,8 +395,7 @@ def test_logprobs_bitwise_batch_invariance_bs1_vs_bsN(
BACKENDS,
)
def test_simple_generation(backend):
"""
Simple test that runs the model with a basic prompt and prints the output.
"""Simple test that runs the model with a basic prompt and prints the output.
Useful for quick smoke testing and debugging.
"""
model = TEST_MODEL
@@ -447,8 +446,7 @@ def test_simple_generation(backend):
def test_logprobs_without_batch_invariance_should_fail(
backend, monkeypatch: pytest.MonkeyPatch
):
"""
This test is the inverse of test_logprobs_bitwise_batch_invariance_bs1_vs_bsN.
"""This test is the inverse of test_logprobs_bitwise_batch_invariance_bs1_vs_bsN.
It DISABLES batch invariance mode and expects to see non-deterministic behavior
between BS=1 and BS=N runs. This demonstrates that batch invariance is actually
doing something useful.
@@ -660,8 +658,7 @@ def test_logprobs_without_batch_invariance_should_fail(
def test_decode_logprobs_match_prefill_logprobs(
backend,
):
"""
Test that verifies decode logprobs match prefill logprobs.
"""Test that verifies decode logprobs match prefill logprobs.
For each decoded token at position i:
1. Run decode to generate N tokens and collect their logprobs
@@ -927,8 +924,7 @@ def LLM_with_max_seqs(
attention_config: dict | None = None,
kernel_config: dict | None = None,
) -> LLM:
"""
Helper to construct an LLM with a specific max_num_seqs (batch-size limit)
"""Helper to construct an LLM with a specific max_num_seqs (batch-size limit)
using the high-level v1 LLM API, while constraining memory usage.
"""
extra_kwargs: dict = {}
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""
Test batch-invariant matmul against torch.matmul for various shape combinations.
"""Test batch-invariant matmul against torch.matmul for various shape combinations.
Tests correctness (matches torch.matmul) and batch invariance (result for one
item doesn't change based on other items in the batch).
@@ -53,9 +52,7 @@ DEVICE_TYPE = current_platform.device_type
)
@pytest.mark.parametrize("dtype", [torch.float16, torch.bfloat16])
def test_matmul_correctness(a_shape, b_shape, dtype):
"""
Compare matmul_batch_invariant against torch.matmul for various shapes.
"""
"""Compare matmul_batch_invariant against torch.matmul for various shapes."""
device = torch.device(DEVICE_TYPE)
torch.manual_seed(42)
@@ -87,11 +84,9 @@ def test_matmul_correctness(a_shape, b_shape, dtype):
@skip_unsupported
@pytest.mark.parametrize("dtype", [torch.float16, torch.bfloat16])
def test_matmul_batch_invariance(dtype):
"""
Verify that the result for one item is bitwise identical regardless
"""Verify that the result for one item is bitwise identical regardless
of what other items are in the batch.
"""
device = torch.device(DEVICE_TYPE)
torch.manual_seed(42)
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""
HTTP-based batch invariance test: send requests to a running
"""HTTP-based batch invariance test: send requests to a running
vLLM server and compare BS=1 vs BS=N results (tokens and per-step logprobs).
Environment variables:
@@ -41,8 +41,7 @@ def test_rms_norm_batch_invariant_vs_reference(
eps: float,
seed: int,
):
"""
Compare batch-invariant Triton RMS norm against a PyTorch reference.
"""Compare batch-invariant Triton RMS norm against a PyTorch reference.
Tests that the Triton-based batch-invariant RMS norm produces numerically
equivalent results to an independent implementation across configurations.
@@ -90,9 +89,7 @@ def test_fused_add_rms_norm_batch_invariant_residual_path(
n_extra: int,
seed: int,
):
"""
Test the batch-invariant fused residual-add + RMSNorm helper directly.
"""
"""Test the batch-invariant fused residual-add + RMSNorm helper directly."""
device = torch.device(DEVICE_TYPE)
torch.manual_seed(seed)
@@ -278,7 +275,8 @@ def test_rms_norm_per_block_quant_batch_invariant(
hidden_size: int, dtype: torch.dtype, seed: int
):
"""C++ ``rms_norm_per_block_quant`` must be batch invariant across the
block threshold (compiled fp8 block-quant path; block pinned to 512)."""
block threshold (compiled fp8 block-quant path; block pinned to 512).
"""
import vllm._custom_ops as ops
device = torch.device(DEVICE_TYPE)
@@ -313,8 +311,7 @@ def test_rms_norm_per_block_quant_batch_invariant(
def test_rms_norm_3d_input(
default_vllm_config, batch_size: int, seq_len: int, hidden_size: int
):
"""
Test RMS norm with 3D input tensors (batch, seq_len, hidden_size).
"""Test RMS norm with 3D input tensors (batch, seq_len, hidden_size).
Ensures that the batch-invariant RMS norm correctly handles multi-dimensional
inputs that are common in transformer models.
@@ -349,8 +346,7 @@ def test_rms_norm_3d_input(
@skip_if_not_cuda
def test_rms_norm_numerical_stability(default_vllm_config):
"""
Test RMS norm numerical stability with extreme values.
"""Test RMS norm numerical stability with extreme values.
Ensures that both implementations handle edge cases like very small or large
values without producing NaN or Inf.
@@ -406,8 +402,7 @@ def test_rms_norm_numerical_stability(default_vllm_config):
@skip_unsupported
def test_rms_norm_formula(default_vllm_config):
"""
Test that RMS norm follows the correct mathematical formula.
"""Test that RMS norm follows the correct mathematical formula.
Verifies: output = input / sqrt(mean(input^2) + eps) * weight
"""
@@ -440,8 +435,7 @@ def test_rms_norm_formula(default_vllm_config):
@skip_if_not_cuda
@pytest.mark.parametrize("hidden_size", [128, 1024, 4096, 16384])
def test_rms_norm_different_hidden_sizes(default_vllm_config, hidden_size: int):
"""
Test RMS norm with various hidden sizes to ensure block size handling.
"""Test RMS norm with various hidden sizes to ensure block size handling.
The Triton kernel uses a fixed BLOCK_SIZE=1024, so this tests that it
correctly handles hidden sizes both smaller and larger than the block size.
@@ -474,8 +468,7 @@ def test_rms_norm_different_hidden_sizes(default_vllm_config, hidden_size: int):
@skip_unsupported
def test_rms_norm_determinism(default_vllm_config):
"""
Test that batch-invariant RMS norm produces deterministic results.
"""Test that batch-invariant RMS norm produces deterministic results.
Runs the same input through the kernel multiple times and verifies
identical outputs.