Disable mypy arg-type and assignment checks in tests (#59428)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
17e9295dd5
commit
fc2c801ad9
@@ -23,12 +23,12 @@ from vllm.platforms.interface import DeviceCapability
|
||||
if current_platform.is_cuda():
|
||||
from vllm.platforms.cuda import CudaPlatform
|
||||
else:
|
||||
CudaPlatform = None # type: ignore[assignment] # Unavailable platform import.
|
||||
CudaPlatform = None
|
||||
|
||||
if current_platform.is_rocm():
|
||||
from vllm.platforms.rocm import RocmPlatform
|
||||
else:
|
||||
RocmPlatform = None # type: ignore[misc, assignment] # Unavailable platform import.
|
||||
RocmPlatform = None # type: ignore[misc] # Unavailable platform import.
|
||||
|
||||
from vllm.v1.attention.backend import AttentionType
|
||||
from vllm.v1.attention.backends.registry import AttentionBackendEnum
|
||||
@@ -356,14 +356,14 @@ def test_invalid_backend():
|
||||
def test_auto_backend_string(auto_value: str):
|
||||
"""Test that 'auto' string value triggers automatic backend selection."""
|
||||
# Using "auto" should result in backend=None (automatic selection)
|
||||
attention_config = AttentionConfig(backend=auto_value) # type: ignore[arg-type]
|
||||
attention_config = AttentionConfig(backend=auto_value)
|
||||
assert attention_config.backend is None
|
||||
|
||||
|
||||
def test_auto_backend_selection_behavior():
|
||||
"""Test that 'auto' backend behaves same as None (automatic selection)."""
|
||||
# Create config with explicit "auto"
|
||||
auto_config = AttentionConfig(backend="auto") # type: ignore[arg-type]
|
||||
auto_config = AttentionConfig(backend="auto")
|
||||
|
||||
# Create config with None (default)
|
||||
none_config = AttentionConfig(backend=None)
|
||||
|
||||
@@ -836,7 +836,7 @@ def varlen_encoder_zentorch_sdpa(
|
||||
key,
|
||||
value,
|
||||
output,
|
||||
SimpleNamespace(query_start_loc=query_start_loc, causal=False), # type: ignore[arg-type]
|
||||
SimpleNamespace(query_start_loc=query_start_loc, causal=False),
|
||||
scale,
|
||||
sliding_window if sliding_window is not None else -1,
|
||||
alibi_slopes,
|
||||
|
||||
@@ -1782,7 +1782,7 @@ def test_aiter_indexer_requires_the_aiter_attend(monkeypatch):
|
||||
num_index_heads=1,
|
||||
index_head_dim=HEAD_DIM,
|
||||
# The implementation also accepts this legacy fp8 alias.
|
||||
indexer_kv_dtype="fp8_e4m3", # type: ignore[arg-type]
|
||||
indexer_kv_dtype="fp8_e4m3",
|
||||
max_model_len=8192,
|
||||
)
|
||||
|
||||
|
||||
@@ -235,14 +235,14 @@ def test_msa_metadata_builder_prepares_cutlass_for_regular_decode(
|
||||
builder.num_q_heads = 64
|
||||
builder.num_kv_heads = 4
|
||||
builder.topk_blocks = TOPK
|
||||
builder.kv_cache_spec = SimpleNamespace(num_kv_heads=4) # type: ignore[assignment]
|
||||
builder.kv_cache_spec = SimpleNamespace(num_kv_heads=4)
|
||||
builder.kv_cache_dtype = "fp8_e4m3"
|
||||
builder.decode_backend = "cutlass"
|
||||
builder.msa_cutlass_plan_cache = object() # type: ignore[assignment] # Mocked plan-cache sentinel.
|
||||
builder.msa_cutlass_plan_cache = object()
|
||||
|
||||
metadata = builder.build(
|
||||
0,
|
||||
SimpleNamespace( # type: ignore[arg-type]
|
||||
SimpleNamespace(
|
||||
seq_lens_cpu_upper_bound=torch.full((batch,), 257, dtype=torch.int32)
|
||||
),
|
||||
)
|
||||
@@ -377,7 +377,7 @@ def test_query_fp8_stays_valid_when_cutlass_plan_appears_on_replay(
|
||||
with torch.cuda.stream(stream), override_forward_context(forward_context):
|
||||
capture = BreakableCUDAGraphCapture()
|
||||
with capture:
|
||||
query_fp8 = MiniMaxM3SparseAttention._allocate_query_fp8(attention, qkv) # type: ignore[arg-type]
|
||||
query_fp8 = MiniMaxM3SparseAttention._allocate_query_fp8(attention, qkv)
|
||||
if query_fp8 is not None:
|
||||
query_fp8.zero_()
|
||||
run_attention(query_fp8)
|
||||
@@ -387,7 +387,7 @@ def test_query_fp8_stays_valid_when_cutlass_plan_appears_on_replay(
|
||||
assert capture.num_eager_breaks == 1
|
||||
assert observed_ptrs == []
|
||||
|
||||
decode.msa_cutlass = object() # type: ignore[assignment]
|
||||
decode.msa_cutlass = object()
|
||||
for _ in range(3):
|
||||
capture.replay()
|
||||
stream.synchronize()
|
||||
|
||||
@@ -204,7 +204,7 @@ def _run_verify_block():
|
||||
),
|
||||
):
|
||||
assert isinstance(impl, AiterMLAImpl)
|
||||
impl.forward_mqa((q_nope, q_pe), kv_cache, metadata, layer=None) # type: ignore[arg-type] # Spy decode path does not read layer.
|
||||
impl.forward_mqa((q_nope, q_pe), kv_cache, metadata, layer=None)
|
||||
|
||||
return metadata, captured
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ def _build_prefill_metadata(
|
||||
|
||||
builder = object.__new__(AiterMLAMetadataBuilder)
|
||||
builder.num_heads = num_heads
|
||||
builder.mla_dims = SimpleNamespace(v_head_dim=V_HEAD_DIM) # type: ignore[assignment]
|
||||
builder.mla_dims = SimpleNamespace(v_head_dim=V_HEAD_DIM)
|
||||
builder._init_fp8_prefill_ps_buffers(
|
||||
max_num_reqs=len(seq_lens),
|
||||
max_prefill_qlen=max_q,
|
||||
@@ -136,7 +136,7 @@ def _build_prefill_metadata(
|
||||
prefill = SimpleNamespace(query_start_loc=qo_indptr, max_query_len=max_q)
|
||||
metadata = SimpleNamespace(prefill=prefill, num_decodes=0)
|
||||
common = SimpleNamespace(query_start_loc_cpu=qo_indptr_cpu)
|
||||
builder._build_fp8_prefill_ps_metadata(metadata, common) # type: ignore[arg-type]
|
||||
builder._build_fp8_prefill_ps_metadata(metadata, common)
|
||||
return metadata, total_q, builder
|
||||
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ def test_sparse_mla_sink_matches_ragged_reference(
|
||||
SimpleNamespace(_q_scale=q_scale, _k_scale=kv_scale),
|
||||
q,
|
||||
kv,
|
||||
metadata, # type: ignore[arg-type]
|
||||
metadata,
|
||||
)
|
||||
kv_flat = kv_ref[:, 0]
|
||||
references = []
|
||||
@@ -244,7 +244,7 @@ def test_sparse_mla_sink_rejects_unsupported_aiter_dtypes(
|
||||
SimpleNamespace(_q_scale=None, _k_scale=None),
|
||||
torch.empty(1, 16, Q_HEAD_DIM, dtype=q_dtype),
|
||||
torch.empty(1, 1, Q_HEAD_DIM, dtype=kv_dtype),
|
||||
metadata, # type: ignore[arg-type]
|
||||
metadata,
|
||||
)
|
||||
|
||||
|
||||
@@ -384,7 +384,7 @@ def test_sparse_mla_sink_matches_dense_attention_with_empty_rows_and_paged_cache
|
||||
paged_kv_indices=torch.tensor(indices, dtype=torch.int32, device="cuda"),
|
||||
paged_kv_indptr=lengths.cumsum(0).to(device="cuda", dtype=torch.int32),
|
||||
)
|
||||
impl = ROCMAiterMLASparseImpl.__new__(ROCMAiterMLASparseImpl) # type: ignore[arg-type]
|
||||
impl = ROCMAiterMLASparseImpl.__new__(ROCMAiterMLASparseImpl)
|
||||
impl.num_heads = num_heads
|
||||
impl.head_size = head_dim
|
||||
impl.kv_lora_rank = value_dim
|
||||
@@ -441,9 +441,9 @@ def test_sparse_mla_backend_resolves_only_contiguous_layer_layouts(monkeypatch,
|
||||
]
|
||||
if layout == "BLNHC":
|
||||
with pytest.raises(ValueError, match="does not satisfy"):
|
||||
resolve_kv_cache_layout(config, supported) # type: ignore[arg-type]
|
||||
resolve_kv_cache_layout(config, supported)
|
||||
else:
|
||||
assert resolve_kv_cache_layout(config, supported).name == layout # type: ignore[arg-type]
|
||||
assert resolve_kv_cache_layout(config, supported).name == layout
|
||||
|
||||
|
||||
@pytest.mark.parametrize("dtype", [torch.bfloat16, torch.float16])
|
||||
@@ -494,7 +494,7 @@ def test_sparse_mla_sink_forward_mqa_preserves_split_query(dtype):
|
||||
actual, _ = impl.forward_mqa(
|
||||
(q[..., :V_HEAD_DIM], q[..., V_HEAD_DIM:]),
|
||||
kv,
|
||||
metadata, # type: ignore[arg-type]
|
||||
metadata,
|
||||
SimpleNamespace(_q_scale=None, _k_scale=None),
|
||||
)
|
||||
references = [
|
||||
|
||||
@@ -39,10 +39,10 @@ def _make_builder():
|
||||
topk_tokens = 4
|
||||
|
||||
builder.device = torch.device("cpu")
|
||||
builder.kv_cache_spec = SimpleNamespace(block_size=1) # type: ignore[assignment]
|
||||
builder.kv_cache_spec = SimpleNamespace(block_size=1)
|
||||
builder.model_dtype = torch.bfloat16
|
||||
builder.kv_cache_dtype = "fp8"
|
||||
builder.mla_dims = SimpleNamespace(kv_lora_rank=512, qk_rope_head_dim=64) # type: ignore[assignment]
|
||||
builder.mla_dims = SimpleNamespace(kv_lora_rank=512, qk_rope_head_dim=64)
|
||||
builder.topk_tokens = topk_tokens
|
||||
builder.req_id_per_token_buffer = torch.zeros(
|
||||
max_num_batched_tokens, dtype=torch.int32, device="cpu"
|
||||
|
||||
@@ -227,9 +227,7 @@ def _decode_metadata(case, rows, ratio, query_lens):
|
||||
num_decode_tokens=len(rows),
|
||||
num_prefills=0,
|
||||
num_prefill_tokens=0,
|
||||
decode=types.SimpleNamespace( # type: ignore[arg-type]
|
||||
block_table=block_table, seq_lens=lens[:, None]
|
||||
),
|
||||
decode=types.SimpleNamespace(block_table=block_table, seq_lens=lens[:, None]),
|
||||
decode_row_lens=lens,
|
||||
decode_block_ends=(lens + CAND_BLOCK - 1) // CAND_BLOCK,
|
||||
decode_native=native,
|
||||
@@ -280,7 +278,7 @@ def _prefill_metadata(
|
||||
num_decode_tokens=0,
|
||||
num_prefills=len(case.seq_lens),
|
||||
num_prefill_tokens=len(rows),
|
||||
prefill=types.SimpleNamespace(chunks=chunks), # type: ignore[arg-type]
|
||||
prefill=types.SimpleNamespace(chunks=chunks),
|
||||
prefill_plans=plans,
|
||||
gather_launches=plan_gather_launches(chunks, plans, gather_rows),
|
||||
)
|
||||
|
||||
@@ -955,7 +955,7 @@ def test_rocm_capture_metadata_sets_adaptive_marker(monkeypatch) -> None:
|
||||
)
|
||||
builder = object.__new__(rocm_mod.DeepseekV4ROCMAiterMLASparseMetadataBuilder)
|
||||
|
||||
actual = builder.build_for_cudagraph_capture(SimpleNamespace()) # type: ignore[arg-type] # Patched base method ignores metadata.
|
||||
actual = builder.build_for_cudagraph_capture(SimpleNamespace())
|
||||
|
||||
assert actual is metadata
|
||||
assert actual.for_cudagraph_capture is _on_gfx950()
|
||||
@@ -1563,7 +1563,7 @@ def test_dsv4_adaptive_mla_swa_metadata_graph_replay(monkeypatch) -> None:
|
||||
"sliding_window": window_size,
|
||||
},
|
||||
)
|
||||
vllm_config.speculative_config = SimpleNamespace( # type: ignore[assignment]
|
||||
vllm_config.speculative_config = SimpleNamespace(
|
||||
num_speculative_tokens=upper_query_len - 1,
|
||||
parallel_drafting=False,
|
||||
enable_adaptive_verification=True,
|
||||
|
||||
@@ -176,7 +176,7 @@ def test_forward_core_split_matches_unified(
|
||||
builder = GDNAttentionMetadataBuilder(
|
||||
# GDNAttentionMetadataBuilder declares kv_cache_spec as AttentionSpec but
|
||||
# asserts isinstance(kv_cache_spec, MambaSpec). MambaSpec is correct here.
|
||||
kv_cache_spec=MambaSpec( # type: ignore[arg-type]
|
||||
kv_cache_spec=MambaSpec(
|
||||
block_size=BLOCK_SIZE, shapes=((16, 64),), dtypes=(torch.float16,)
|
||||
),
|
||||
layer_names=[PREFIX],
|
||||
|
||||
@@ -538,7 +538,7 @@ def run_8_bit(
|
||||
assert num_local_experts is not None
|
||||
return run_with_expert_maps(
|
||||
num_experts,
|
||||
num_local_experts, # type: ignore[arg-type]
|
||||
num_local_experts,
|
||||
quant_config,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
@@ -1724,7 +1724,7 @@ def test_rocm_mxfp4_moe_oracle(
|
||||
w13_conv, w2_conv, w13_scale_conv, w2_scale_conv, w13_bias_conv, w2_bias_conv = (
|
||||
convert_gpt_oss_weight_to_mxfp4_moe_kernel_format(
|
||||
mxfp4_backend=backend,
|
||||
layer=layer, # type: ignore[arg-type]
|
||||
layer=layer,
|
||||
w13_weight=w13_quant,
|
||||
w2_weight=w2_quant,
|
||||
w13_weight_scale=w13_scale,
|
||||
|
||||
@@ -259,7 +259,7 @@ def test_w8a8_block_fp8_torch_scaled_mm_matmul():
|
||||
stub = BlockWiseTorchFP8ScaledMMLinearKernel.__new__(
|
||||
BlockWiseTorchFP8ScaledMMLinearKernel
|
||||
)
|
||||
stub.config = types.SimpleNamespace(out_dtype=out_dtype) # type: ignore[assignment]
|
||||
stub.config = types.SimpleNamespace(out_dtype=out_dtype)
|
||||
out = stub.apply_block_scaled_mm(
|
||||
A_fp8_cuda.cuda(), B_fp8.cuda(), As_cuda.cuda(), Bs.cuda()
|
||||
)
|
||||
|
||||
@@ -208,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, # type: ignore[arg-type]
|
||||
b_group_size=group_size,
|
||||
b_channel_scales=tensors.w_ch_s,
|
||||
a_token_scales=tensors.w_tok_s,
|
||||
)
|
||||
|
||||
@@ -525,15 +525,13 @@ def test_check_marlin_supports_layer_allow_tile_padding():
|
||||
)
|
||||
|
||||
# Tile-misaligned but group-aligned: rejected strictly, allowed w/ padding
|
||||
layer: LinearBase = _FakeLinear( # type: ignore[assignment]
|
||||
4640, 512, input_size=2048
|
||||
)
|
||||
layer: LinearBase = _FakeLinear(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) # type: ignore[assignment]
|
||||
layer = _FakeLinear(4608, 4672, input_size=18688)
|
||||
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, # type: ignore[arg-type]
|
||||
**config_kwargs,
|
||||
)
|
||||
|
||||
supported, reason = Nvfp4QuantizationEmulationTritonExperts.is_supported_config(
|
||||
|
||||
Reference in New Issue
Block a user