[CI] Ignore ruff D209, rejoin the docstrings it split, and silence incompatible-rule warnings (#57212)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
1085b64425
commit
651a88c09a
@@ -304,8 +304,7 @@ def test_hipb_mm_kernel_forward_matches_raw_aiter_hipb_mm(enable_hipb_mm_kernel)
|
||||
|
||||
def test_hipb_mm_kernel_forward_accuracy(enable_hipb_mm_kernel):
|
||||
"""Kernel output should match a dequantized fp32 reference within
|
||||
fp8 per-token / per-channel quantization noise.
|
||||
"""
|
||||
fp8 per-token / per-channel quantization noise."""
|
||||
weight_shape = (512, 4096) # (N, K)
|
||||
num_tokens = 32
|
||||
_check_bpreshuffle_runtime_support(weight_shape, num_tokens=num_tokens)
|
||||
|
||||
@@ -30,8 +30,7 @@ if current_platform.is_cuda_alike() and not current_platform.has_device_capabili
|
||||
|
||||
def native_w8a8_per_token_matmul(A, B, As, Bs, output_dtype=torch.float16):
|
||||
"""Matrix multiplication function that supports per-token input
|
||||
quantization and per-column weight quantization
|
||||
"""
|
||||
quantization and per-column weight quantization"""
|
||||
A = A.to(torch.float32)
|
||||
B = B.to(torch.float32)
|
||||
|
||||
@@ -54,8 +53,7 @@ def native_w8a8_per_token_matmul(A, B, As, Bs, output_dtype=torch.float16):
|
||||
|
||||
def torch_w8a8_per_column_moe(a, w1, w2, w1_s, w2_s, topk, topk_weight, topk_ids):
|
||||
"""This function performs fused moe with per-column int8 quantization
|
||||
using native torch.
|
||||
"""
|
||||
using native torch."""
|
||||
B, D = a.shape
|
||||
# Perform per-token quantization
|
||||
a_q, a_s = per_token_quant_int8(a)
|
||||
|
||||
@@ -360,8 +360,7 @@ def test_gptq_marlin_padded_round_trip(shape, group_size):
|
||||
def test_fp8_block_marlin_padded_round_trip(shape):
|
||||
"""Block-quantized FP8 (e.g. Nemotron NVFP4 checkpoints' FP8 layers):
|
||||
group_size=128 exercises the lcm K-alignment in marlin_padded_nk and the
|
||||
weight_scale_inv group-wise scale padding.
|
||||
"""
|
||||
weight_scale_inv group-wise scale padding."""
|
||||
size_n, size_k = shape
|
||||
block = 128
|
||||
dtype = torch.float16
|
||||
@@ -411,8 +410,7 @@ def test_fp8_block_marlin_padded_round_trip(shape):
|
||||
@pytest.mark.parametrize("shape", [(200, 288), (4640, 512)])
|
||||
def test_mxfp8_marlin_padded_round_trip(shape):
|
||||
"""MXFP8 exercises the e8m0 scale path, where padded 0.0 scales clamp to
|
||||
2^-127 instead of zero and must still contribute nothing.
|
||||
"""
|
||||
2^-127 instead of zero and must still contribute nothing."""
|
||||
size_n, size_k = shape
|
||||
group_size = 32
|
||||
# The e8m0-scale Marlin kernels are only instantiated for bf16 activations.
|
||||
@@ -459,8 +457,7 @@ def test_mxfp8_marlin_padded_round_trip(shape):
|
||||
@pytest.mark.parametrize("shape", [(200, 512), (4640, 512)])
|
||||
def test_awq_zp_marlin_padded_round_trip(shape):
|
||||
"""AWQ-style uint4 with runtime zero-points, padded the way
|
||||
MarlinLinearKernel does: padded columns rely on (q=0 - zp=0) * scale=0.
|
||||
"""
|
||||
MarlinLinearKernel does: padded columns rely on (q=0 - zp=0) * scale=0."""
|
||||
size_n, size_k = shape
|
||||
group_size = 128
|
||||
dtype = torch.float16
|
||||
@@ -695,8 +692,7 @@ def test_check_moe_marlin_supports_layer_padding():
|
||||
@pytest.mark.parametrize("shape", [(96, 256, 8), (160, 512, 4)])
|
||||
def test_fp8_marlin_moe_padded_round_trip(shape, quant):
|
||||
"""FP8 weight-only MoE: pad a tile-misaligned intermediate and check the
|
||||
real prepare + fused_marlin_moe against the dequantized reference.
|
||||
"""
|
||||
real prepare + fused_marlin_moe against the dequantized reference."""
|
||||
from tests.kernels.utils import torch_experts
|
||||
from vllm.config import VllmConfig, set_current_vllm_config
|
||||
from vllm.model_executor.layers.fused_moe import fused_topk
|
||||
@@ -781,8 +777,7 @@ def test_fp8_marlin_moe_padded_round_trip(shape, quant):
|
||||
@pytest.mark.parametrize("shape", [(96, 256, 8), (160, 512, 4)])
|
||||
def test_mxfp8_marlin_moe_padded_round_trip(shape):
|
||||
"""MXFP8 weight-only MoE round-trip at a tile-misaligned intermediate, with
|
||||
unit e8m0 scales so the reference is the exact fp8 dequant.
|
||||
"""
|
||||
unit e8m0 scales so the reference is the exact fp8 dequant."""
|
||||
from tests.kernels.utils import torch_experts
|
||||
from vllm.config import VllmConfig, set_current_vllm_config
|
||||
from vllm.model_executor.layers.fused_moe import fused_topk
|
||||
|
||||
@@ -72,8 +72,7 @@ def test_true_w4a4_kernels_reject_unset_activation(kernel_cls):
|
||||
@pytest.mark.parametrize("kernel_cls", _TRUE_W4A4_KERNELS)
|
||||
def test_true_w4a4_kernels_reject_explicit_non_mxfp4_activation(kernel_cls):
|
||||
"""FlashInfer/XPU/Aiter quantize activations to MXFP4 internally, so an
|
||||
explicit request for a different activation format must be rejected.
|
||||
"""
|
||||
explicit request for a different activation format must be rejected."""
|
||||
config = MxFp4LinearLayerConfig(activation_quant_key=kMxfp6E3M2Dynamic)
|
||||
can_implement, reason = kernel_cls.can_implement(config)
|
||||
assert not can_implement
|
||||
@@ -88,8 +87,7 @@ def test_weight_only_kernels_accept_unquantized_or_mxfp4_activation(
|
||||
"""Marlin/Humming never quantize activations, so an unset activation key,
|
||||
or one that already describes MXFP4-shaped data, is tolerated. When an
|
||||
activation key is explicitly set, a warning must be logged noting that it
|
||||
is ignored, since these kernels are weight-only (A16).
|
||||
"""
|
||||
is ignored, since these kernels are weight-only (A16)."""
|
||||
config = MxFp4LinearLayerConfig(activation_quant_key=activation_quant_key)
|
||||
with patch(f"{kernel_cls.__module__}.logger.warning_once") as warning_once:
|
||||
can_implement, reason = kernel_cls.can_implement(config)
|
||||
@@ -118,8 +116,7 @@ def test_weight_only_kernels_reject_non_mxfp4_activation(kernel_cls):
|
||||
)
|
||||
def test_emulation_kernel_accepts_any_config(activation_quant_key, monkeypatch):
|
||||
"""EmulationMxfp4LinearKernel is the universal fallback: it must accept
|
||||
every supported activation format.
|
||||
"""
|
||||
every supported activation format."""
|
||||
# `EmulationMxfp4LinearKernel.can_implement` gates on `has_quark()`,
|
||||
# which we are not testing here.
|
||||
monkeypatch.setattr(
|
||||
@@ -137,8 +134,7 @@ def test_emulation_kernel_accepts_any_config(activation_quant_key, monkeypatch):
|
||||
|
||||
def test_emulation_kernel_derives_quant_dequant_func_from_config(monkeypatch):
|
||||
"""quant_dequant_func must be derived purely from the config's activation
|
||||
QuantKey, not set externally.
|
||||
"""
|
||||
QuantKey, not set externally."""
|
||||
# `EmulationMxfp4LinearKernel.can_implement` gates on `has_quark()`,
|
||||
# which we are not testing here.
|
||||
monkeypatch.setattr(
|
||||
@@ -162,8 +158,7 @@ def test_emulation_kernel_derives_quant_dequant_func_from_config(monkeypatch):
|
||||
|
||||
def test_aiter_kernel_is_supported_requires_native_mx_support():
|
||||
"""AiterMxfp4LinearKernel must not be selected on platforms without
|
||||
native MX compute, even if AITER itself is importable.
|
||||
"""
|
||||
native MX compute, even if AITER itself is importable."""
|
||||
with patch(
|
||||
"vllm.model_executor.kernels.linear.mxfp4.aiter.current_platform.supports_mx",
|
||||
return_value=False,
|
||||
@@ -199,8 +194,7 @@ class OOTMxFp4LinearKernel(MxFp4LinearKernel):
|
||||
@patch("vllm.model_executor.kernels.linear.current_platform")
|
||||
def test_init_mxfp4_linear_kernel_dispatches_to_registered_kernel(platform_mock):
|
||||
"""init_mxfp4_linear_kernel should select a registered kernel that
|
||||
reports itself as supported, and construct it with a fresh config.
|
||||
"""
|
||||
reports itself as supported, and construct it with a fresh config."""
|
||||
platform_mock._enum = PlatformEnum.OOT
|
||||
register_linear_kernel(OOTMxFp4LinearKernel, PlatformEnum.OOT, "mxfp4")
|
||||
|
||||
|
||||
@@ -16,8 +16,7 @@ import torch
|
||||
|
||||
class TestTritonMoeForwardExpertMap:
|
||||
"""Test that triton_kernel_moe_forward applies expert_map remapping
|
||||
when expert_map is provided (EP active).
|
||||
"""
|
||||
when expert_map is provided (EP active)."""
|
||||
|
||||
def test_expert_map_remap(self):
|
||||
device = "cuda" if torch.cuda.is_available() else "cpu"
|
||||
|
||||
@@ -41,8 +41,7 @@ def test_can_implement_is_abstract():
|
||||
|
||||
def test_emulation_kernel_rejects_non_mxfp6_weights():
|
||||
"""EmulationMxfp6LinearKernel must not implement a non-MXFP6 weight
|
||||
format.
|
||||
"""
|
||||
format."""
|
||||
config = MxFp6LinearLayerConfig(weight_quant_key=kMxfp4Static)
|
||||
can_implement, reason = EmulationMxfp6LinearKernel.can_implement(config)
|
||||
assert not can_implement
|
||||
@@ -58,8 +57,7 @@ def test_emulation_kernel_accepts_any_supported_config(
|
||||
weight_quant_key, activation_quant_key
|
||||
):
|
||||
"""EmulationMxfp6LinearKernel is the only backend today: it must accept
|
||||
every supported weight/activation format combination.
|
||||
"""
|
||||
every supported weight/activation format combination."""
|
||||
config = MxFp6LinearLayerConfig(
|
||||
weight_quant_key=weight_quant_key, activation_quant_key=activation_quant_key
|
||||
)
|
||||
@@ -104,8 +102,7 @@ class OOTMxFp6LinearKernel(MxFp6LinearKernel):
|
||||
def test_init_mxfp6_linear_kernel_dispatches_to_registered_kernel(platform_mock):
|
||||
"""init_mxfp6_linear_kernel should select a registered kernel that
|
||||
reports itself as supported/able to implement the given config, and
|
||||
construct it with that exact config.
|
||||
"""
|
||||
construct it with that exact config."""
|
||||
platform_mock._enum = PlatformEnum.OOT
|
||||
register_linear_kernel(OOTMxFp6LinearKernel, PlatformEnum.OOT, "mxfp6")
|
||||
|
||||
|
||||
@@ -118,8 +118,7 @@ def test_per_token_group_quant_fp8_packed(
|
||||
num_tokens, hidden_dim, group_size, poisoned_scales
|
||||
):
|
||||
"""Test the packed DeepGEMM quantization kernel against the Triton
|
||||
reference (row-major, UE8M0 scales).
|
||||
"""
|
||||
reference (row-major, UE8M0 scales)."""
|
||||
device = "cuda"
|
||||
torch.manual_seed(42)
|
||||
|
||||
@@ -257,8 +256,7 @@ def test_per_token_group_quant_fp8_packed_all_zero():
|
||||
def test_per_token_group_quant_fp8_packed_mantissa_rounds_up():
|
||||
"""Inputs whose absmax/max_8bit produces a non-power-of-2 force the
|
||||
mantissa-rounding-up branch (exp_byte += 1). Locks down this behavior
|
||||
before optimization.
|
||||
"""
|
||||
before optimization."""
|
||||
device = "cuda"
|
||||
num_tokens, hidden_dim, group_size = 4, 7168, 128
|
||||
|
||||
@@ -330,8 +328,7 @@ def test_per_token_group_quant_fp8_packed_zero_fills_padded_output_q(
|
||||
):
|
||||
"""When output_q is allocated with shape (tma_aligned_mn, k) instead of
|
||||
(mn, k), the kernel must overwrite the padded mn rows with zeros so
|
||||
callers can use ``torch.empty`` instead of ``torch.zeros``.
|
||||
"""
|
||||
callers can use ``torch.empty`` instead of ``torch.zeros``."""
|
||||
device = "cuda"
|
||||
group_size = 128
|
||||
torch.manual_seed(42)
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
"""Tests for the Triton dequant-gather kernel used by
|
||||
``CompressedTensorsEmbeddingWNA16Int`` (quantized embedding lookup).
|
||||
"""
|
||||
``CompressedTensorsEmbeddingWNA16Int`` (quantized embedding lookup)."""
|
||||
|
||||
import pytest
|
||||
import torch
|
||||
|
||||
@@ -29,8 +29,7 @@ pytestmark = pytest.mark.skipif(
|
||||
|
||||
def test_rocm_aiter_group_fp8_quant_fake_implementation():
|
||||
"""Test that the fake implementation is correctly
|
||||
defined for torch.ops.vllm.rocm_aiter_group_fp8_quant.
|
||||
"""
|
||||
defined for torch.ops.vllm.rocm_aiter_group_fp8_quant."""
|
||||
# Create test tensors
|
||||
M = 128
|
||||
N = 4096
|
||||
@@ -50,8 +49,7 @@ def test_rocm_aiter_group_fp8_quant_fake_implementation():
|
||||
def test_rocm_aiter_group_fp8_quant_torch_compile_with_cudagraph():
|
||||
"""Test that rocm_aiter_ops.group_fp8_quant
|
||||
with group size 128 can be used with
|
||||
torch.compile in cudagraph mode.
|
||||
"""
|
||||
torch.compile in cudagraph mode."""
|
||||
# Create test tensors
|
||||
M = 128
|
||||
N = 4096
|
||||
|
||||
@@ -209,8 +209,7 @@ def test_rocm_aiter_fp4_enablement_follows_env_and_arch(
|
||||
@pytest.mark.parametrize("shape", LLAMA_SHAPES)
|
||||
def test_vllm_quant_dequant_mxfp4_matches_reference_on_large_shapes(shape, dtype):
|
||||
"""The public vLLM MXFP4 QDQ helper should stay exact against the torch
|
||||
reference even on larger Llama-like shapes.
|
||||
"""
|
||||
reference even on larger Llama-like shapes."""
|
||||
from vllm.model_executor.layers.quantization.utils.mxfp4_utils import (
|
||||
quant_dequant_mxfp4,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user