[MyPy][2/N] Fix mypy errors in small tests/ dirs (#51043)

Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Co-authored-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Martin Hickey
2026-09-29 21:27:45 +01:00
committed by GitHub
co-authored by Harry Mellor Claude Opus 5.5
parent a96ee5935d
commit 5dd693122c
71 changed files with 491 additions and 301 deletions
+3 -2
View File
@@ -37,7 +37,8 @@ from vllm.utils.flashinfer import (
)
from vllm.utils.import_utils import has_deep_gemm
if current_platform.get_device_capability() < (9, 0):
capability = current_platform.get_device_capability()
if capability is None or capability < (9, 0):
pytest.skip("FP8 Triton requires CUDA 9.0 or higher", allow_module_level=True)
vllm_config = VllmConfig()
@@ -258,7 +259,7 @@ def test_w8a8_block_fp8_torch_scaled_mm_matmul():
stub = BlockWiseTorchFP8ScaledMMLinearKernel.__new__(
BlockWiseTorchFP8ScaledMMLinearKernel
)
stub.config = types.SimpleNamespace(out_dtype=out_dtype)
stub.config = types.SimpleNamespace(out_dtype=out_dtype) # type: ignore[assignment]
out = stub.apply_block_scaled_mm(
A_fp8_cuda.cuda(), B_fp8.cuda(), As_cuda.cuda(), Bs.cuda()
)
@@ -62,7 +62,8 @@ PER_TOKEN_GROUP_SHAPE = (1, -1)
PER_OUT_CH_GROUP_SHAPE = (-1, 1)
capability = current_platform.get_device_capability()
capability = capability[0] * 10 + capability[1]
# Fall back to 0 so import doesn't fail on unknown capability
capability_int = (capability[0] * 10 + capability[1]) if capability is not None else 0
def rand_int8(shape: tuple, device: str = "cuda"):
@@ -639,7 +640,7 @@ def test_cutlass_cuda_graph(per_act_token: bool, per_out_ch: bool):
def test_cutlass_support_opcheck():
opcheck(torch.ops._C.cutlass_scaled_mm_supports_fp8, (capability,))
opcheck(torch.ops._C.cutlass_scaled_mm_supports_fp8, (capability_int,))
@pytest.mark.parametrize("num_experts", [8, 64])
@@ -29,7 +29,8 @@ if not current_platform.is_cuda():
# `is_quant_method_supported` conflates kernels with quantization methods
# an assumption which is breaking down as quantizations methods can have
# have kernels and some kernels support multiple quantization methods.
IS_SUPPORTED_BY_GPU = current_platform.get_device_capability()[0] >= 9
capability = current_platform.get_device_capability()
IS_SUPPORTED_BY_GPU = capability is not None and capability[0] >= 9
MNK_SHAPES = [
(1, 128, 128),
@@ -207,7 +208,7 @@ def mm_test_helper(
a=tensors.a,
b_q=tensors.w_q,
b_group_scales=tensors.w_g_s,
b_group_size=group_size,
b_group_size=group_size, # type: ignore[arg-type]
b_channel_scales=tensors.w_ch_s,
a_token_scales=tensors.w_tok_s,
)
@@ -17,8 +17,9 @@ from vllm.platforms import current_platform
from vllm.scalar_type import ScalarType, scalar_types
from vllm.utils.torch_utils import set_random_seed
capability = current_platform.get_device_capability()
IS_SUPPORTED_BY_GPU = (
current_platform.is_cuda() and current_platform.get_device_capability()[0] >= 9
current_platform.is_cuda() and capability is not None and capability[0] >= 9
)
+6 -2
View File
@@ -12,6 +12,7 @@ from tests.kernels.quant_utils import (
)
from tests.kernels.utils import opcheck
from vllm.model_executor.layers.quantization.utils.quant_utils import (
GroupShape,
scaled_quantize,
)
from vllm.platforms import current_platform
@@ -208,7 +209,10 @@ def test_static_fp8_quant_group_2d(
x = torch.rand(num_tokens, hidden_size, dtype=dtype, device="cuda")
ref_out, scale = scaled_quantize(
x, group_shape, current_platform.fp8_dtype(), compute_dtype=torch.float32
x,
GroupShape(*group_shape),
current_platform.fp8_dtype(),
compute_dtype=torch.float32,
)
ops_out, ops_scale = ops.scaled_fp8_quant(x, scale=scale, group_shape=group_shape)
@@ -236,7 +240,7 @@ def test_static_fp8_quant_1d_scale(
x = torch.rand(num_tokens, hidden_size, dtype=dtype, device="cuda")
ref_out, scale_2d = scaled_quantize(
x, group_shape, FP8_DTYPE, compute_dtype=torch.float32
x, GroupShape(*group_shape), FP8_DTYPE, compute_dtype=torch.float32
)
# Flatten scale to 1D for testing 1D scale path
@@ -38,7 +38,8 @@ CUDA_DEVICES = [
# `is_quant_method_supported` conflates kernels with quantization methods
# an assumption which is breaking down as quantizations methods can have
# have kernels and some kernels support multiple quantization methods.
IS_SUPPORTED_BY_GPU = current_platform.get_device_capability()[0] >= 9
capability = current_platform.get_device_capability()
IS_SUPPORTED_BY_GPU = capability is not None and capability[0] >= 9
MNK_SHAPES = [
(1, 128, 128),
@@ -305,7 +306,7 @@ def test_machete_all_schedules(shape, types: TypeConfig):
if types.group_scale_type is None:
group_sizes = [None]
else:
group_sizes = query_machete_supported_group_sizes(types.act_type)
group_sizes = list(query_machete_supported_group_sizes(types.act_type))
for group_size in group_sizes:
if not group_size_valid(shape, group_size):
@@ -334,7 +335,7 @@ def test_machete_heuristic(shape, types: TypeConfig):
if types.group_scale_type is None:
group_sizes = [None]
else:
group_sizes = query_machete_supported_group_sizes(types.act_type)
group_sizes = list(query_machete_supported_group_sizes(types.act_type))
for group_size in group_sizes:
if not group_size_valid(shape, group_size):
@@ -342,7 +342,7 @@ def marlin_generate_valid_test_cases():
[quant_test_config["b_type"]],
quant_test_config.get("c_type", f16_types),
quant_test_config["group_blocks"],
)
) # type: ignore[call-overload]
for sub_case in inner_combinations:
if (
@@ -11,6 +11,7 @@ import pytest
import torch
from vllm import _custom_ops as ops
from vllm.model_executor.layers.linear import LinearBase
from vllm.model_executor.layers.quantization.utils.marlin_utils import (
GPTQ_MARLIN_TILE,
apply_gptq_marlin_linear,
@@ -524,13 +525,15 @@ def test_check_marlin_supports_layer_allow_tile_padding():
)
# Tile-misaligned but group-aligned: rejected strictly, allowed w/ padding
layer = _FakeLinear(4640, 512, input_size=2048)
layer: LinearBase = _FakeLinear( # type: ignore[assignment]
4640, 512, input_size=2048
)
assert not check_marlin_supports_layer(layer, 128)
assert check_marlin_supports_layer(layer, 128, allow_tile_padding=True)
assert check_marlin_supports_layer(layer, -1, allow_tile_padding=True)
# A group straddling the TP shard cannot be fixed by padding
layer = _FakeLinear(4608, 4672, input_size=18688)
layer = _FakeLinear(4608, 4672, input_size=18688) # type: ignore[assignment]
assert not check_marlin_supports_layer(layer, 128, allow_tile_padding=True)
@@ -206,7 +206,7 @@ def test_nvfp4_emulation_support_check_rejects_bias_and_lora(
in_dtype=torch.bfloat16,
device="cuda",
routing_method=RoutingMethodType.TopK,
**config_kwargs,
**config_kwargs, # type: ignore[arg-type]
)
supported, reason = Nvfp4QuantizationEmulationTritonExperts.is_supported_config(
@@ -35,7 +35,7 @@ pytestmark = pytest.mark.cpu_test
def test_auto_linear_backend_is_unchanged_without_overrides():
kernels = [object]
kernels: list[type] = [object]
quantizations = (
"fp8_block_w8a8",
"fp8_w8a8",