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
@@ -11,7 +11,8 @@ from ...utils import compute_acceptance_len, get_test_prompts
@single_gpu_only
def test_synthetic_acceptance_rate(vllm_runner):
"""Verify that synthetic rejection sampling produces an acceptance
length close to the requested mean acceptance length."""
length close to the requested mean acceptance length.
"""
num_spec_tokens = 3
expected_acceptance_len = 1.875
tolerance = 0.15
@@ -43,8 +43,7 @@ def run_acceptance_length_eval(
chat_template_kwargs: dict[str, Any],
use_mrv2: bool,
):
"""
E2E acceptance-rate validation for speculative decoding.
"""E2E acceptance-rate validation for speculative decoding.
Drives one or more datasets (keyed in ``expected_acceptance_lengths``)
through the spec decode engine and asserts the mean acceptance length
@@ -167,7 +167,8 @@ def test_draft_model_tensor_parallelism(vllm_runner):
@multi_gpu_only(num_gpus=2)
def test_draft_model_engine_args_tensor_parallelism():
"""Ensure the vllm_config for the draft model is created correctly,
and independently of the target model (quantization, TP, etc.)"""
and independently of the target model (quantization, TP, etc.)
"""
engine_args = EngineArgs(
model="Qwen/Qwen3-1.7B-FP8", # <<< tgt quantized
tensor_parallel_size=2,
@@ -198,7 +199,8 @@ def test_draft_model_engine_args_tensor_parallelism():
def _apply_draft_moe_backend(vllm_config: VllmConfig) -> VllmConfig:
"""Replicate SpecDecodeBaseProposer._create_draft_vllm_config logic
so we can test it without instantiating a full proposer."""
so we can test it without instantiating a full proposer.
"""
spec_cfg = vllm_config.speculative_config
if spec_cfg.moe_backend is not None:
return replace(
@@ -223,7 +225,8 @@ def _platform_moe_backend(monkeypatch: pytest.MonkeyPatch) -> MoEBackend:
def test_draft_model_moe_backend_override(monkeypatch: pytest.MonkeyPatch):
"""When moe_backend is set in speculative_config, the draft VllmConfig
should use it while the target keeps its own setting."""
should use it while the target keeps its own setting.
"""
target_moe_backend = _platform_moe_backend(monkeypatch)
engine_args = EngineArgs(
model="Qwen/Qwen3-1.7B",
@@ -248,7 +251,8 @@ def test_draft_model_moe_backend_override(monkeypatch: pytest.MonkeyPatch):
def test_draft_model_moe_backend_inherits_target(monkeypatch: pytest.MonkeyPatch):
"""When moe_backend is not set in speculative_config, the draft should
inherit the target's moe_backend."""
inherit the target's moe_backend.
"""
target_moe_backend = _platform_moe_backend(monkeypatch)
engine_args = EngineArgs(
model="Qwen/Qwen3-1.7B",
@@ -271,7 +275,8 @@ def test_draft_model_moe_backend_inherits_target(monkeypatch: pytest.MonkeyPatch
def test_draft_model_moe_backend_default_auto():
"""When neither target nor draft set moe_backend explicitly, both should
default to 'auto'."""
default to 'auto'.
"""
engine_args = EngineArgs(
model="Qwen/Qwen3-1.7B",
tensor_parallel_size=1,
@@ -292,8 +297,8 @@ def test_draft_model_moe_backend_default_auto():
def test_draft_model_engine_args_rejects_invalid_tp_argname():
"""The user should pass "draft_tensor_parallel_size" rather than
"tensor_parallel_size". We enforce this with validation."""
"tensor_parallel_size". We enforce this with validation.
"""
engine_args = EngineArgs(
model="Qwen/Qwen3-1.7B",
tensor_parallel_size=1,
@@ -310,7 +315,8 @@ def test_draft_model_engine_args_rejects_invalid_tp_argname():
def assert_draft_model_correctness(args: ArgsTest, vllm_runner):
"""Compare the outputs using and not using speculative decoding.
In the greedy decoding case, the outputs must match EXACTLY."""
In the greedy decoding case, the outputs must match EXACTLY.
"""
test_prompts: list[Messages] = get_messages(
dataset=args.dataset, n=args.num_prompts
)
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""
This script contains:
"""This script contains:
1. test lora with speculative decoding for batch inference
"""
@@ -59,8 +58,7 @@ def test_batch_inference_correctness(
model_setup: tuple[str, str, str, str, int],
vllm_runner,
):
"""
Compare the outputs of a LLM with only Lora and a LLM with both SD and Lora.
"""Compare the outputs of a LLM with only Lora and a LLM with both SD and Lora.
Should be the same and no failure when doing batch inference.
model_setup: (method, model_name, spec_model_name, lora_path, tp_size)
"""
+1 -2
View File
@@ -28,8 +28,7 @@ def _run_eagle_correctness(
attn_backend: str,
vllm_runner,
):
"""
Compare the outputs of an original LLM and a speculative LLM
"""Compare the outputs of an original LLM and a speculative LLM
which should be the same when using eagle speculative decoding.
"""
method, model_name, spec_model_name, tp_size = model_setup
+1 -2
View File
@@ -157,8 +157,7 @@ def test_mtp_correctness(
expected_accuracy_threshold: float,
vllm_runner,
):
"""
Compare the outputs of a original LLM and a speculative LLM
"""Compare the outputs of a original LLM and a speculative LLM
which should be the same when using MTP speculative decoding. Due to some variance
in the engine, it is possible for some outputs to differ, so we expect that at least
6/10 output tokens match exactly, and that the GSM8k accuracy is above a precomputed
@@ -64,8 +64,7 @@ def test_ngram_gpu_default_with_async_scheduling(
async_scheduling: bool,
vllm_runner,
):
"""
Test ngram_gpu speculative decoding (k=3) correctness with and without
"""Test ngram_gpu speculative decoding (k=3) correctness with and without
async scheduling, validated via GSM8K accuracy.
Uses Qwen/Qwen3-8B (ref GSM8K accuracy: 87%-92%).
"""
@@ -99,8 +98,7 @@ def test_suffix_decoding_acceptance(
model_name: str,
vllm_runner,
):
"""
Check that suffix decoding caching takes effect and improves acceptance
"""Check that suffix decoding caching takes effect and improves acceptance
lengths and acceptance rates over multiple runs of the same prompts.
"""
test_prompts = get_test_prompts(mm_enabled=False)
@@ -32,8 +32,7 @@ def test_speculators_model_integration(
expected_accuracy_threshold: float,
vllm_runner,
):
"""
Test that speculators models work with the simplified integration.
"""Test that speculators models work with the simplified integration.
This verifies the `vllm serve <speculator-model>` use case where
speculative config is automatically detected from the model config
@@ -28,7 +28,8 @@ def test_mtp_sharded_sampling_equivalence(monkeypatch: pytest.MonkeyPatch):
sampling under MTP spec decoding: the collectives move the same logits
bytes, Gumbel keys derive from (request slot, position, seed), and slot
assignment is rank-deterministic. Both runs here are spec decode with
identical math, so outputs must match exactly."""
identical math, so outputs must match exactly.
"""
tp_size = 2
_skip_if_insufficient_gpus_for_tp(tp_size)
model_name = "Qwen/Qwen3.5-0.8B-Base"