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
+10 -5
View File
@@ -382,7 +382,8 @@ def test_inc_get_quant_method_unquantized_layer_with_model_prefix(
layer_factory,
) -> None:
"""``model.``-prefixed extra_config entries trigger early exit for both
LinearBase and ParallelLMHead layers."""
LinearBase and ParallelLMHead layers.
"""
config = make_config(extra_config={"model.layer": {"bits": 16}})
layer = layer_factory()
@@ -395,7 +396,8 @@ def test_inc_get_quant_method_unquantized_routed_experts_with_model_prefix(
monkeypatch,
) -> None:
"""``model.``-prefixed extra_config entries trigger early exit for
RoutedExperts layers, returning UnquantizedFusedMoEMethod."""
RoutedExperts layers, returning UnquantizedFusedMoEMethod.
"""
class DummyUnquantizedFusedMoEMethod:
def __init__(self, moe_config) -> None:
@@ -418,7 +420,8 @@ def test_inc_get_quant_method_unquantized_routed_experts_with_model_prefix(
def test_inc_get_quant_method_unknown_layer_with_model_prefix_returns_none() -> None:
"""``model.``-prefixed extra_config entries return None for unhandled
layer types (non-Linear, non-MoE)."""
layer types (non-Linear, non-MoE).
"""
config = make_config(extra_config={"model.unknown": {"bits": 16}})
method = config.get_quant_method(DummyLayer(), "unknown")
@@ -733,7 +736,8 @@ def test_wna16_cuda_low_bit_moe_routes_to_humming(monkeypatch, bits) -> None:
@pytest.mark.parametrize("bits", [4, 8])
def test_wna16_cuda_high_bit_skips_humming(monkeypatch, bits) -> None:
"""4/8-bit int stays on the Marlin/GPTQ/AWQ path even on CUDA so a single
model can mix high-bit Marlin and low-bit humming layers."""
model can mix high-bit Marlin and low-bit humming layers.
"""
called = {"humming": False}
monkeypatch.setattr(current_platform, "is_cuda", lambda: True)
@@ -1664,7 +1668,8 @@ def test_inc_get_quant_method_unquantized_moe_returns_unquantized(
monkeypatch,
) -> None:
"""Early-exit returns UnquantizedFusedMoEMethod for FusedMoE layers
when extra_config has bits >= 16."""
when extra_config has bits >= 16.
"""
config = make_config(extra_config={"layer": {"bits": 16}})
layer = object.__new__(RoutedExperts)
layer.moe_config = None # UnquantizedFusedMoEMethod accepts moe_config
@@ -574,8 +574,7 @@ def test_compressed_tensors_fp8_block_enabled(
reason="This test is not for non-CUDA platforms",
)
def test_compressed_tensors_moe_ignore_with_model(vllm_runner):
"""
Integration test for MoE layer ignore functionality with a real model.
"""Integration test for MoE layer ignore functionality with a real model.
This test would verify that when loading a compressed-tensors quantized
MoE model where some MoE layers are in the ignore list, those layers
@@ -587,7 +586,6 @@ def test_compressed_tensors_moe_ignore_with_model(vllm_runner):
- Config with ignore list containing specific MoE layers
- Multiple MoE layers where some are quantized and some are not
"""
# model_path = "nm-testing/tinysmokeqwen3moe-W4A16-first-only" # CT 12.3
model_path = "nm-testing/tinysmokeqwen3moe-W4A16-first-only-CTstable" # CT 12.2
+2 -1
View File
@@ -213,7 +213,8 @@ def test_deepseek_v41_vl_mapper_routes_linear_scales(
):
"""The VL wrapper must map ``.scale`` keys to the parameter the linear
quant method registers, as the text model does. A hardcoded
``weight_scale_inv`` raised KeyError for native MXFP8 checkpoints."""
``weight_scale_inv`` raised KeyError for native MXFP8 checkpoints.
"""
from vllm.models.deepseek_v41.nvidia import model as model_module
from vllm.models.deepseek_v41.nvidia import vl_model as vl_module
+3 -3
View File
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""
Tests for MXFP4 MoE oracle backend selection on mi355x (GFX950).
"""Tests for MXFP4 MoE oracle backend selection on mi355x (GFX950).
These tests run on real hardware — no mocks. Skipped on non-GFX950 platforms.
"""
@@ -161,7 +160,8 @@ def test_qwen38_tep8_auto_fallback_respects_explicit_backend(
@pytest.fixture
def mxfp4_oracle_config():
"""Stub the config the oracle reads (``model_config.quantization_config``)
so backend dispatch resolves without a real model / user override."""
so backend dispatch resolves without a real model / user override.
"""
from unittest.mock import patch
with patch(
@@ -85,7 +85,8 @@ def test_block_fp8_activation_quant_config_is_block_quantized():
(FP8 dtype, [1, 128] block, not per-act-token). This is what makes the
DeepEP prepare/finalize step quantize activations to block FP8 *before* the
all-to-all dispatch instead of deferring to Humming -- and what makes
HummingExpertsBase.expects_unquantized_inputs return False."""
HummingExpertsBase.expects_unquantized_inputs return False.
"""
from vllm.model_executor.layers.quantization.utils.humming_utils import (
make_humming_moe_quant_config,
)
@@ -107,7 +108,8 @@ def test_block_fp8_activation_quant_config_is_block_quantized():
def test_default_activation_quant_config_defers_to_humming():
"""Without a block activation shape the config stays per-token (the deferred
path): Humming quantizes internally, preserving pre-existing behavior for
every non-block-FP8 scheme."""
every non-block-FP8 scheme.
"""
from vllm.model_executor.layers.quantization.utils.humming_utils import (
make_humming_moe_quant_config,
)
+3 -3
View File
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""
Tests for INT8 (W8A8) fused-MoE oracle backend selection.
"""Tests for INT8 (W8A8) fused-MoE oracle backend selection.
These exercise ``select_int8_moe_backend`` only (no kernels are launched), so
they run on any platform where the Triton INT8 MoE kernel is available — CUDA
@@ -71,7 +70,8 @@ def _make_int8_moe_config(moe_backend: str = "auto") -> FusedMoEConfig:
)
def test_int8_dynamic_schemes_dispatch_to_triton(weight_key, activation_key):
"""Both dynamic-activation INT8 MoE schemes (per-channel + per-tensor
weights) select the Triton backend."""
weights) select the Triton backend.
"""
config = _make_int8_moe_config()
backend, experts_cls = select_int8_moe_backend(
config, weight_key=weight_key, activation_key=activation_key
+8 -4
View File
@@ -587,7 +587,8 @@ def test_modelopt_fp8_pb_wo_checkpoint_setup(monkeypatch, dist_init, workspace_i
def test_modelopt_nvfp4_config_dispatches_w4a4_method():
"""``quant_method="NVFP4"`` (W4A4) resolves to a
``(kNvfp4Static, kNvfp4Dynamic)`` QuantSpec under the generic
``ModelOptLinearMethod``."""
``ModelOptLinearMethod``.
"""
from vllm.model_executor.layers.linear import LinearBase
config = ModelOptNvFp4Config(
@@ -636,7 +637,8 @@ def test_modelopt_linear_method_builder_registry_override(monkeypatch):
"""The bespoke-method escape hatch: a format registered in
``LINEAR_METHOD_BUILDERS`` routes that algo to its own method instead of the
generic ``ModelOptLinearMethod``. This is how a format that cannot be a
``(weight, activation)`` key pair plugs into dispatch."""
``(weight, activation)`` key pair plugs into dispatch.
"""
from vllm.model_executor.layers.linear import LinearBase
from vllm.model_executor.layers.quantization import modelopt as m
@@ -667,7 +669,8 @@ def test_modelopt_linear_method_builder_registry_override(monkeypatch):
def test_modelopt_w4a16_respects_linear_backend(linear_backend, kernel_cls):
"""W4A16 (`activation=None`) kernel selection honors ``--linear-backend``:
``use_a16=True`` defaults to Marlin, but an explicit backend wins. The
generic method routes this through ``select_linear_kernel``."""
generic method routes this through ``select_linear_kernel``.
"""
from vllm.config.quantization import QuantSpec
from vllm.model_executor.layers.quantization.modelopt import (
RuntimeDtypes,
@@ -938,7 +941,8 @@ def test_modelopt_fp8_pb_wo_hides_output_padding(monkeypatch):
def test_modelopt_fp8_pb_wo_rejects_non_128_input():
"""Input width must still be a multiple of 128 (same as #53132, which only
pads the output). A partial input block is refused loudly rather than
silently loading wrong scales."""
silently loading wrong scales.
"""
from vllm.model_executor.layers.quantization import modelopt as mo
from vllm.model_executor.layers.quantization.utils.quant_utils import (
kFp8Static128BlockSym,
+1 -4
View File
@@ -449,7 +449,6 @@ def test_online_shorthand_selects_checkpoint_or_online_config(
tmp_path, quantization, checkpoint_quantization_config, is_config_file
) -> None:
"""Online shorthands defer to checkpoint metadata when available."""
if is_config_file:
(tmp_path / "hf_quant_config.json").write_text(
'{"quant_method": "mxfp8", "ignored_layers": []}'
@@ -609,14 +608,12 @@ def test_online_quantization(
dist_init,
workspace_init,
) -> None:
"""
Tests that online quantization frontend configuration works -
"""Tests that online quantization frontend configuration works -
selecting quant schemes, overriding quant schemes by type, ignoring
layers.
Does not test performance, peak memory usage, etc.
"""
# TODO: Relax this condition once there is a native MXFP4_MXFP4
# linear/moe backend supported on cuda.
if quant_scheme == "mxfp4" and not (on_gfx950() or on_gfx942()):
+5 -7
View File
@@ -135,8 +135,7 @@ def _skip_reason_if_unavailable(backend: str, dtype: torch.dtype) -> str | None:
@pytest.mark.parametrize("dtype", [torch.bfloat16, torch.float16])
@pytest.mark.parametrize("backend", ["triton", "aiter", "xpu", "quark"])
def test_mxfp4_quantization_correctness(backend: str, dtype: torch.dtype):
"""
Tests that the different implementations of mxfp4_quantize
"""Tests that the different implementations of mxfp4_quantize
in mxfp4_utils.py all match.
"""
skip_reason = _skip_reason_if_unavailable(backend, dtype)
@@ -290,8 +289,7 @@ def test_online_mxfp4_moe_matches_quark(
dist_init,
monkeypatch,
):
"""
Ensures `Mxfp4OnlineMoEMethod` (online quantization)
"""Ensures `Mxfp4OnlineMoEMethod` (online quantization)
and `QuarkOCP_MX_MoEMethod` (AMD Quark checkpoints) produce the same weights,
with same MOE backend used.
@@ -413,7 +411,8 @@ def test_online_mxfp4_moe_matches_quark(
) -> tuple[torch.Tensor, torch.Tensor]:
"""Place the source weights into buffers of the padded size, the
way the weight loader writes only the unpadded slice of a larger
allocation."""
allocation.
"""
w13 = torch.full(
(num_experts, 2 * intermediate_size, hidden_size),
padding_value,
@@ -495,8 +494,7 @@ def test_online_mxfp4_moe_matches_quark(
def test_online_mxfp4_dense_matches_quark(
linear_backend: str, default_vllm_config, dist_init, monkeypatch
):
"""
Ensures `Mxfp4OnlineLinearMethod` (online quantization)
"""Ensures `Mxfp4OnlineLinearMethod` (online quantization)
and `QuarkOCP_MX` (AMD Quark checkpoints) produce the same weights,
with same linear backend used.
"""
@@ -490,7 +490,8 @@ def test_per_token_head_negative_slot_skipped(qcfg: QuantConfig):
)
def test_process_weights_sets_placeholder_scales(kv_cache_dtype: str):
"""Per-token-head should set _k_scale=1.0, _v_scale=1.0
and delete checkpoint attrs."""
and delete checkpoint attrs.
"""
from vllm.model_executor.layers.quantization.kv_cache import (
BaseKVCacheMethod,
)
@@ -48,7 +48,6 @@ class FakeQuantLinearMethod(UnquantizedLinearMethod):
bias: torch.Tensor | None = None,
) -> torch.Tensor:
"""Perform fake quantization before the linear layer."""
# Calculate the scales dynamically
max_val = torch.amax(x, dim=(0, -1), keepdims=True)
min_val = torch.amin(x, dim=(0, -1), keepdims=True)
@@ -108,7 +107,6 @@ class CustomQuantConfig(QuantizationConfig):
def test_register_quantization_config(caplog_vllm):
"""Test register custom quantization config."""
# The quantization method `custom_quant` should be registered.
assert get_quantization_config("custom_quant") == CustomQuantConfig