[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:
Harry Mellor
2026-09-16 10:57:24 -07:00
committed by GitHub
co-authored by Claude Opus 5
parent 1085b64425
commit 651a88c09a
693 changed files with 2088 additions and 4171 deletions
@@ -167,8 +167,7 @@ class Config:
def fe_supports_quant_scheme(self) -> bool:
"""Check if the fused experts class supports this quant config.
See https://github.com/ROCm/aiter/issues/2419 for AITER gaps.
"""
See https://github.com/ROCm/aiter/issues/2419 for AITER gaps."""
if self.quant_config is None or self.quant_dtype is None:
return True
if self.quant_dtype != torch.float8_e4m3fn:
+1 -2
View File
@@ -468,8 +468,7 @@ def test_deepseek_v4_flashinfer_cutlass_falls_through_to_w4a8(
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""Explicit flashinfer_cutlass must try the W4A8 variant when the BF16
variant is unsupported (the BF16 variant is gated to SM90).
"""
variant is unsupported (the BF16 variant is gated to SM90)."""
from vllm.model_executor.layers.fused_moe.experts.flashinfer_cutlass_moe import (
FlashInferExperts,
)
+3 -6
View File
@@ -129,8 +129,7 @@ def test_batched_mm(
per_act_token_quant: bool,
):
"""Note: float8_e4m3fn is not supported on CUDA architecture < 89,
and those tests will be skipped on unsupported hardware.
"""
and those tests will be skipped on unsupported hardware."""
set_random_seed(7)
use_fp8_w8a8 = dtype == torch.float8_e4m3fn
@@ -269,8 +268,7 @@ def test_fused_moe_batched_experts(
workspace_init,
):
"""Note: float8_e4m3fn is not supported on CUDA architecture < 89,
and those tests will be skipped on unsupported hardware.
"""
and those tests will be skipped on unsupported hardware."""
set_random_seed(7)
use_fp8_w8a8 = dtype == torch.float8_e4m3fn
@@ -651,8 +649,7 @@ def test_batched_experts_masked_activation_end_to_end(
def test_batched_experts_end_to_end(m, n, k, e, topk):
"""End-to-end BatchedTritonExperts via the reference (no-comms)
BatchedPrepareAndFinalize, validated against a torch reference. Exercises
the device-enablement path.
"""
the device-enablement path."""
from vllm.v1.worker.workspace import init_workspace_manager
set_random_seed(7)
+2 -4
View File
@@ -54,8 +54,7 @@ SEEDS = [0]
# For test
def torch_w8a8_block_int8_moe(a, w1, w2, w1_s, w2_s, score, topk, block_shape):
"""This function performs fused moe with block-wise quantization using
native torch.
"""
native torch."""
B, D = a.shape
a = a.view(B, -1, D).repeat(1, topk, 1).reshape(-1, D)
out = torch.zeros(B * topk, w2.shape[1], dtype=a.dtype, device=a.device)
@@ -98,8 +97,7 @@ def setup_cuda():
@torch.inference_mode()
def test_w8a8_block_int8_fused_moe(M, N, K, E, topk, block_size, dtype, seed):
"""Tests the fused_moe kernel with W8A8 INT8 block quantization against a
native torch reference.
"""
native torch reference."""
torch.manual_seed(seed)
a = torch.randn((M, K), dtype=dtype) / 10
+2 -4
View File
@@ -397,8 +397,7 @@ UNALIGNED_INTERMEDIATE_DIM = 176
class _StubMoELayer(torch.nn.Module):
"""Minimal stand-in for the real MoE layer module, exposing just what
the unquantized CPU experts read/replace (w13_weight, w2_weight, the
router configuration, and optionally w13_bias/w2_bias).
"""
router configuration, and optionally w13_bias/w2_bias)."""
def __init__(
self,
@@ -501,8 +500,7 @@ def test_cpu_fused_moe_unaligned_intermediate_size(
act: MoEActivation,
):
"""CPU kernels handle unaligned intermediate sizes by zero-padding the
weights before prepacking.
"""
weights before prepacking."""
set_random_seed(0)
batch_size = 64
intermediate_size = UNALIGNED_INTERMEDIATE_DIM
+1 -2
View File
@@ -464,8 +464,7 @@ def test_trtllm_fp8_swiglu_clamp_support(
):
"""FlashInfer >= 0.6.18 applies the SwiGLU clamp for both block-scaled
kernels with a SwiGLU activation (DeepSeek-V4 sets swiglu_limit); the
per-tensor kernel has no clamp, and Relu2 rejects the parameters.
"""
per-tensor kernel has no clamp, and Relu2 rejects the parameters."""
class _Experts(TrtLlmFp8ExpertsModular):
@staticmethod
@@ -377,8 +377,7 @@ def test_unit_shuffle():
@pytest.mark.parametrize("n_experts,topk", [(32, 4), (128, 4)])
def test_routing_data_from_sparse_topk_parity(n_tokens, n_experts, topk):
"""routing_data_from_sparse_topk must produce routing structures
identical to make_routing_data for the same topk result.
"""
identical to make_routing_data for the same topk result."""
from vllm.model_executor.layers.fused_moe.experts import (
gpt_oss_triton_kernels_moe as gptoss_moe,
)
@@ -289,8 +289,7 @@ def test_marlin_vs_trtllm_mxint4_moe_kimik2(monkeypatch, m, n, k, e, topk, group
@torch.inference_mode()
def test_flashinfer_trtllm_mxint4_moe_wrapper(m, n, k, e, topk):
"""Test that the flashinfer_trtllm_mxint4_moe wrapper matches the raw
trtllm_mxint4_block_scale_moe kernel call.
"""
trtllm_mxint4_block_scale_moe kernel call."""
pytest.importorskip("flashinfer")
from flashinfer import RoutingMethodType
from flashinfer.fused_moe import trtllm_mxint4_block_scale_moe
@@ -352,8 +352,7 @@ def test_modular_kernel_combinations_singlegpu(
workspace_init,
):
"""Note: float8_e4m3fn is not supported on CUDA architecture < 89,
and those tests will be skipped on unsupported hardware.
"""
and those tests will be skipped on unsupported hardware."""
config = Config(
Ms=Ms,
K=k,
+1 -2
View File
@@ -21,8 +21,7 @@ from vllm.model_executor.layers.fused_moe.oracle.unquantized import (
class TestUnquantizedDelegation:
"""UnquantizedMoEKernelOracle methods must delegate to the existing
module-level functions; behaviour is bit-identical.
"""
module-level functions; behaviour is bit-identical."""
def test_make_kernel_delegates(self) -> None:
quant_config = object()
+1 -2
View File
@@ -315,8 +315,7 @@ def tp_chunk_gate_up(
device: torch.device | int | None = None,
) -> torch.Tensor:
"""TP-chunk a combined [gate; up] weight, splitting each half separately
so every rank gets a portion of both gate and up.
"""
so every rank gets a portion of both gate and up."""
half = w.shape[dim] // 2
gate = chunk_by_rank(
w.narrow(dim, 0, half), tp_rank, tp_size, dim=dim, device=device
@@ -130,8 +130,7 @@ def test_is_supported_config(present, ep_size, supported, reason_substr):
def test_explicit_moe_backend_aiter():
"""--moe-backend aiter: returns FlyDSL when usable (TP or EP), else a clear
ValueError when the flydsl package is missing.
"""
ValueError when the flydsl package is missing."""
with _gfx950(), _flydsl_installed(True):
assert (
_select_kernel_cls(Fp8MoeBackend.AITER_MXFP8, _config(1))
@@ -163,8 +162,7 @@ def test_gfx950_picks_aiter():
def test_gfx942_picks_emulation():
"""Flydsl unusable (e.g. gfx942, no FlyDSL support) -> native Triton
dot_scaled backend wins instead.
"""
dot_scaled backend wins instead."""
with patch(f"{_AITER_MOD}.current_platform.supports_mx", return_value=False):
backend, experts_cls = select_mxfp8_moe_backend(_config())
assert backend is Fp8MoeBackend.EMULATION
+11 -22
View File
@@ -249,8 +249,7 @@ def _make_topk_ids(
device: str = "cuda",
) -> torch.Tensor:
"""Generate distinct expert IDs per token with the same top-k shape as
production routing.
"""
production routing."""
router_logits = torch.randn(num_tokens, num_experts, device=device)
_, topk_ids = torch.topk(torch.softmax(router_logits, dim=-1), k=topk, dim=-1)
return topk_ids.to(torch.int32)
@@ -444,8 +443,7 @@ def test_aiter_fused_moe_custom_op_registered():
def test_aiter_asm_moe_tkw1_custom_op_registered():
"""The tkw1 custom op should stay registered for FP8 apply-router-weight
paths.
"""
paths."""
_assert_aiter_supported()
import vllm._aiter_ops as aiter_ops # noqa: F401
@@ -455,8 +453,7 @@ def test_aiter_asm_moe_tkw1_custom_op_registered():
def test_aiter_fused_moe_fake_tensor_support():
"""The fused-MoE op should preserve fake-tensor compatibility for
torch.compile-style tracing.
"""
torch.compile-style tracing."""
_assert_aiter_supported()
import vllm._aiter_ops # noqa: F401
@@ -519,8 +516,7 @@ def test_aiter_moe_enablement_follows_env(
monkeypatch: pytest.MonkeyPatch,
):
"""The fused-MoE gate should depend only on the main AITER toggle and the
MoE-specific toggle.
"""
MoE-specific toggle."""
from vllm._aiter_ops import rocm_aiter_ops
_assert_aiter_supported()
@@ -551,8 +547,7 @@ def test_aiter_moe_shared_experts_enablement_follows_env(
monkeypatch: pytest.MonkeyPatch,
):
"""Shared-expert fusion should only be enabled when the fused-MoE path is
enabled too.
"""
enabled too."""
from vllm._aiter_ops import rocm_aiter_ops
_assert_aiter_supported()
@@ -693,8 +688,7 @@ def test_aiter_mxfp4_quant_scheme_support_matches_gfx950():
@pytest.mark.skipif(not on_gfx950(), reason="gfx950 ROCm only")
def test_aiter_fused_moe_mi350_mxfp4_w4a16_accuracy():
"""The gfx950 AITER MXFP4 W4A16 MoE path should match the dequantized
MXFP4 reference.
"""
MXFP4 reference."""
from vllm.model_executor.layers.fused_moe.activation import MoEActivation
from vllm.model_executor.layers.fused_moe.experts.rocm_aiter_moe import (
rocm_aiter_fused_experts,
@@ -743,8 +737,7 @@ def test_aiter_fused_moe_mi350_mxfp4_w4a16_accuracy():
@pytest.mark.skipif(not on_gfx950(), reason="gfx950 ROCm only")
def test_aiter_fused_moe_mi350_mxfp4_w4a16_determinism():
"""The gfx950 AITER MXFP4 W4A16 MoE path should stay bitwise
deterministic.
"""
deterministic."""
from vllm.model_executor.layers.fused_moe.activation import MoEActivation
from vllm.model_executor.layers.fused_moe.experts.rocm_aiter_moe import (
rocm_aiter_fused_experts,
@@ -837,8 +830,7 @@ def test_aiter_fused_moe_bf16_accuracy(
intermediate_dim: int,
):
"""The ROCm AITER fused-MoE BF16 path should match the float32 reference
on representative shapes.
"""
on representative shapes."""
from vllm.model_executor.layers.fused_moe.experts.rocm_aiter_moe import (
ActivationMethod,
QuantMethod,
@@ -883,8 +875,7 @@ def test_aiter_fused_moe_bf16_accuracy(
def test_aiter_fused_moe_gelu_accuracy():
"""The GELU activation variant should stay aligned with the float32
reference.
"""
reference."""
from vllm.model_executor.layers.fused_moe.experts.rocm_aiter_moe import (
ActivationMethod,
QuantMethod,
@@ -929,8 +920,7 @@ def test_aiter_fused_moe_gelu_accuracy():
def test_aiter_fused_moe_determinism():
"""The BF16 fused-MoE kernel should stay bitwise deterministic for the
same inputs.
"""
same inputs."""
from vllm.model_executor.layers.fused_moe.experts.rocm_aiter_moe import (
ActivationMethod,
QuantMethod,
@@ -1085,8 +1075,7 @@ def test_aiter_fused_moe_mi3xx_bf16_accuracy():
)
def test_aiter_fused_moe_mi3xx_fp8_accuracy():
"""The MI3xx FP8 per-tensor MoE path should stay within the measured FP8
error budget.
"""
error budget."""
from tests.kernels.moe.utils import make_test_weights
from vllm._aiter_ops import rocm_aiter_ops
from vllm.model_executor.layers.fused_moe.experts.rocm_aiter_moe import (
@@ -185,8 +185,7 @@ def test_trtllm_bf16_monolithic_routing_replay_records_valid_experts(
) -> None:
"""The capture callback should receive the int16 routed-expert IDs the
kernel actually used, the values should be valid expert indices, and
each token should pick ``top_k`` distinct experts.
"""
each token should pick ``top_k`` distinct experts."""
if top_k > _DSV3_N_GROUP * _DSV3_TOPK_GROUP:
pytest.skip(
f"DSV3 requires top_k <= n_group * topk_group "
@@ -265,8 +264,7 @@ def test_trtllm_bf16_monolithic_routing_replay_non_dsv3(
routing_method: RoutingMethodType,
) -> None:
"""Routing replay works for non-DeepSeekV3 routing methods too.
FlashInfer's ``routing_replay_out`` is routing-method-agnostic.
"""
FlashInfer's ``routing_replay_out`` is routing-method-agnostic."""
torch.manual_seed(0)
device = torch.device("cuda:0")
@@ -319,8 +317,7 @@ def test_trtllm_bf16_monolithic_routing_replay_non_dsv3(
def test_trtllm_bf16_monolithic_capture_disabled_skips_buffer_alloc() -> None:
"""With no callback installed the kernel should not see a
``routing_replay_out`` tensor — verify the helper short-circuits.
"""
``routing_replay_out`` tensor — verify the helper short-circuits."""
torch.manual_seed(0)
device = torch.device("cuda:0")
experts, _, _ = _make_bf16_monolithic_experts(
@@ -342,8 +339,7 @@ def test_trtllm_bf16_monolithic_capture_disabled_skips_buffer_alloc() -> None:
def test_trtllm_bf16_monolithic_supports_capture_for_all_routing() -> None:
"""FlashInfer's ``routing_replay_out`` is supported by all routing
methods, so ``supports_routing_replay_capture`` should be True
regardless of routing method.
"""
regardless of routing method."""
device = torch.device("cuda:0")
for routing_method in (
RoutingMethodType.DeepSeekV3,
@@ -365,8 +361,7 @@ def test_trtllm_bf16_monolithic_supports_capture_for_all_routing() -> None:
def test_trtllm_bf16_monolithic_capture_buffer_shape_and_dtype() -> None:
"""When capture is installed, the allocated buffer is int16 and shaped
``(num_tokens, experts_per_token)``.
"""
``(num_tokens, experts_per_token)``."""
device = torch.device("cuda:0")
experts, _, _ = _make_bf16_monolithic_experts(
num_experts=_DSV3_NUM_EXPERTS,
@@ -597,8 +592,7 @@ def test_trtllm_fp8_block_scale_monolithic_routing_replay_records_valid_experts(
top_k: int,
) -> None:
"""End-to-end: ``TrtLlmFp8ExpertsMonolithic`` (DeepSeekFp8 block-scale
path, DSV3 routing) captures valid expert IDs.
"""
path, DSV3 routing) captures valid expert IDs."""
if top_k > _DSV3_N_GROUP * _DSV3_TOPK_GROUP:
pytest.skip(
f"DSV3 requires top_k <= n_group * topk_group "
@@ -784,8 +778,7 @@ def _run_nvfp4_monolithic(
routing_bias: torch.Tensor,
) -> torch.Tensor:
"""The monolithic NVFP4 apply expects packed fp4 hidden states + the
matching fp8 per-block scale stored in the ``a1q_scale`` slot.
"""
matching fp8 per-block scale stored in the ``a1q_scale`` slot."""
# Stash the weight tensors on the experts in the locations the apply()
# implementation reads from (it pulls them from quant_config / scales
# already; w1/w2 come in as args).
@@ -813,8 +806,7 @@ def test_trtllm_nvfp4_monolithic_routing_replay_records_valid_experts(
top_k: int,
) -> None:
"""End-to-end: ``TrtLlmNvFp4ExpertsMonolithic`` captures valid expert IDs
on the DSV3 routing path.
"""
on the DSV3 routing path."""
if top_k > _DSV3_N_GROUP * _DSV3_TOPK_GROUP:
pytest.skip(
f"DSV3 requires top_k <= n_group * topk_group "
+1 -2
View File
@@ -250,8 +250,7 @@ def assert_aiter_routing_valid(
the Python baseline (different group selection, scoring internals),
so numerical comparison is not meaningful. Instead we verify the
outputs satisfy the routing contract: correct shapes, valid expert
IDs, non-negative weights, and proper normalization.
"""
IDs, non-negative weights, and proper normalization."""
n_tokens = topk_weights.shape[0]
# Shape
+2 -4
View File
@@ -76,8 +76,7 @@ def test_basic_functionality(
def test_routing_strategy_integration(monkeypatch, device):
"""Test that the routing strategy environment variable works with
FusedMoEFactory.
"""
FusedMoEFactory."""
pytest.importorskip("vllm.model_executor.layers.fused_moe.layer")
import vllm.envs as envs
@@ -158,8 +157,7 @@ def test_routing_strategy_integration(monkeypatch, device):
def test_distribution_based_routing_with_custom_strategy():
"""Test registering and using DistributionBasedRouting with custom
parameters.
"""
parameters."""
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# Register custom distribution-based strategy
@@ -70,8 +70,7 @@ def reference_with_clamp(
) -> tuple[torch.Tensor, torch.Tensor]:
"""Pre-clamp inputs (gate from above, up symmetric) at the input dtype to
match the C++ compute() template, then run the standard silu_and_mul +
quant reference.
"""
quant reference."""
N_2 = x.size(1) // 2
dtype = x.dtype
gate = x[..., :N_2].to(torch.float32).clamp(max=clamp_limit).to(dtype)
@@ -28,8 +28,7 @@ if current_platform.is_fp8_fnuz():
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)
@@ -57,8 +56,7 @@ def fp8_mask(a, mask):
def torch_w8a8_per_column_moe(a, w1, w2, w1_s, w2_s, score, topk):
"""This function performs fused moe with per-column int8
quantization using native torch.
"""
quantization using native torch."""
B, D = a.shape
# Perform per-token quantization
a_q, a_s = ops.scaled_fp8_quant(a, use_per_token_if_dynamic=True)
@@ -150,8 +150,7 @@ def test_select_default_backend_by_platform(
expected_backend,
):
"""Test default backend selection per platform with all optional
accelerators (FlashInfer, AITER) disabled.
"""
accelerators (FlashInfer, AITER) disabled."""
with patch(
"vllm.model_executor.layers.fused_moe.oracle.unquantized.current_platform"
) as mock_platform:
@@ -445,8 +444,7 @@ def test_select_cuda_flashinfer_cutlass_backend(
mock_has_flashinfer,
):
"""Test CUDA backend selection when FlashInfer TRTLLM is not available
and FlashInfer CUTLASS is available.
"""
and FlashInfer CUTLASS is available."""
with (
patch.object(current_platform, "is_cuda", return_value=True),
patch.object(current_platform, "is_rocm", return_value=False),