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
@@ -126,7 +126,6 @@ class QuarkConfig(QuantizationConfig):
revision: str | None = None,
):
"""Enable dynamic MXFP4 only for DeepSeek-V3-family fp4 checkpoints."""
if hf_config is None:
return
@@ -162,13 +161,13 @@ class QuarkConfig(QuantizationConfig):
def apply_vllm_mapper( # noqa: B027
self, hf_to_vllm_mapper: "WeightsMapper"
):
"""
Interface for models to update module names referenced in
"""Interface for models to update module names referenced in
quantization configs in order to reflect the vllm model structure
Args:
hf_to_vllm_mapper: maps from hf model structure (the assumed
structure of the qconfig) to vllm model structure
"""
quant_config_with_hf_to_vllm_mapper: dict[str, Any] = {}
@@ -657,8 +656,7 @@ class QuarkConfig(QuantizationConfig):
input_quant: dict[str, Any] | None,
allow_static_fp8: bool = False,
) -> QuantKeyMatch:
"""
This check returns True only if it is an OCP-MX weight quantization.
"""This check returns True only if it is an OCP-MX weight quantization.
The activation can be FP16/BF16, OCP MXFP4, MXFP8, FP8.
The rationale for checking only the weight type is that
the model loading concept and process primarily concerns the weights themselves.
@@ -984,8 +982,7 @@ class QuarkLinearMethod(LinearMethodBase):
params_dtype: torch.dtype,
**extra_weight_attrs,
):
"""
Use the CompressedTensorsScheme associated with each layer to create
"""Use the CompressedTensorsScheme associated with each layer to create
the necessary parameters for the layer. See LinearMethodBase for param
details
"""
@@ -1006,8 +1003,7 @@ class QuarkLinearMethod(LinearMethodBase):
x: torch.Tensor,
bias: torch.Tensor | None = None,
):
"""
Use the output of create_weights and the CompressedTensorsScheme
"""Use the output of create_weights and the CompressedTensorsScheme
associated with the layer to apply the forward pass with the
layer input. See LinearMethodBase for param details
@@ -1020,9 +1016,7 @@ class QuarkLinearMethod(LinearMethodBase):
class QuarkKVCacheMethod(BaseKVCacheMethod):
"""
Supports loading kv-cache scaling factors from quark checkpoints.
"""
"""Supports loading kv-cache scaling factors from quark checkpoints."""
def __init__(self, quant_config: QuarkConfig):
self.validate_kv_cache_config(quant_config.kv_cache_config)
@@ -1030,12 +1024,12 @@ class QuarkKVCacheMethod(BaseKVCacheMethod):
@staticmethod
def validate_kv_cache_config(kv_cache_config: dict[str, Any] | None):
"""
Validator for the kv cache configuration. Useful for controlling the
"""Validator for the kv cache configuration. Useful for controlling the
kv cache quantization schemes, that are being supported in vLLM
Args:
kv_cache_config: the quark kv cache scheme
"""
if kv_cache_config is None:
return
@@ -1748,10 +1748,7 @@ class QuarkNvfp4MoEMethod(QuarkMoEMethod):
set_weight_attrs(w2_input_scale_2, extra_weight_attrs)
def process_weights_after_loading(self, layer: RoutedExperts) -> None:
"""
Convert NVFP4 MoE weights into kernel format and setup the kernel.
"""
"""Convert NVFP4 MoE weights into kernel format and setup the kernel."""
# Match existing NVFP4 MoE paths: fused w13 uses the w1 global scale.
if self.moe.is_act_and_mul and not torch.allclose(
layer.w13_weight_scale_2[:, 0], layer.w13_weight_scale_2[:, 1]
@@ -31,8 +31,7 @@ logger = init_logger(__name__)
class QuarkNVFP4(QuarkScheme):
"""
Quark NVFP4 quantization scheme.
"""Quark NVFP4 quantization scheme.
Supports loading NVFP4 checkpoints with the following structure:
- weight: uint8, shape [out_features, in_features // 2] (packed FP4)
@@ -11,8 +11,7 @@ __all__ = ["QuarkScheme"]
class QuarkScheme(ABC):
"""
Abstract class used to describe the weight creation and forward pass
"""Abstract class used to describe the weight creation and forward pass
of different quantization schemes supported by Quark.
"""
@@ -36,25 +35,19 @@ class QuarkScheme(ABC):
@classmethod
@abstractmethod
def get_min_capability(cls) -> int:
"""
Get minimum device capability.
"""
"""Get minimum device capability."""
raise NotImplementedError
@abstractmethod
def create_weights(self, *args, **kwargs):
"""
Weight creation for the particular scheme. Inputs to this function
"""
"""Weight creation for the particular scheme. Inputs to this function."""
raise NotImplementedError
@abstractmethod
def apply_weights(
self, layer: torch.nn.Module, x: torch.Tensor, bias: torch.Tensor | None
):
"""
Run the forward pass for the particular scheme. This is where
"""Run the forward pass for the particular scheme. This is where
scheme-specific dequant/quant steps/kernels should be applied.
Args:
@@ -62,13 +55,13 @@ class QuarkScheme(ABC):
other parameters relevant to the particular scheme.
x: input to the layer
bias: bias parameter
"""
raise NotImplementedError
@abstractmethod
def process_weights_after_loading(self, layer: torch.nn.Module):
"""
Called after weight loading is complete for any cleanup that
"""Called after weight loading is complete for any cleanup that
needs to occur.
"""
raise NotImplementedError
@@ -33,8 +33,7 @@ OCP_MX_BLOCK_SIZE = 32
class QuarkW4A8_MXFP4_FP8(QuarkScheme):
"""
- Weights: MXFP4 with E8M0 scales per block of 32
"""- Weights: MXFP4 with E8M0 scales per block of 32
- Activations: FP8 E4M3 (static per-tensor quantization)
Uses the AITER Triton kernel and falls back to emulation if AITER not available.