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:
Harry Mellor
2026-09-30 15:18:50 +00:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 17e9295dd5
commit fc2c801ad9
131 changed files with 402 additions and 409 deletions
+5
View File
@@ -117,6 +117,11 @@ ignore_missing_imports = true
check_untyped_defs = true
follow_imports = "silent"
[[tool.mypy.overrides]]
module = "tests.*"
disable_error_code = ["arg-type", "assignment"]
enable_error_code = ["method-assign"]
[tool.pytest.ini_options]
markers = [
"slow_test",
+2 -2
View File
@@ -271,7 +271,7 @@ def test_bfcl_prompt_len_includes_tools(tmp_path: Path) -> None:
args.num_prompts = 1
with _patch_hf_api(fake_download):
samples = get_samples(args, fake) # type: ignore[arg-type]
samples = get_samples(args, fake)
assert len(samples) == 1
assert captured["tools"] is not None, (
@@ -311,7 +311,7 @@ def test_bfcl_prompt_len_falls_back_when_tokenizer_rejects_tools(
args.num_prompts = 1
with _patch_hf_api(fake_download):
samples = get_samples(args, _LegacyTokenizer()) # type: ignore[arg-type]
samples = get_samples(args, _LegacyTokenizer())
assert len(samples) == 1
assert samples[0].prompt_len > 0
@@ -58,7 +58,7 @@ def test_chat_template_kwargs_forwarded(tmp_path: Path) -> None:
_write_one(jsonl)
tok = _RecordingTokenizer()
get_samples(_args(str(jsonl), {"thinking": True}), tok) # type: ignore[arg-type]
get_samples(_args(str(jsonl), {"thinking": True}), tok)
assert tok.captured_kwargs == {"thinking": True}
@@ -70,6 +70,6 @@ def test_chat_template_kwargs_default_is_noop(tmp_path: Path) -> None:
_write_one(jsonl)
tok = _RecordingTokenizer()
get_samples(_args(str(jsonl), None), tok) # type: ignore[arg-type]
get_samples(_args(str(jsonl), None), tok)
assert tok.captured_kwargs == {}
@@ -285,7 +285,7 @@ def test_async_tp_pass_requires_full_graph_compilation():
]
async_tp_pass = object.__new__(AsyncTPPass)
async_tp_pass.compilation_config = vllm_config.compilation_config # type: ignore[assignment]
async_tp_pass.compilation_config = vllm_config.compilation_config
with pytest.raises(
AssertionError, match="AsyncTPPass requires full-graph compilation"
@@ -111,7 +111,7 @@ def test_fused_ar_workspace_hidden_dim(
target_hidden: int, draft_hidden: int | None, expected: int
):
config = _make_workspace_hidden_config(target_hidden, draft_hidden)
assert _fused_ar_workspace_hidden_dim(config) == expected # type: ignore[arg-type]
assert _fused_ar_workspace_hidden_dim(config) == expected
def test_fused_ar_workspace_hidden_dim_spec_without_draft():
@@ -120,7 +120,7 @@ def test_fused_ar_workspace_hidden_dim_spec_without_draft():
model_config=SimpleNamespace(get_hidden_size=lambda: 2048),
speculative_config=SimpleNamespace(draft_model_config=None),
)
assert _fused_ar_workspace_hidden_dim(config) == 2048 # type: ignore[arg-type]
assert _fused_ar_workspace_hidden_dim(config) == 2048
class TestAllReduceRMSNormModel(torch.nn.Module):
@@ -222,7 +222,7 @@ def test_sequence_parallelism_pass_requires_full_graph_compilation():
]
sequence_parallelism_pass = object.__new__(SequenceParallelismPass)
sequence_parallelism_pass.compilation_config = vllm_config.compilation_config # type: ignore[assignment]
sequence_parallelism_pass.compilation_config = vllm_config.compilation_config
sequence_parallelism_pass.min_token_num = 1
with pytest.raises(
+1 -1
View File
@@ -28,7 +28,7 @@ def test_bad_callable():
pass_manager.configure(config)
with pytest.raises(AssertionError):
pass_manager.add(simple_callable) # type: ignore[arg-type]
pass_manager.add(simple_callable)
# Pass that inherits from InductorPass
@@ -331,7 +331,7 @@ def test_fusion_silu_and_mul_quant(
backend = TestBackend(*passes)
model = model_class(
hidden_size=hidden_size,
force_kernel=force_kernel, # type: ignore[arg-type]
force_kernel=force_kernel,
x=x,
dtype=dtype,
)
+2 -2
View File
@@ -133,7 +133,7 @@ def test_get_diff_sampling_param_includes_penalties():
},
)
diff = ModelConfig.get_diff_sampling_param(fake) # type: ignore[arg-type]
diff = ModelConfig.get_diff_sampling_param(fake)
assert diff["presence_penalty"] == 1.5
assert diff["frequency_penalty"] == 0.5
@@ -161,7 +161,7 @@ def test_generation_config_penalties_survive_diff_sampling_filter():
},
)
diff = ModelConfig.get_diff_sampling_param(fake) # type: ignore[arg-type]
diff = ModelConfig.get_diff_sampling_param(fake)
assert diff["presence_penalty"] == 1.1
assert diff["frequency_penalty"] == 0.7
+5 -5
View File
@@ -40,18 +40,18 @@ def test_supports_multimodal_inputs(model_id, limit_mm_per_prompt, expected):
def test_mm_encoder_attn_backend_str_conversion():
config = MultiModalConfig(mm_encoder_attn_backend="FLASH_ATTN") # type: ignore[arg-type]
config = MultiModalConfig(mm_encoder_attn_backend="FLASH_ATTN")
assert config.mm_encoder_attn_backend == AttentionBackendEnum.FLASH_ATTN
def test_mm_encoder_attn_backend_invalid():
with pytest.raises(ValueError):
MultiModalConfig(mm_encoder_attn_backend="not_a_backend") # type: ignore[arg-type]
MultiModalConfig(mm_encoder_attn_backend="not_a_backend")
def test_mm_hasher_algorithm_invalid():
with pytest.raises(ValueError, match="mm_hasher_algorithm"):
MultiModalConfig(mm_hasher_algorithm="md5") # type: ignore[arg-type]
MultiModalConfig(mm_hasher_algorithm="md5")
def test_mm_encoder_attn_backend_hash_updates():
@@ -560,7 +560,7 @@ def _resolve_mm_processor_device(
"""Run the `auto` resolution and report where the processor ended up."""
mm_config = MultiModalConfig(
mm_processor_kwargs={} if device is None else {"device": device},
mm_tensor_ipc=mm_tensor_ipc, # type: ignore[arg-type]
mm_tensor_ipc=mm_tensor_ipc,
)
model_config = MagicMock(spec=ModelConfig)
model_config.multimodal_config = mm_config
@@ -662,7 +662,7 @@ def _resolve_mm_video_decode_device(
the resulting video media IO kwargs."""
mm_config = MultiModalConfig(
mm_processor_kwargs={} if device is None else {"device": device},
mm_tensor_ipc=mm_tensor_ipc, # type: ignore[arg-type]
mm_tensor_ipc=mm_tensor_ipc,
media_io_kwargs={} if video_kwargs is None else {"video": dict(video_kwargs)},
)
model_config = MagicMock(spec=ModelConfig)
+1 -1
View File
@@ -1163,7 +1163,7 @@ class VllmRunner:
output_logprobs = sample.logprobs
if include_prompt_token_ids:
outputs.append(
( # type: ignore[arg-type]
(
output_ids,
output_str,
output_logprobs,
@@ -1447,7 +1447,7 @@ class TestDetectMergeInlineSystem:
model_config=None,
)
assert (
AnthropicServingMessages._should_merge_inline_system(online_renderer) # type: ignore[arg-type]
AnthropicServingMessages._should_merge_inline_system(online_renderer)
is expected
)
assert mock_logger.warning_once.called is expected
@@ -29,7 +29,7 @@ from vllm.entrypoints.cohere.cohere_chat_message import (
class TestCitationSource:
def test_invalid_type_rejected(self):
with pytest.raises(ValidationError):
CitationSource(type="other") # type: ignore[arg-type]
CitationSource(type="other")
def test_none_fields_excluded_from_dump(self):
s = CitationSource(type="document", id="d1")
@@ -65,7 +65,7 @@ class TestCitationSource:
class TestCitation:
def test_invalid_type_rejected(self):
with pytest.raises(ValidationError):
Citation(type="OTHER") # type: ignore[arg-type]
Citation(type="OTHER")
def test_dump_excludes_none_fields(self):
c = Citation(start=0, end=5, text="hello")
+2 -2
View File
@@ -136,7 +136,7 @@ class TestCohereChatV2Response:
with pytest.raises(ValidationError):
CohereChatV2Response(
id="r1",
finish_reason="NOT_A_REASON", # type: ignore[arg-type]
finish_reason="NOT_A_REASON",
message=msg,
)
@@ -246,5 +246,5 @@ class TestStreamingEventTypeField:
MessageStartEvent(
id="a",
delta={"message": {"role": "assistant"}},
type="other", # type: ignore[arg-type]
type="other",
)
@@ -308,7 +308,7 @@ def test_external_process_monitoring(api_server_args):
try:
wait_for_completion_or_failure(
api_server_manager=manager,
coordinator=mock_coordinator, # type: ignore[arg-type]
coordinator=mock_coordinator,
)
except Exception as e:
result["exception"] = e
@@ -377,7 +377,7 @@ def test_gather_actual_addresses_end_to_end():
manager = APIServerProcessManager(
listen_address=f"tcp://{host}:0",
sock=sock,
args="test_args", # type: ignore[arg-type]
args="test_args",
num_servers=num_servers,
input_addresses=placeholder_inputs,
output_addresses=placeholder_outputs,
@@ -424,7 +424,7 @@ def test_gather_actual_addresses_child_crash_before_report():
manager = APIServerProcessManager(
listen_address=f"tcp://{host}:0",
sock=sock,
args="test_args", # type: ignore[arg-type]
args="test_args",
num_servers=num_servers,
input_addresses=placeholder_inputs,
output_addresses=placeholder_outputs,
@@ -14,7 +14,7 @@ from vllm.outputs import RequestOutput
def _make_mock_llm() -> LLM:
llm = object.__new__(LLM)
llm.model_config = SimpleNamespace( # type: ignore[assignment]
llm.model_config = SimpleNamespace(
runner_type="generate", enable_prompt_embeds=False
)
return llm
@@ -225,7 +225,7 @@ def online_renderer(model_config: MockModelConfig, request) -> OnlineRenderer:
renderer.tokenizer = MagicMock()
return OnlineRenderer(
model_config=model_config, # type: ignore[arg-type]
model_config=model_config,
renderer=renderer,
request_logger=None,
chat_template=None,
@@ -411,7 +411,7 @@ class TestChunkedEmbeddingProcessing:
@classmethod
def _make_handler(cls):
handler = object.__new__(EmbedIOProcessor)
handler.model_config = cls._FakeModelConfig() # type: ignore[assignment]
handler.model_config = cls._FakeModelConfig()
handler.enable_chunked_processing = True
return handler
@@ -47,7 +47,7 @@ def llm_reranker_processor() -> CrossEncoderIOProcessor:
)
processor = CrossEncoderIOProcessor.__new__(CrossEncoderIOProcessor)
processor.model_config = SimpleNamespace(enable_prompt_embeds=False) # type: ignore[assignment]
processor.model_config = SimpleNamespace(enable_prompt_embeds=False)
processor.tokenizer = TokenizersBackend(
tokenizer_object=backend,
unk_token="[UNK]",
@@ -96,7 +96,7 @@ def test_token_type_ids_stay_aligned_with_a_truncated_padded_prompt():
)
processed_prompt = tok_params.apply_post_tokenization(
tokenizer, # type: ignore[arg-type]
tokenizer,
prompt,
)
assert "prompt_token_ids" in processed_prompt
@@ -77,10 +77,8 @@ def offline_processor_and_context():
backend.pre_tokenizer = pre_tokenizers.WhitespaceSplit()
proc = JinaRankingIOProcessor.__new__(JinaRankingIOProcessor)
proc.tokenizer = TokenizersBackend(tokenizer_object=backend)
proc.model_config = SimpleNamespace( # type: ignore[assignment]
max_model_len=1024, is_encoder_decoder=False
)
proc.renderer = SimpleNamespace( # type: ignore[assignment]
proc.model_config = SimpleNamespace(max_model_len=1024, is_encoder_decoder=False)
proc.renderer = SimpleNamespace(
default_cmpl_tok_params=TokenizeParams(max_total_tokens=1024)
)
ctx = OfflineScoringInputsContext(
@@ -53,8 +53,8 @@ def test_rejects_mismatched_lora_requests(processor: PoolingIOProcessor):
def test_rejects_conflicting_pooling_task(processor: PoolingIOProcessor):
processor.model_config = SimpleNamespace(is_encoder_decoder=False) # type: ignore[assignment]
processor.renderer = SimpleNamespace( # type: ignore[assignment] # Tokenization defaults only.
processor.model_config = SimpleNamespace(is_encoder_decoder=False)
processor.renderer = SimpleNamespace(
default_cmpl_tok_params=TokenizeParams(max_total_tokens=None)
)
ctx = OfflineEncodeInputsContext(
@@ -87,7 +87,7 @@ def task_routes(request, monkeypatch) -> tuple[str, list[tuple[str, list[str]]]]
args,
app,
supported_tasks=(task,),
model_config=MockModelConfig(), # type: ignore[arg-type]
model_config=MockModelConfig(),
)
routes = get_all_http_routes(app)
@@ -107,7 +107,7 @@ async def test_tokenize_chat(
conversation=conversation,
tokenize=False,
)
tokens = tokenizer.encode(prompt, add_special_tokens=add_special) # type: ignore[arg-type]
tokens = tokenizer.encode(prompt, add_special_tokens=add_special)
response = requests.post(
server.url_for("tokenize"),
@@ -176,7 +176,7 @@ async def test_tokenize_chat_with_tools(
tools=tools,
tokenize=False,
)
tokens = tokenizer.encode(prompt, add_special_tokens=add_special) # type: ignore[arg-type]
tokens = tokenizer.encode(prompt, add_special_tokens=add_special)
response = requests.post(
server.url_for("tokenize"),
@@ -47,7 +47,7 @@ def test_sanitize_handles_falsy_inputs() -> None:
assert _sanitize_transcription_user_text("") == ""
# The dataclass default for ``response_prefix`` is the empty string;
# the sanitizer must accept that without exception or extra work.
assert _sanitize_transcription_user_text(None) == "" # type: ignore[arg-type]
assert _sanitize_transcription_user_text(None) == ""
def test_sanitize_is_idempotent() -> None:
@@ -216,7 +216,7 @@ def video_url():
@pytest.fixture(scope="module")
def audio_url():
audio = AudioAsset("mary_had_lamb")
return encode_audio_url(*audio.audio_and_sample_rate) # type: ignore[arg-type]
return encode_audio_url(*audio.audio_and_sample_rate)
def _assert_mm_data_is_image_input(
@@ -3194,5 +3194,5 @@ def test_validate_chat_template_rejects_invalid_type():
with pytest.raises(
VLLMValidationError, match="not a valid chat template type"
) as exc_info:
validate_chat_template(123) # type: ignore[arg-type]
validate_chat_template(123)
assert exc_info.value.parameter == "chat_template"
+1 -1
View File
@@ -149,7 +149,7 @@ def test_activate_logs_info():
def test_activate_rejects_unknown_mode():
with pytest.raises(ValueError, match="Unsupported JIT monitor mode"):
jit_monitor.activate(mode="panic") # type: ignore[arg-type]
jit_monitor.activate(mode="panic")
def test_activate_without_triton():
@@ -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)
+1 -1
View File
@@ -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,
+1 -1
View File
@@ -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],
+1 -1
View File
@@ -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,
)
+1 -1
View File
@@ -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,
+1 -1
View File
@@ -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(
@@ -413,7 +413,7 @@ def test_deepseek_v4_shared_expert_fse_uses_mtp_quantization_config_prefix(
)
compatible, reason = is_shared_expert_quant_fse_compatible(
DeepseekV4Config(), # type: ignore[arg-type]
DeepseekV4Config(),
"model.layers.2.ffn.experts",
"model.layers.2.ffn.shared_experts",
)
@@ -824,7 +824,7 @@ def test_models_fse_init(
model_type, quantization_config
)
vllm_config = VllmConfig()
vllm_config.model_config = SimpleNamespace( # type: ignore[assignment]
vllm_config.model_config = SimpleNamespace(
hf_config=config,
hf_text_config=config,
dtype=torch.bfloat16,
@@ -893,7 +893,7 @@ def test_models_fse_init(
DeepSeekV4MTP,
)
vllm_config.speculative_config = SimpleNamespace( # type: ignore[assignment]
vllm_config.speculative_config = SimpleNamespace(
draft_model_config=SimpleNamespace(hf_config=config),
method="mtp",
parallel_drafting=False,
@@ -46,7 +46,7 @@ def test_sparse_attention_refreshes_batch_state_inside_eager_segment(
with pytest.raises(BatchStateRefreshed):
DeepseekV32Attention._sparse_indexer_and_attn(
layer, # type: ignore[arg-type]
layer,
torch.empty(1, dtype=torch.long),
torch.empty(1, 1),
torch.empty(1, 1, 1),
@@ -80,7 +80,7 @@ def make_indexer_metadata(
num_decode_tokens=num_decode_tokens,
num_prefills=num_prefills,
num_prefill_tokens=num_prefill_tokens,
prefill=SimpleNamespace(chunks=[]) if num_prefills else None, # type: ignore[arg-type]
prefill=SimpleNamespace(chunks=[]) if num_prefills else None,
)
@@ -129,7 +129,7 @@ def test_short_prefill_updates_k_cache_before_scoring_decision(
slot_mapping=slot_mapping,
)
if indexer_metadata.num_decodes:
indexer_metadata.decode = object() # type: ignore[assignment]
indexer_metadata.decode = object()
mla_metadata = make_mla_metadata(
use_dense_mha=batch_kind != "force_mqa",
num_decode_tokens=mla_num_decode_tokens,
@@ -307,7 +307,7 @@ def test_deepseek_v32_dispatches_selected_mha(
output = torch.empty(2, 2)
DeepseekV32Attention._sparse_indexer_and_attn(
layer, # type: ignore[arg-type]
layer,
torch.arange(2),
torch.empty(2, 2),
q_nope,
@@ -224,11 +224,11 @@ class TestResolveClassifierActFn:
model_config = SimpleNamespace(
hf_config=SimpleNamespace(num_labels=3, problem_type="")
)
result = resolve_classifier_act_fn(model_config, act_fn=None) # type: ignore[arg-type]
result = resolve_classifier_act_fn(model_config, act_fn=None)
assert isinstance(result, PoolerClassify)
assert result.num_labels == 3
def test_passes_through_provided_act_fn(self):
custom = PoolerIdentity()
result = resolve_classifier_act_fn(None, act_fn=custom) # type: ignore[arg-type]
result = resolve_classifier_act_fn(None, act_fn=custom)
assert result is custom
@@ -320,7 +320,7 @@ def test_dispatch_seq_cls_honors_token_pooling_type(tok_pooling_type):
),
)
classifier = torch.nn.Linear(4, 3)
with set_current_vllm_config(config): # type: ignore[arg-type]
with set_current_vllm_config(config):
pooler = DispatchPooler.for_seq_cls(pooler_config, classifier=classifier)
token_ids = [[2, 99, 3, 99], [4, 99], [5, 6]]
@@ -36,7 +36,7 @@ try:
import tensorizer
from tensorizer import EncryptionParams
except ImportError:
tensorizer = PlaceholderModule("tensorizer") # type: ignore[assignment]
tensorizer = PlaceholderModule("tensorizer")
EncryptionParams = tensorizer.placeholder_attr("EncryptionParams")
@@ -368,4 +368,4 @@ def test_ipc_loader_copy_mode_reports_no_external_weight_memory():
load_format="ipc_cache", model_loader_extra_config={"mode": "copy"}
)
loader = IpcModelLoader(copy_mode)
assert loader.get_external_weight_memory(None) == 0 # type: ignore[arg-type]
assert loader.get_external_weight_memory(None) == 0
@@ -259,7 +259,7 @@ def test_mistral_function_calling(vllm_runner, model: str, dtype: str) -> None:
model_output = outputs[0].outputs[0].text.strip()
assert model_output.startswith(tool_parser.bot_token), model_output
parsed_message = tool_parser.extract_tool_calls(model_output, None) # type: ignore[arg-type]
parsed_message = tool_parser.extract_tool_calls(model_output, None)
assert parsed_message.tools_called
@@ -302,7 +302,7 @@ def test_mistral_function_call_nested_json():
model_output = f"{parser.bot_token}get_current_weather{json.dumps(args_dict)}"
parsed = parser.extract_tool_calls(model_output, None) # type: ignore[arg-type]
parsed = parser.extract_tool_calls(model_output, None)
# Assertions: the tool call is detected and the full nested JSON is parsed
# without truncation.
@@ -335,7 +335,7 @@ def test_mistral_function_call_nested_json():
]
)
parsed = parser.extract_tool_calls(model_output, None) # type: ignore[arg-type]
parsed = parser.extract_tool_calls(model_output, None)
# Assertions: the tool call is detected and the full nested JSON is parsed
# without truncation.
@@ -1193,7 +1193,7 @@ def voxtral_patch_hf_runner(hf_model: "HfRunner") -> "HfRunner":
output.sequences = output.sequences[:, prompt_len:]
return output
hf_model.get_inputs = patched_get_inputs # type: ignore[method-assign, assignment]
hf_model.get_inputs = patched_get_inputs # type: ignore[method-assign]
hf_model.model.generate = patched_generate # type: ignore[method-assign]
return hf_model
+1 -1
View File
@@ -132,7 +132,7 @@ def test_models(
_run_test(
hf_runner,
vllm_runner,
input_cases, # type: ignore[arg-type]
input_cases,
model,
dtype=dtype,
)
@@ -190,7 +190,7 @@ def test_models(
_run_test(
hf_runner,
vllm_runner,
input_cases, # type: ignore[arg-type]
input_cases,
model,
dtype=dtype,
)
@@ -149,7 +149,7 @@ def test_models(
_run_test(
hf_runner,
vllm_runner,
input_cases, # type: ignore[arg-type]
input_cases,
model,
dtype=dtype,
)
@@ -106,7 +106,7 @@ def test_merge_and_resolve_mm_processor_kwargs_preserves_request_alias_precedenc
mm_device_do_normalize=False,
)
model_config = SimpleNamespace(get_multimodal_config=lambda: mm_config)
ctx = InputProcessingContext(model_config, tokenizer=None) # type: ignore[arg-type]
ctx = InputProcessingContext(model_config, tokenizer=None)
info = Qwen2VLProcessingInfo(ctx)
monkeypatch.setattr(
info,
@@ -236,7 +236,7 @@ def test_get_vision_info_reads_merged_modality_scope(
do_resize=False,
image_processor=image_processor,
mm_kwargs={},
modality=modality, # type: ignore[arg-type]
modality=modality,
)
assert seen == [merged[scope]]
+2 -2
View File
@@ -260,7 +260,7 @@ def test_quantization(
model,
model_impl="auto",
enforce_eager=True,
**quantization_kwargs, # type: ignore[arg-type]
**quantization_kwargs,
) as vllm_model:
vllm_outputs = vllm_model.generate_greedy_logprobs(
example_prompts, max_tokens=max_tokens, num_logprobs=num_logprobs
@@ -270,7 +270,7 @@ def test_quantization(
model,
model_impl="transformers",
enforce_eager=True,
**quantization_kwargs, # type: ignore[arg-type]
**quantization_kwargs,
) as vllm_model:
model_config = vllm_model.llm.llm_engine.model_config
assert model_config.using_transformers_backend()
+1 -1
View File
@@ -385,7 +385,7 @@ def test_pynvvideocodec_unrelated_error_propagates(
PyNvVideoCodecVideoBackendMixin.decode_frames_pynvvideocodec(
None,
b"video",
None, # type: ignore[arg-type] # Fails before target metadata is used.
None,
)
assert exc_info.value is original_error
+1 -1
View File
@@ -179,7 +179,7 @@ def test_audio_resampler_invalid_method(dummy_audio):
# Validated eagerly so a bad method fails at construction, not on the
# first audio request.
with pytest.raises(ValueError, match="Invalid resampling method"):
AudioResampler(target_sr=22050, method="invalid") # type: ignore[arg-type]
AudioResampler(target_sr=22050, method="invalid")
def test_audio_resampler_no_target_sr(dummy_audio):
+12 -12
View File
@@ -276,14 +276,14 @@ def test_oversized_item_is_served_uncached():
item = MultiModalKwargsItem.dummy(nbytes=4096)
small = MultiModalKwargsItem.dummy(nbytes=64)
p0_only = MultiModalProcessorOnlyCache(model_config) # type: ignore[arg-type]
p0_only = MultiModalProcessorOnlyCache(model_config)
assert p0_only.get_and_update_item((item, []), "big")[0] is item
assert not p0_only.is_cached_item("big")
assert p0_only.get_and_update_item((small, []), "small")[0] is small
assert p0_only.is_cached_item("small")
p0 = LruKeyReplicatedSenderCache(model_config) # type: ignore[arg-type]
p1 = LruKeyReplicatedReceiverCache(model_config) # type: ignore[arg-type]
p0 = LruKeyReplicatedSenderCache(model_config)
p1 = LruKeyReplicatedReceiverCache(model_config)
assert item is not None
assert p0.get_and_update_item((item, []), "big")[0] is item
assert not p0.is_cached_item("big")
@@ -304,8 +304,8 @@ def test_mm_cache_miss_raises_and_recovers():
model or network.
"""
model_config = _StubModelConfig(mm_processor_cache_gb=1)
p0 = LruKeyReplicatedSenderCache(model_config) # type: ignore[arg-type]
p1 = LruKeyReplicatedReceiverCache(model_config) # type: ignore[arg-type]
p0 = LruKeyReplicatedSenderCache(model_config)
p1 = LruKeyReplicatedReceiverCache(model_config)
mm_hash = "image_A"
item = MultiModalKwargsItem.dummy(nbytes=64)
@@ -348,7 +348,7 @@ def test_receiver_cache_replaces_stale_item_when_payload_resent():
and kills EngineCore. Prefer the fresh payload and keep it for later hits.
"""
model_config = _StubModelConfig(mm_processor_cache_gb=1)
p1 = LruKeyReplicatedReceiverCache(model_config) # type: ignore[arg-type]
p1 = LruKeyReplicatedReceiverCache(model_config)
small = MultiModalKwargsItem.dummy(nbytes=64)
large = MultiModalKwargsItem.dummy(nbytes=256)
mm_hash = "shared-id"
@@ -361,7 +361,7 @@ def test_receiver_cache_replaces_stale_item_when_payload_resent():
def test_receiver_cache_features_keep_resent_payload():
"""EngineCore updates features through get_and_update_features."""
model_config = _StubModelConfig(mm_processor_cache_gb=1)
p1 = LruKeyReplicatedReceiverCache(model_config) # type: ignore[arg-type]
p1 = LruKeyReplicatedReceiverCache(model_config)
small = MultiModalKwargsItem.dummy(nbytes=64)
large = MultiModalKwargsItem.dummy(nbytes=256)
mm_hash = "shared-id"
@@ -394,7 +394,7 @@ def test_mm_cache_miss_batches_all_drifted_hashes():
non-drifted items in the same request are still ingested.
"""
model_config = _StubModelConfig(mm_processor_cache_gb=1)
p1 = LruKeyReplicatedReceiverCache(model_config) # type: ignore[arg-type]
p1 = LruKeyReplicatedReceiverCache(model_config)
item = MultiModalKwargsItem.dummy(nbytes=64)
def _feature(
@@ -442,8 +442,8 @@ def test_shm_receiver_handles_prefix_covered_items(monkeypatch):
parallel_config=SimpleNamespace(world_size=1),
model_config=_StubModelConfig(mm_processor_cache_gb=4 * MiB_bytes / GiB_bytes),
)
p0 = ShmObjectStoreSenderCache(vllm_config) # type: ignore[arg-type]
p1 = ShmObjectStoreReceiverCache(vllm_config, mp.Lock()) # type: ignore[arg-type]
p0 = ShmObjectStoreSenderCache(vllm_config)
p1 = ShmObjectStoreReceiverCache(vllm_config, mp.Lock())
def _feature(
mm_hash: str, data: MultiModalKwargsItem | None
@@ -1082,9 +1082,9 @@ async def test_release_kv_cache_resends_mm_payload(use_async, release_error):
async def call_release():
if use_async:
await AsyncLLM.release_kv_cache_memory(engine) # type: ignore[arg-type]
await AsyncLLM.release_kv_cache_memory(engine)
else:
LLMEngine.release_kv_cache_memory(engine) # type: ignore[arg-type]
LLMEngine.release_kv_cache_memory(engine)
if release_error:
with pytest.raises(RuntimeError, match=release_error):
+4 -4
View File
@@ -1281,7 +1281,7 @@ def test_get_supported_mm_processor_kwargs_uses_supported_modalities(
processor: SimpleNamespace,
expected: dict[str, set[str]],
) -> None:
info = BaseProcessingInfo(SimpleNamespace()) # type: ignore[arg-type]
info = BaseProcessingInfo(SimpleNamespace())
info.__dict__["supported_mm_limits"] = supported_mm_limits
monkeypatch.setattr(info, "get_hf_processor", lambda **_: processor)
@@ -1291,7 +1291,7 @@ def test_get_supported_mm_processor_kwargs_uses_supported_modalities(
def test_supported_mm_processor_kwargs_is_cached(
monkeypatch: pytest.MonkeyPatch,
) -> None:
info = BaseProcessingInfo(SimpleNamespace()) # type: ignore[arg-type]
info = BaseProcessingInfo(SimpleNamespace())
expected = {"images_kwargs": {"size"}}
calls = 0
@@ -1442,7 +1442,7 @@ def test_get_merged_mm_kwargs_treats_empty_scopes_as_absent_before_routing(
mm_device_do_normalize=False,
)
model_config = SimpleNamespace(get_multimodal_config=lambda: mm_config)
ctx = InputProcessingContext(model_config, tokenizer=None) # type: ignore[arg-type]
ctx = InputProcessingContext(model_config, tokenizer=None)
merged = ctx.get_merged_mm_kwargs(
inference_kwargs,
@@ -1482,7 +1482,7 @@ def test_get_merged_mm_kwargs_merges_before_routing():
mm_device_do_normalize=False,
)
model_config = SimpleNamespace(get_multimodal_config=lambda: mm_config)
ctx = InputProcessingContext(model_config, tokenizer=None) # type: ignore[arg-type]
ctx = InputProcessingContext(model_config, tokenizer=None)
merged = ctx.get_merged_mm_kwargs(
{
+1 -1
View File
@@ -24,4 +24,4 @@ def test_create_processor_error_uses_served_model_name():
ValueError,
match="friendly-model-name is not a multimodal model",
):
MULTIMODAL_REGISTRY.create_processor(model_config) # type: ignore[arg-type]
MULTIMODAL_REGISTRY.create_processor(model_config)
+1 -1
View File
@@ -493,7 +493,7 @@ def test_pynvvideocodec_failed_rebuild_invalidates_decoder_slot():
old_decoder = FakeDecoder()
slot = PyNvVideoCodecDecoderSlot(FakeStream())
slot.decoder = old_decoder # type: ignore[assignment] # Fake retained GPU decoder.
slot.decoder = old_decoder
slot.source_path = "valid.mp4"
class FakeNvc:
+1 -1
View File
@@ -347,7 +347,7 @@ class TestAdjustRequestFoldFromStructuredOutputs:
id="chat_completion_request",
),
pytest.param(
lambda: StructuredOutputsParams(json=[1, 2, 3]), # type: ignore[arg-type]
lambda: StructuredOutputsParams(json=[1, 2, 3]),
id="structured_outputs_params",
),
],
@@ -271,7 +271,7 @@ def test_bitsandbytes_passes_revision_by_name():
return_value=["/folder/model.safetensors"],
),
):
bnb.BitsAndBytesModelLoader._prepare_weights(fake_self, "org/model", "myrev") # type: ignore[arg-type]
bnb.BitsAndBytesModelLoader._prepare_weights(fake_self, "org/model", "myrev")
mock_idx.assert_called_once()
assert mock_idx.call_args.kwargs.get("revision") == "myrev"
@@ -43,7 +43,7 @@ def test_transformers_backend_quantization(
model,
model_impl="auto",
enforce_eager=True,
**quantization_kwargs, # type: ignore[arg-type]
**quantization_kwargs,
) as vllm_model:
vllm_outputs = vllm_model.generate_greedy_logprobs(
example_prompts, max_tokens=max_tokens, num_logprobs=num_logprobs
@@ -53,7 +53,7 @@ def test_transformers_backend_quantization(
model,
model_impl="transformers",
enforce_eager=True,
**quantization_kwargs, # type: ignore[arg-type]
**quantization_kwargs,
) as vllm_model:
model_config = vllm_model.llm.llm_engine.model_config
assert model_config.using_transformers_backend()
@@ -92,7 +92,7 @@ def run_multimodal_gguf_test(
num_logprobs: int,
):
# Load images at runtime (inside subprocess) to avoid pickle issues
images = [ImageAsset(name).pil_image for name in model.image_names] # type: ignore[arg-type]
images = [ImageAsset(name).pil_image for name in model.image_names]
size_factors = [0.25, 0.5, 1.0]
inputs_per_image = [
(
+2 -2
View File
@@ -172,7 +172,7 @@ async def test_init_state_is_noop_without_phase_a(monkeypatch: pytest.MonkeyPatc
monkeypatch.setenv("VLLM_PLUGINS", "dummy_admin_endpoint_plugin")
state = State()
await init_endpoint_plugins_state(_FakeEngineClient(), state, _build_args()) # type: ignore[arg-type]
await init_endpoint_plugins_state(_FakeEngineClient(), state, _build_args())
assert not hasattr(state, "dummy_engine_client")
@@ -223,7 +223,7 @@ async def test_endpoint_plugin_end_to_end(monkeypatch: pytest.MonkeyPatch):
)
fake_engine_client = _FakeEngineClient(rpc_result=["cfg-a", "cfg-b"])
await init_endpoint_plugins_state(fake_engine_client, app.state, args) # type: ignore[arg-type]
await init_endpoint_plugins_state(fake_engine_client, app.state, args)
assert app.state.dummy_engine_client is fake_engine_client
@@ -92,7 +92,7 @@ def test_oot_registration_multimodal(
)
first_token = llm.get_tokenizer().decode(0)
outputs = llm.generate(prompts, sampling_params) # type: ignore[arg-type]
outputs = llm.generate(prompts, sampling_params)
for output in outputs:
generated_text = output.outputs[0].text
@@ -24,7 +24,7 @@ def test_stat_logger_plugin_is_discovered(monkeypatch: pytest.MonkeyPatch):
vllm_config = VllmConfig()
instance = factories[0](vllm_config)
# The `is` check above narrows DummyStatLogger to a Callable
assert isinstance(instance, DummyStatLogger) # type: ignore[arg-type]
assert isinstance(instance, DummyStatLogger)
def test_no_plugins_loaded_if_env_empty(monkeypatch: pytest.MonkeyPatch):
+2 -2
View File
@@ -123,8 +123,8 @@ def test_auto_gptq_moe_creates_zero_initialized_expert_biases():
method = object.__new__(AutoGPTQMoEMethod)
method.quant_config = AutoGPTQConfig(4, 128, False, True, False, {}, {})
method.input_dtype = None
method.experts_cls = None # type: ignore[assignment] # Weight creation does not select experts.
method.moe = SimpleNamespace(w13_num_shards=2) # type: ignore[assignment]
method.experts_cls = None
method.moe = SimpleNamespace(w13_num_shards=2)
layer = torch.nn.Module()
method.create_weights(
+6 -6
View File
@@ -423,7 +423,7 @@ def test_inc_get_quant_method_unquantized_routed_experts_with_model_prefix(
config = make_config(extra_config={"model.moe_layer": {"bits": 16}})
layer = object.__new__(RoutedExperts)
layer.moe_config = None # type: ignore[assignment] # No MoE config used by this stub.
layer.moe_config = None
method = config.get_quant_method(layer, "moe_layer")
@@ -730,7 +730,7 @@ def test_wna16_cuda_low_bit_moe_routes_to_humming(monkeypatch, bits) -> None:
)
layer = object.__new__(RoutedExperts)
layer.moe_config = DummyMoeConfig() # type: ignore[assignment]
layer.moe_config = DummyMoeConfig()
layer_config = make_layer_config(bits=bits)
method = INCWna16Scheme().get_moe_method(
make_config(), layer, "model.layers.0.mlp", layer_config
@@ -861,7 +861,7 @@ def test_qwen3_30b_a3b_w4a16_autoround_routes_to_gptq_moe(
config = make_qwen3_autoround_config("qwen3_30b_a3b_w4a16")
layer = object.__new__(RoutedExperts)
layer.moe_config = DummyMoeConfig() # type: ignore[assignment]
layer.moe_config = DummyMoeConfig()
method = config.get_quant_method(layer, "model.layers.0.mlp")
@@ -890,7 +890,7 @@ def test_qwen3_30b_a3b_mxfp4_autoround_routes_to_mxfp4_moe(
config = make_qwen3_autoround_config("qwen3_30b_a3b_mxfp4")
layer = object.__new__(RoutedExperts)
layer.moe_config = DummyMoeConfig() # type: ignore[assignment]
layer.moe_config = DummyMoeConfig()
ignored_method = config.get_quant_method(
object.__new__(LinearBase), "model.layers.0.self_attn.q_proj"
@@ -1186,7 +1186,7 @@ def test_wna16_xpu_moe_routes_to_gptq_moe(monkeypatch) -> None:
)
layer = object.__new__(RoutedExperts)
layer.moe_config = DummyMoeConfig() # type: ignore[assignment]
layer.moe_config = DummyMoeConfig()
method = INCWna16Scheme().get_moe_method(
make_config(),
layer,
@@ -1669,7 +1669,7 @@ def test_inc_get_quant_method_unquantized_moe_returns_unquantized(
when extra_config has bits >= 16."""
config = make_config(extra_config={"layer": {"bits": 16}})
layer = object.__new__(RoutedExperts)
layer.moe_config = None # type: ignore[assignment] # No MoE config used by this stub.
layer.moe_config = None
class DummyUnquantizedFusedMoEMethod:
def __init__(self, moe_config) -> None:
+2 -2
View File
@@ -220,7 +220,7 @@ def test_deepseek_v41_vl_mapper_routes_linear_scales(
quant_config=SimpleNamespace(weight_block_size=weight_block_size)
)
resolved = model_module._linear_scale_param_name(
vllm_config, # type: ignore[arg-type]
vllm_config,
expert_dtype,
)
assert resolved == scale_name
@@ -798,7 +798,7 @@ def test_kv_cache_scale_sync_to_host_copies():
set_default_quant_scales(layer, register_buffer=True)
layer.kv_cache_dtype = "fp8"
method = BaseKVCacheMethod(quant_config=None) # type: ignore[arg-type] # Scale synchronization does not use quant_config.
method = BaseKVCacheMethod(quant_config=None)
method.create_weights(layer)
# 0.3 stays != 1.0 even after the fp8_fnuz x2 rescale.
checkpoint_scale = torch.tensor(0.3, dtype=torch.float32)
+4 -4
View File
@@ -218,9 +218,9 @@ def test_gptq_nfirst_weights_pass_through_for_triton():
def test_moe_wna16_setup_forwards_selected_backend(monkeypatch):
method = object.__new__(MoeWNA16Method)
method.experts_cls = object # type: ignore[assignment] # Opaque mocked-expert sentinel.
method.experts_cls = object
method.wna16_backend = WNA16MoEBackend.HUMMING
method.moe = object() # type: ignore[assignment] # Opaque mocked-config sentinel.
method.moe = object()
quant_config = object()
monkeypatch.setattr(
method, "get_fused_moe_quant_config", lambda layer: quant_config
@@ -235,7 +235,7 @@ def test_moe_wna16_setup_forwards_selected_backend(monkeypatch):
monkeypatch.setattr(moe_wna16, "make_wna16_moe_kernel", fake_make_wna16_moe_kernel)
method._setup_kernel(layer) # type: ignore[arg-type] # Routing-table stub.
method._setup_kernel(layer)
assert method.moe_kernel is kernel
assert captured["backend"] == WNA16MoEBackend.HUMMING
@@ -280,7 +280,7 @@ def test_moe_wna16_uses_humming_quant_config(monkeypatch):
),
)
assert method.get_fused_moe_quant_config(layer) is quant_config # type: ignore[arg-type] # Identity sentinel.
assert method.get_fused_moe_quant_config(layer) is quant_config
@pytest.mark.skipif(
+4 -4
View File
@@ -210,9 +210,9 @@ def test_online_nvfp4_reuses_kernel_when_weights_are_reprocessed(
monkeypatch,
) -> None:
method = object.__new__(Nvfp4OnlineMoEMethod)
method.moe = SimpleNamespace(is_act_and_mul=True) # type: ignore[assignment]
method.nvfp4_backend = object() # type: ignore[assignment] # Opaque mocked-backend sentinel.
method.experts_cls = object # type: ignore[assignment] # Opaque mocked-expert sentinel.
method.moe = SimpleNamespace(is_act_and_mul=True)
method.nvfp4_backend = object()
method.experts_cls = object
method.moe_quant_config = None
method.moe_kernel = None
@@ -1432,7 +1432,7 @@ def test_online_int8_moe_w2_scale_matches_unsharded(monkeypatch) -> None:
layer.w2_weight = torch.nn.Parameter(w2_in, requires_grad=False)
layer.num_experts = layer.local_num_experts = w13.shape[0]
method = SimpleNamespace(moe=SimpleNamespace(tp_size=moe_tp_size))
Int8OnlineMoEMethod._quantize_weights(method, layer) # type: ignore[arg-type]
Int8OnlineMoEMethod._quantize_weights(method, layer)
return layer.w2_weight, layer.w2_scale
full_weight, full_scale = quantize(w2, 1)
+2 -2
View File
@@ -2314,7 +2314,7 @@ class TestQuarkInt4Format:
None,
quant_config.quant_config["global_quant_config"]["weight"],
quant_config.pack_method,
moe_config, # type: ignore[arg-type]
moe_config,
)
layer = _FakeLayer(moe_config)
@@ -2326,7 +2326,7 @@ class TestQuarkInt4Format:
requires_grad=False,
)
loader = method.get_weight_loader(
layer, # type: ignore[arg-type]
layer,
weight_loader=None,
)
loader(
@@ -34,7 +34,7 @@ def test_shared_nvfp4_input_scales_have_writable_storage(monkeypatch):
outputs = prepare_nvfp4_moe_layer_for_fi_or_cutlass(
backend=NvFp4MoeBackend.FLASHINFER_CUTLASS,
layer=layer, # type: ignore[arg-type]
layer=layer,
w13=w13,
w13_scale=w13_scale,
w13_scale_2=weight_scale,
+1 -1
View File
@@ -300,7 +300,7 @@ class TestTurboQuantKVCacheSpec:
# The layer builds an unpacked spec; the worker's spec-collection
# loop applies TQ slot packing via the backend's customize_spec hook.
spec = Attention.get_kv_cache_spec(layer, vllm_config) # type: ignore[arg-type]
spec = Attention.get_kv_cache_spec(layer, vllm_config)
assert isinstance(spec, FullAttentionSpec)
assert spec.kv_quant_mode.is_turboquant
assert spec.state_content_bytes is None
@@ -68,7 +68,7 @@ class TestBaseThinkingReasoningParserInit:
def test_initialization_with_missing_tokenizer(self):
"""Test that initialization fails without tokenizer."""
with pytest.raises(ValueError, match="model tokenizer must be passed"):
TestThinkingReasoningParser(None) # type: ignore[arg-type]
TestThinkingReasoningParser(None)
def test_initialization_with_missing_tokens(self, test_tokenizer):
"""Test that initialization fails when tokens are not in vocabulary."""
+50 -50
View File
@@ -81,7 +81,7 @@ class TestRoleToMelody:
# reject non-strings — any exception type is acceptable as long
# as we don't silently produce a malformed prompt.
with pytest.raises((AttributeError, TypeError, ValueError)):
_role_to_melody(None) # type: ignore[arg-type]
_role_to_melody(None)
# ======================================================================
@@ -135,7 +135,7 @@ class TestNormalizeToolCall:
def test_invalid_type_rejected(self):
with pytest.raises(TypeError, match="Unexpected tool_call value"):
_normalize_tool_call(42) # type: ignore[arg-type]
_normalize_tool_call(42)
# ======================================================================
@@ -249,7 +249,7 @@ class TestDocumentToMelody:
def test_invalid_type_rejected(self):
with pytest.raises(TypeError, match="Unsupported document type"):
_document_to_melody(42) # type: ignore[arg-type]
_document_to_melody(42)
# ======================================================================
@@ -302,7 +302,7 @@ class TestToolToMelody:
def test_invalid_type_rejected(self):
with pytest.raises(TypeError, match="Unsupported tool type"):
_tool_to_melody(42) # type: ignore[arg-type]
_tool_to_melody(42)
# ======================================================================
@@ -418,7 +418,7 @@ class TestConversationToMelody:
{"role": "user", "content": "hi"},
{"role": "assistant", "content": "hello"},
]
out = _conversation_to_melody_messages(conv) # type: ignore[arg-type]
out = _conversation_to_melody_messages(conv)
assert out == [
{
"role": "user",
@@ -443,7 +443,7 @@ class TestConversationToMelody:
"reasoning": "thoughts",
}
]
out = _conversation_to_melody_messages(conv) # type: ignore[arg-type]
out = _conversation_to_melody_messages(conv)
assert out[0]["content"] == [
{"type": MelodyContentType.THINKING, "thinking": "thoughts"},
{"type": MelodyContentType.TEXT, "text": "answer"},
@@ -457,7 +457,7 @@ class TestConversationToMelody:
"reasoning_content": "thoughts",
}
]
out = _conversation_to_melody_messages(conv) # type: ignore[arg-type]
out = _conversation_to_melody_messages(conv)
assert out[0]["content"][0] == {
"type": MelodyContentType.THINKING,
"thinking": "thoughts",
@@ -474,7 +474,7 @@ class TestConversationToMelody:
"reasoning": "should be ignored",
}
]
out = _conversation_to_melody_messages(conv) # type: ignore[arg-type]
out = _conversation_to_melody_messages(conv)
assert out[0]["content"] == [{"type": MelodyContentType.TEXT, "text": "hi"}]
def test_tool_calls_normalized(self):
@@ -491,7 +491,7 @@ class TestConversationToMelody:
],
}
]
out = _conversation_to_melody_messages(conv) # type: ignore[arg-type]
out = _conversation_to_melody_messages(conv)
assert out[0]["tool_calls"] == [
{"id": "c1", "name": "f", "parameters": '{"a":1}'}
]
@@ -504,7 +504,7 @@ class TestConversationToMelody:
"tool_call_id": "c1",
}
]
out = _conversation_to_melody_messages(conv) # type: ignore[arg-type]
out = _conversation_to_melody_messages(conv)
assert out[0]["tool_call_id"] == "c1"
def test_messages_citations_attached_by_index(self):
@@ -531,20 +531,20 @@ class TestConversationToMelody:
}
]
}
out = _conversation_to_melody_messages(conv, citations) # type: ignore[arg-type]
out = _conversation_to_melody_messages(conv, citations)
assert "citations" not in out[0]
assert out[1]["citations"] == citations[1]
def test_messages_citations_none_is_a_no_op(self):
conv = [{"role": "assistant", "content": "a"}]
out = _conversation_to_melody_messages(conv, None) # type: ignore[arg-type]
out = _conversation_to_melody_messages(conv, None)
assert "citations" not in out[0]
def test_messages_citations_missing_index_is_a_no_op(self):
# A ``messages_citations`` dict whose key doesn't hit any
# message must not attach anything (and must not raise).
conv = [{"role": "assistant", "content": "a"}]
out = _conversation_to_melody_messages(conv, {5: [{"anything": 1}]}) # type: ignore[arg-type]
out = _conversation_to_melody_messages(conv, {5: [{"anything": 1}]})
assert "citations" not in out[0]
def test_tool_message_v2_content_replaces_default_content(self):
@@ -575,7 +575,7 @@ class TestConversationToMelody:
]
}
out = _conversation_to_melody_messages(
conv, # type: ignore[arg-type]
conv,
tool_message_v2_content=v2_content,
)
# User message (no forwarded entry) still goes through the
@@ -597,7 +597,7 @@ class TestConversationToMelody:
]
}
out = _conversation_to_melody_messages(
conv, # type: ignore[arg-type]
conv,
tool_message_v2_content=v2_content,
)
assert out[0]["content"] == [
@@ -607,7 +607,7 @@ class TestConversationToMelody:
def test_tool_message_v2_content_none_falls_back_to_default(self):
conv = [{"role": "tool", "tool_call_id": "c", "content": "plain text"}]
out = _conversation_to_melody_messages(
conv, # type: ignore[arg-type]
conv,
tool_message_v2_content=None,
)
assert out[0]["content"] == [{"type": "text", "text": "plain text"}]
@@ -626,7 +626,7 @@ class TestBuildRenderConfig:
# Bare kwargs -> cmd4 (the current Command A+ prompt format).
# Mirrors ``_DEFAULT_FORMAT`` in ``vllm/renderers/cohere.py`` and
# the ``--cohere-format`` CLI default.
fmt, cfg = _build_render_config(self._conv(), {}) # type: ignore[arg-type]
fmt, cfg = _build_render_config(self._conv(), {})
assert fmt == "cmd4"
assert cfg["use_jinja"] is True
assert isinstance(cfg["messages"], list)
@@ -634,12 +634,12 @@ class TestBuildRenderConfig:
assert "additional_template_fields" not in cfg
def test_explicit_cmd3(self):
fmt, cfg = _build_render_config(self._conv(), {"cohere_format": "cmd3"}) # type: ignore[arg-type]
fmt, cfg = _build_render_config(self._conv(), {"cohere_format": "cmd3"})
assert fmt == "cmd3"
def test_invalid_format_raises(self):
with pytest.raises(ValueError, match="Invalid cohere_format"):
_build_render_config(self._conv(), {"cohere_format": "cmd5"}) # type: ignore[arg-type]
_build_render_config(self._conv(), {"cohere_format": "cmd5"})
def test_documents_converted(self):
_, cfg = _build_render_config(
@@ -650,7 +650,7 @@ class TestBuildRenderConfig:
{"id": "d1", "data": {"text": "wrapped"}},
]
},
) # type: ignore[arg-type]
)
assert cfg["documents"] == [
{"text": "doc text"},
{"id": "d1", "text": "wrapped"},
@@ -665,7 +665,7 @@ class TestBuildRenderConfig:
{"type": "function", "function": {"name": "preferred"}}
],
},
) # type: ignore[arg-type]
)
names = [t["name"] for t in cfg["available_tools"]]
assert names == ["preferred"]
@@ -673,30 +673,30 @@ class TestBuildRenderConfig:
_, cfg = _build_render_config(
self._conv(),
{"tools": [{"type": "function", "function": {"name": "from_tools"}}]},
) # type: ignore[arg-type]
)
assert [t["name"] for t in cfg["available_tools"]] == ["from_tools"]
@pytest.mark.parametrize("value", ["enabled", "disabled"])
def test_reasoning_type_direct(self, value):
_, cfg = _build_render_config(self._conv(), {"reasoning_type": value}) # type: ignore[arg-type]
_, cfg = _build_render_config(self._conv(), {"reasoning_type": value})
assert cfg["reasoning_type"] == value
def test_thinking_dict_shorthand_resolves_reasoning_type(self):
_, cfg = _build_render_config(self._conv(), {"thinking": {"type": "enabled"}}) # type: ignore[arg-type]
_, cfg = _build_render_config(self._conv(), {"thinking": {"type": "enabled"}})
assert cfg["reasoning_type"] == "enabled"
def test_thinking_shorthand_ignores_unknown_type(self):
_, cfg = _build_render_config(self._conv(), {"thinking": {"type": "auto"}}) # type: ignore[arg-type]
_, cfg = _build_render_config(self._conv(), {"thinking": {"type": "auto"}})
assert "reasoning_type" not in cfg
def test_dev_instruction_forwarded(self):
_, cfg = _build_render_config(self._conv(), {"dev_instruction": "be brief"}) # type: ignore[arg-type]
_, cfg = _build_render_config(self._conv(), {"dev_instruction": "be brief"})
assert cfg["dev_instruction"] == "be brief"
def test_response_format_json_object_sets_json_mode(self):
_, cfg = _build_render_config(
self._conv(), {"response_format": {"type": "json_object"}}
) # type: ignore[arg-type]
)
assert cfg["json_mode"] is True
assert "json_schema" not in cfg
@@ -705,7 +705,7 @@ class TestBuildRenderConfig:
_, cfg = _build_render_config(
self._conv(),
{"response_format": {"type": "json_schema", "schema": schema}},
) # type: ignore[arg-type]
)
# JSON-encoded for melody (string-only schema field).
assert cfg["json_schema"] == json.dumps(schema)
@@ -721,35 +721,35 @@ class TestBuildRenderConfig:
"schema": {"schema": inner},
}
},
) # type: ignore[arg-type]
)
assert cfg["json_schema"] == json.dumps(inner)
def test_json_schema_kwarg_direct(self):
# Caller can also pass ``json_schema`` directly, both as dict and
# as a pre-stringified value.
_, cfg = _build_render_config(self._conv(), {"json_schema": {"a": 1}}) # type: ignore[arg-type]
_, cfg = _build_render_config(self._conv(), {"json_schema": {"a": 1}})
assert cfg["json_schema"] == '{"a": 1}'
_, cfg = _build_render_config(
self._conv(), {"json_schema": "raw-string-schema"}
) # type: ignore[arg-type]
)
assert cfg["json_schema"] == "raw-string-schema"
def test_json_mode_kwarg_overrides(self):
_, cfg = _build_render_config(self._conv(), {"json_mode": True}) # type: ignore[arg-type]
_, cfg = _build_render_config(self._conv(), {"json_mode": True})
assert cfg["json_mode"] is True
def test_cmd3_safety_mode_lowercased(self):
_, cfg = _build_render_config(
self._conv(),
{"cohere_format": "cmd3", "safety_mode": "CONTEXTUAL"},
) # type: ignore[arg-type]
)
assert cfg["safety_mode"] == "contextual"
def test_cmd3_citation_quality_direct(self):
_, cfg = _build_render_config(
self._conv(),
{"cohere_format": "cmd3", "citation_quality": "ACCURATE"},
) # type: ignore[arg-type]
)
assert cfg["citation_quality"] == "accurate"
def test_cmd3_citation_quality_derived_from_citation_options(self):
@@ -758,20 +758,20 @@ class TestBuildRenderConfig:
_, cfg = _build_render_config(
self._conv(),
{"cohere_format": "cmd3", "citation_options": {"mode": "accurate"}},
) # type: ignore[arg-type]
)
assert cfg["citation_quality"] == "on"
_, cfg = _build_render_config(
self._conv(),
{"cohere_format": "cmd3", "citation_options": {"mode": "off"}},
) # type: ignore[arg-type]
)
assert cfg["citation_quality"] == "off"
def test_cmd3_skip_preamble_forwarded(self):
_, cfg = _build_render_config(
self._conv(),
{"cohere_format": "cmd3", "skip_preamble": True},
) # type: ignore[arg-type]
)
assert cfg["skip_preamble"] is True
def test_cmd3_no_grounding_field(self):
@@ -779,7 +779,7 @@ class TestBuildRenderConfig:
_, cfg = _build_render_config(
self._conv(),
{"cohere_format": "cmd3", "grounding": "fast"},
) # type: ignore[arg-type]
)
assert "grounding" not in cfg
@pytest.mark.parametrize(
@@ -800,7 +800,7 @@ class TestBuildRenderConfig:
_, cfg = _build_render_config(
self._conv(),
{"cohere_format": "cmd4", "grounding": raw},
) # type: ignore[arg-type]
)
assert cfg["grounding"] == expected
@pytest.mark.parametrize(
@@ -818,7 +818,7 @@ class TestBuildRenderConfig:
"cohere_format": "cmd4",
"citation_options": {"mode": mode},
},
) # type: ignore[arg-type]
)
assert cfg["grounding"] == expected
def test_cmd4_grounding_rejects_unknown_value(self):
@@ -826,7 +826,7 @@ class TestBuildRenderConfig:
_build_render_config(
self._conv(),
{"cohere_format": "cmd4", "grounding": "foobar"},
) # type: ignore[arg-type]
)
def test_cmd4_platform_instruction(self):
_, cfg = _build_render_config(
@@ -835,7 +835,7 @@ class TestBuildRenderConfig:
"cohere_format": "cmd4",
"platform_instruction": "do this",
},
) # type: ignore[arg-type]
)
assert cfg["platform_instruction"] == "do this"
def test_cmd4_no_safety_mode_field(self):
@@ -847,7 +847,7 @@ class TestBuildRenderConfig:
"safety_mode": "contextual",
"citation_quality": "on",
},
) # type: ignore[arg-type]
)
assert "safety_mode" not in cfg
assert "citation_quality" not in cfg
@@ -862,7 +862,7 @@ class TestBuildRenderConfig:
"my_var": "x",
"documents": ["doc"], # consumed, must NOT leak through
},
) # type: ignore[arg-type]
)
extras = cfg["additional_template_fields"]
assert extras == {"reasoning_effort": "low", "my_var": "x"}
# Sanity: the consumed key still produced its dedicated config slot.
@@ -875,7 +875,7 @@ class TestBuildRenderConfig:
_, cfg = _build_render_config(
self._conv(),
{"template_id": "tpl1"},
) # type: ignore[arg-type]
)
assert cfg["template_id"] == "tpl1"
# use_jinja is always True, regardless of caller input.
assert cfg["use_jinja"] is True
@@ -896,7 +896,7 @@ class TestBuildRenderConfig:
_build_render_config(
self._conv(),
{cohere_only_key: "raw {{ jinja }}"},
) # type: ignore[arg-type]
)
@pytest.mark.parametrize("cohere_only_key", ["template_jinja", "template"])
def test_cohere_only_template_kwargs_none_is_tolerated(self, cohere_only_key):
@@ -906,7 +906,7 @@ class TestBuildRenderConfig:
_, cfg = _build_render_config(
self._conv(),
{cohere_only_key: None},
) # type: ignore[arg-type]
)
assert cohere_only_key not in cfg
assert "additional_template_fields" not in cfg
@@ -918,7 +918,7 @@ class TestBuildRenderConfig:
self._conv(),
{},
"raw {{ jinja }}",
) # type: ignore[arg-type]
)
assert cfg["template_jinja"] == "raw {{ jinja }}"
assert cfg["use_jinja"] is True
@@ -927,7 +927,7 @@ class TestBuildRenderConfig:
self._conv(),
{},
None,
) # type: ignore[arg-type]
)
assert "template_jinja" not in cfg
def test_tool_message_v2_content_key_picked_up_from_kwargs(self):
@@ -954,7 +954,7 @@ class TestBuildRenderConfig:
]
}
}
_, cfg = _build_render_config(conv, kwargs) # type: ignore[arg-type]
_, cfg = _build_render_config(conv, kwargs)
tool_msg = cfg["messages"][1]
assert tool_msg["content"] == [{"type": "document", "document": {"r": "k"}}]
# And the key must be *consumed* -- not surfaced as a stray
+1 -1
View File
@@ -139,7 +139,7 @@ class TestValidatePrompt:
with pytest.raises(TypeError, match="should be a list of integers"):
renderer.render_prompts(
_preprocess_prompt(renderer.model_config, [[1, 2], ["foo", "bar"]]) # type: ignore[arg-type]
_preprocess_prompt(renderer.model_config, [[1, 2], ["foo", "bar"]])
)
+3 -3
View File
@@ -113,7 +113,7 @@ def test_beam_search_abort_returns_partial_outputs_and_continues_other_prompts(
{"type": "token", "prompt_token_ids": [token]} for token in [prompt_token, 2]
]
params = BeamSearchParams(beam_width=2, max_tokens=3)
outputs = llm.beam_search(prompts, params) # type: ignore[arg-type]
outputs = llm.beam_search(prompts, params)
aborted, normal = outputs
expected_tokens = (
@@ -326,7 +326,7 @@ def test_beam_search_structured_output(
llm = LLM(
model=model,
dtype=dtype, # type: ignore[arg-type]
dtype=dtype,
max_model_len=512,
structured_outputs_config=dict(
backend="xgrammar",
@@ -345,7 +345,7 @@ def test_beam_search_structured_output(
"Generate a JSON object for a person with name and age:",
]
outputs = llm.beam_search(prompts, params) # type: ignore[arg-type]
outputs = llm.beam_search(prompts, params)
assert len(outputs) == len(prompts)
for output in outputs:
+2 -2
View File
@@ -57,8 +57,8 @@ class _EngineClient:
class _Serving(BeamSearchOnlineMixin):
renderer = _Renderer() # type: ignore[assignment]
engine_client = _EngineClient() # type: ignore[assignment]
renderer = _Renderer()
engine_client = _EngineClient()
@pytest.mark.asyncio
+1 -1
View File
@@ -17,6 +17,6 @@ module_names = ["torch._inductor.async_compile", "cv2"]
# if we import any modules during `import vllm`, there would be a
# hard error and nice stacktrace on the first import.
for module_name in module_names:
sys.modules[module_name] = None # type: ignore[assignment]
sys.modules[module_name] = None
import vllm # noqa
+1 -1
View File
@@ -144,6 +144,6 @@ async def test_audio_connector_threads_byte_limit_to_http_reader(
assert kwargs["max_bytes"] == MiB_bytes
raise VLLMValidationError("Maximum file size exceeded")
connector = MediaConnector(connection=_Connection()) # type: ignore[arg-type]
connector = MediaConnector(connection=_Connection())
with pytest.raises(VLLMValidationError, match="Maximum file size exceeded"):
await connector.fetch_audio_async("https://example.test/audio")
+5 -5
View File
@@ -975,7 +975,7 @@ class TestMistralTokenizer:
mistral_tokenizer: MistralTokenizer,
):
assert mistral_tokenizer.batch_decode(
[[]], # type: ignore[arg-type]
[[]],
) == [""]
def test_convert_tokens_to_string(self, mistral_tokenizer: MistralTokenizer):
@@ -2246,7 +2246,7 @@ class TestMistralTokenizer:
]
output = mistral_tokenizer.apply_chat_template(
messages, # type: ignore[arg-type]
messages,
add_generation_prompt=True,
)
decoded = mistral_tokenizer.tokenizer.decode(output, SpecialTokenPolicy.KEEP)
@@ -2352,7 +2352,7 @@ def test_v15_apply_chat_template_passes_reasoning_effort_high(
)
v15_mistral_tokenizer.apply_chat_template(
messages=_PASSTHROUGH_MESSAGES, # type: ignore[arg-type]
messages=_PASSTHROUGH_MESSAGES,
reasoning_effort="high",
)
@@ -2375,7 +2375,7 @@ def test_v15_apply_chat_template_passes_reasoning_effort_none_by_default(
fake_apply_chat_template,
)
v15_mistral_tokenizer.apply_chat_template(messages=_PASSTHROUGH_MESSAGES) # type: ignore[arg-type]
v15_mistral_tokenizer.apply_chat_template(messages=_PASSTHROUGH_MESSAGES)
assert "reasoning_effort" in captured_kwargs[-1]
assert captured_kwargs[-1]["reasoning_effort"] is None
@@ -2398,7 +2398,7 @@ def test_pre_v15_apply_chat_template_omits_reasoning_effort(
)
v13_mistral_tokenizer.apply_chat_template(
messages=_PASSTHROUGH_MESSAGES, # type: ignore[arg-type]
messages=_PASSTHROUGH_MESSAGES,
reasoning_effort="high",
)
+1 -1
View File
@@ -205,7 +205,7 @@ def test_cached_tokenizer_from_config_registers_local_config(tmp_path: Path):
side_effect=lambda tokenizer: tokenizer,
),
):
tokenizer = cached_tokenizer_from_config(model_config) # type: ignore[arg-type]
tokenizer = cached_tokenizer_from_config(model_config)
assert tokenizer.is_fast is True
finally:
@@ -54,7 +54,7 @@ def test_extract_tool_calls_no_tools(ernie45_tool_parser):
model_output = "This is a test"
extracted_tool_calls = ernie45_tool_parser.extract_tool_calls(
model_output, request=None
) # type: ignore[arg-type]
)
assert not extracted_tool_calls.tools_called
assert extracted_tool_calls.tool_calls == []
assert extracted_tool_calls.content == model_output
@@ -163,7 +163,7 @@ def test_extract_tool_calls(
):
extracted_tool_calls = ernie45_tool_parser.extract_tool_calls(
model_output, request=None
) # type: ignore[arg-type]
)
assert extracted_tool_calls.tools_called
assert_tool_calls(extracted_tool_calls.tool_calls, expected_tool_calls)
+3 -3
View File
@@ -78,7 +78,7 @@ def stream_delta_message_generator(
previous_token_ids,
current_token_ids,
delta_token_ids,
request=None, # type: ignore[arg-type]
request=None,
)
if delta_message:
yield delta_message
@@ -95,7 +95,7 @@ def test_extract_tool_calls_no_tools(jamba_tool_parser):
model_output = "This is a test"
extracted_tool_calls = jamba_tool_parser.extract_tool_calls(
model_output, request=None
) # type: ignore[arg-type]
)
assert not extracted_tool_calls.tools_called
assert extracted_tool_calls.tool_calls == []
assert extracted_tool_calls.content == model_output
@@ -166,7 +166,7 @@ def test_extract_tool_calls(
):
extracted_tool_calls = jamba_tool_parser.extract_tool_calls(
model_output, request=None
) # type: ignore[arg-type]
)
assert extracted_tool_calls.tools_called
assert_tool_calls(extracted_tool_calls.tool_calls, expected_tool_calls)
@@ -225,7 +225,7 @@ def test_extract_tool_calls_no_tools(qwen3_tool_parser):
model_output = "This is a test response without any tool calls"
extracted_tool_calls = qwen3_tool_parser.extract_tool_calls(
model_output, request=None
) # type: ignore[arg-type]
)
assert not extracted_tool_calls.tools_called
assert extracted_tool_calls.tool_calls == []
assert extracted_tool_calls.content == model_output
@@ -170,7 +170,7 @@ def test_extract_tool_calls_no_tools(step3p5_tool_parser):
model_output = "This is a test response without any tool calls"
extracted_tool_calls = step3p5_tool_parser.extract_tool_calls(
model_output, request=None
) # type: ignore[arg-type]
)
assert not extracted_tool_calls.tools_called
assert extracted_tool_calls.tool_calls == []
assert extracted_tool_calls.content == model_output
+4 -4
View File
@@ -100,7 +100,7 @@ def test_extract_tool_calls_no_tools(xlam_tool_parser):
model_output = "This is a test"
extracted_tool_calls = xlam_tool_parser.extract_tool_calls(
model_output, request=None
) # type: ignore[arg-type]
)
assert not extracted_tool_calls.tools_called
assert extracted_tool_calls.tool_calls == []
assert extracted_tool_calls.content == model_output
@@ -225,7 +225,7 @@ def test_extract_tool_calls(
):
extracted_tool_calls = xlam_tool_parser.extract_tool_calls(
model_output, request=None
) # type: ignore[arg-type]
)
assert extracted_tool_calls.tools_called
assert_tool_calls(extracted_tool_calls.tool_calls, expected_tool_calls)
@@ -263,7 +263,7 @@ def test_extract_tool_calls_list_structure(
"""Test extraction of tool calls when the model outputs a list-structured tool call.""" # noqa: E501
extracted_tool_calls = xlam_tool_parser.extract_tool_calls(
model_output, request=None
) # type: ignore[arg-type]
)
assert extracted_tool_calls.tools_called
assert_tool_calls(extracted_tool_calls.tool_calls, expected_tool_calls)
@@ -550,7 +550,7 @@ def test_extract_tool_calls_non_ascii(xlam_tool_parser, xlam_tokenizer, streamin
if delta.tool_calls and delta.tool_calls[0].function.arguments
)
else:
extracted = xlam_tool_parser.extract_tool_calls(model_output, request=None) # type: ignore[arg-type]
extracted = xlam_tool_parser.extract_tool_calls(model_output, request=None)
args = "".join(tc.function.arguments for tc in extracted.tool_calls)
assert "北京" in args
@@ -148,7 +148,7 @@ def test_tool_parser_adjust_request_builds_valid_response_text_config() -> None:
description string that the previous two-step construction injected.
"""
parser = ToolParser.__new__(ToolParser)
parser.model_tokenizer = None # type: ignore[assignment]
parser.model_tokenizer = None
request = _build_responses_request(tool_choice="required")
ToolParser.adjust_request(parser, request)
+1 -1
View File
@@ -370,7 +370,7 @@ def test_streaming_split_markers_do_not_leak():
assert len(tool_deltas) == 1
assert tool_deltas[0].function is not None
assert tool_deltas[0].function.name == "calc"
assert json.loads(tool_deltas[0].function.arguments) == {"x": 1} # type: ignore[arg-type]
assert json.loads(tool_deltas[0].function.arguments) == {"x": 1}
def test_tool_call_ids_are_unique_across_messages():
@@ -98,7 +98,7 @@ def test_fetch_audio_rejects_unsupported_type(
feature_extractor: MistralCommonFeatureExtractor,
):
with pytest.raises(TypeError, match="only a numpy array"):
feature_extractor.fetch_audio(42) # type: ignore[arg-type]
feature_extractor.fetch_audio(42)
def test_fetch_audio_str_delegates_to_load_audio(
+2 -2
View File
@@ -44,7 +44,7 @@ class _ProcWithUnpack:
def test_get_processor_kwargs_from_processor_unpack_path_returns_full_union():
proc = _ProcWithUnpack()
keys = get_processor_kwargs_keys(get_processor_kwargs_type(proc)) # type: ignore[arg-type]
keys = get_processor_kwargs_keys(get_processor_kwargs_type(proc))
_assert_has_all_expected(keys)
@@ -63,5 +63,5 @@ def test_get_processor_kwargs_from_processor_module_scan_returns_full_union():
assert hasattr(mod, "_FakeProcessorKwargs")
proc = _ProcWithoutUnpack()
keys = get_processor_kwargs_keys(get_processor_kwargs_type(proc)) # type: ignore[arg-type]
keys = get_processor_kwargs_keys(get_processor_kwargs_type(proc))
_assert_has_all_expected(keys)
+1 -1
View File
@@ -830,7 +830,7 @@ class RemoteOpenAIServerCustom(RemoteOpenAIServer):
self.proc: Process = cast(Any, ctx).Process(
target=_run_in_new_process_group,
args=(self.child_process_fxn, env_dict, model, vllm_serve_args),
) # type: ignore[assignment]
)
with _temporarily_sanitized_pythonpath_env():
self.proc.start()
+9 -9
View File
@@ -476,32 +476,32 @@ def test_compilation_config_mode_validator():
"""Test that CompilationConfig.mode field validator converts strings to integers."""
from vllm.config.compilation import CompilationConfig, CompilationMode
config = CompilationConfig(mode=0) # type: ignore[arg-type]
config = CompilationConfig(mode=0)
assert config.mode == CompilationMode.NONE
config = CompilationConfig(mode=3) # type: ignore[arg-type]
config = CompilationConfig(mode=3)
assert config.mode == CompilationMode.VLLM_COMPILE
config = CompilationConfig(mode="NONE") # type: ignore[arg-type]
config = CompilationConfig(mode="NONE")
assert config.mode == CompilationMode.NONE
config = CompilationConfig(mode="STOCK_TORCH_COMPILE") # type: ignore[arg-type]
config = CompilationConfig(mode="STOCK_TORCH_COMPILE")
assert config.mode == CompilationMode.STOCK_TORCH_COMPILE
config = CompilationConfig(mode="DYNAMO_TRACE_ONCE") # type: ignore[arg-type]
config = CompilationConfig(mode="DYNAMO_TRACE_ONCE")
assert config.mode == CompilationMode.DYNAMO_TRACE_ONCE
config = CompilationConfig(mode="VLLM_COMPILE") # type: ignore[arg-type]
config = CompilationConfig(mode="VLLM_COMPILE")
assert config.mode == CompilationMode.VLLM_COMPILE
config = CompilationConfig(mode="none") # type: ignore[arg-type]
config = CompilationConfig(mode="none")
assert config.mode == CompilationMode.NONE
config = CompilationConfig(mode="vllm_compile") # type: ignore[arg-type]
config = CompilationConfig(mode="vllm_compile")
assert config.mode == CompilationMode.VLLM_COMPILE
with pytest.raises(ValidationError, match="Invalid compilation mode"):
CompilationConfig(mode="INVALID_MODE") # type: ignore[arg-type]
CompilationConfig(mode="INVALID_MODE")
def test_flat_product():
@@ -511,14 +511,14 @@ class TestMLAPrefillBackendParsing:
def test_valid_string_parses_to_enum(self):
config = AttentionConfig(
mla_prefill_backend="FLASH_ATTN", # type: ignore[arg-type]
mla_prefill_backend="FLASH_ATTN",
)
assert config.mla_prefill_backend == MLAPrefillBackendEnum.FLASH_ATTN
def test_invalid_string_raises_error(self):
with pytest.raises(ValueError, match="Unknown MLA prefill backend"):
AttentionConfig(
mla_prefill_backend="NONEXISTENT", # type: ignore[arg-type]
mla_prefill_backend="NONEXISTENT",
)
@@ -3575,7 +3575,7 @@ def test_flashmla_fp8_paths_accept_decode_subset(monkeypatch, use_mixed_batch: b
if use_mixed_batch:
fp8_metadata = FlashMLASparseMetadata.FP8KernelMetadata(
scheduler_metadata=object(), # type: ignore[arg-type]
scheduler_metadata=object(),
dummy_block_table=torch.empty(1, 1, dtype=torch.int32, device=DEVICE_TYPE),
cache_lens=torch.empty(1, dtype=torch.int32, device=DEVICE_TYPE),
)
@@ -3588,7 +3588,7 @@ def test_flashmla_fp8_paths_accept_decode_subset(monkeypatch, use_mixed_batch: b
num_prefill_tokens=num_batch_tokens - num_decode_tokens,
decode=FP8Meta.Decode(
seq_lens=torch.empty(1, dtype=torch.int32, device=DEVICE_TYPE),
kernel_metadata=object(), # type: ignore[arg-type]
kernel_metadata=object(),
decode_query_len=num_decode_tokens,
),
prefill=FP8Meta.Prefill(
@@ -3774,7 +3774,7 @@ def test_fp8_mixed_batch_dcp_neutralizes_empty_rows(monkeypatch):
metadata = SimpleNamespace(
fp8_extra_metadata=FlashMLASparseMetadata.FP8KernelMetadata(
scheduler_metadata=object(), # type: ignore[arg-type]
scheduler_metadata=object(),
dummy_block_table=torch.empty(1, 1, dtype=torch.int32, device=DEVICE_TYPE),
cache_lens=torch.empty(1, dtype=torch.int32, device=DEVICE_TYPE),
),
+2 -2
View File
@@ -134,7 +134,7 @@ def test_piecewise_capture_uses_pcp_dummy_slot_mappings():
device=torch.device("cpu"),
max_num_reqs=num_reqs,
max_num_tokens=num_tokens,
block_tables=pcp_block_tables, # type: ignore[arg-type]
block_tables=pcp_block_tables,
)
block_tables = MagicMock()
@@ -224,7 +224,7 @@ def test_speculator_capture_preserves_decode_query_bounds(
)
manager = SpeculatorCudaGraphManager.__new__(SpeculatorCudaGraphManager)
manager.max_num_reqs = num_reqs
manager.vllm_config = SimpleNamespace( # type: ignore[assignment]
manager.vllm_config = SimpleNamespace(
parallel_config=SimpleNamespace(data_parallel_size=1)
)
buffers = InputBuffers(num_reqs, num_tokens, torch.device("cpu"))

Some files were not shown because too many files have changed in this diff Show More