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
@@ -27,7 +27,7 @@ def make_manager(
manager.num_speculative_steps = num_steps
manager._stale_confidences = [SimpleNamespace(np=confidences)] # type: ignore[list-item] # CPU-only confidence buffer.
manager._stale_idx = 0
manager.req_states = SimpleNamespace( # type: ignore[assignment] # CPU-only request fixture.
manager.req_states = SimpleNamespace(
req_id_to_index={"low": 0, "high": 1},
num_computed_tokens_np=np.ones(num_reqs, dtype=np.int32),
prefill_len=SimpleNamespace(np=np.ones(num_reqs, dtype=np.int32)),
@@ -153,11 +153,11 @@ def test_manager_checks_target_varlen_cudagraph_bound(
manager = maybe_create_adaptive_verification_manager(
enable_adaptive_verification=True,
attn_groups=groups,
req_states=SimpleNamespace(num_speculative_steps=7), # type: ignore[arg-type]
req_states=SimpleNamespace(num_speculative_steps=7),
query_start_loc=object(),
num_bonus_tokens=1,
max_total_logits=1,
vllm_config=None, # type: ignore[arg-type]
vllm_config=None,
target_layer_names={"target"},
additional_attn_cg_support=additional,
)
@@ -186,9 +186,7 @@ def test_budget_stops_where_marginal_drafts_stop_paying_for_themselves():
def test_profiled_batches_seed_cost_curves_via_consumer(monkeypatch):
manager = AdaptiveVerificationManager.__new__(AdaptiveVerificationManager)
manager.req_states = SimpleNamespace( # type: ignore[assignment] # CPU-only request fixture.
max_num_batched_tokens=4096, max_num_reqs=64
)
manager.req_states = SimpleNamespace(max_num_batched_tokens=4096, max_num_reqs=64)
manager.num_speculative_steps = 7
manager.num_bonus_tokens = 1
curves: dict[str, list[tuple[int, float]]] = {}
+8 -8
View File
@@ -98,7 +98,7 @@ def test_draft_quant_exclusions_include_global_layer_indices():
]
)
_add_global_draft_layer_exclusions(quant_config, 88, 5) # type: ignore[arg-type]
_add_global_draft_layer_exclusions(quant_config, 88, 5)
assert "layers.88.mlp_conv*" in quant_config.exclude_modules
assert "*layers.92.self_attn.q_proj" in quant_config.exclude_modules
@@ -171,7 +171,7 @@ def test_selector_leaves_greedy_drafting_without_proposal_logits(monkeypatch):
allocating one here would claim a proposal the walk never sampled from.
"""
_stub_base(monkeypatch, None)
speculator = DFlash2Speculator(None, torch.device("cpu")) # type: ignore[arg-type] # Base initialization is stubbed.
speculator = DFlash2Speculator(None, torch.device("cpu"))
assert speculator.draft_logits is None
@@ -183,7 +183,7 @@ def test_selector_asks_for_fp32_proposal_logits():
candidate row often enough that the walk and the rejection sampler checking it
would no longer read the same distribution.
"""
dtype, fill = DFlash2Speculator.draft_logits_spec(None, None) # type: ignore[arg-type] # Constant spec ignores self/config.
dtype, fill = DFlash2Speculator.draft_logits_spec(None, None)
assert dtype is torch.float32
assert fill == float("-inf")
@@ -309,9 +309,9 @@ def test_candidate_model_decoder_layer_cls(monkeypatch, variant):
vllm_config.compilation_config = mock_current_vllm_config.compilation_config
# 3. Instantiate the model under meta device to avoid parameter allocation issues
with set_current_vllm_config(mock_current_vllm_config), torch.device("meta"): # type: ignore[arg-type]
with set_current_vllm_config(mock_current_vllm_config), torch.device("meta"):
model_cls = DFlash2Qwen3Model if variant == "dflash2" else LiLiCorr
model = model_cls(vllm_config=vllm_config) # type: ignore[arg-type]
model = model_cls(vllm_config=vllm_config)
# 4. Assert that the layers are DFlash2Qwen3DecoderLayer (the subclass)
assert len(model.layers) == 2
@@ -350,7 +350,7 @@ def test_conv_projections_use_draft_quant_config(monkeypatch):
quant_method="W4A16_NVFP4", is_checkpoint_nvfp4_serialized=True
)
layer = DFlash2Qwen3DecoderLayer(
SimpleNamespace( # type: ignore[arg-type]
SimpleNamespace(
speculative_config=SimpleNamespace(num_speculative_tokens=7),
model_config=SimpleNamespace(dtype=torch.bfloat16),
),
@@ -434,7 +434,7 @@ def test_context_kv_uses_quantized_projection_fallback(monkeypatch):
for projection in projections
]
qwen3_dflash.DFlashQwen3Model._build_context_kv_buffers(
model, # type: ignore[arg-type]
model,
layers_attn,
has_bias=False,
)
@@ -442,7 +442,7 @@ def test_context_kv_uses_quantized_projection_fallback(monkeypatch):
assert all(not hasattr(projection, "weight") for projection in projections)
actual_k, actual_v = qwen3_dflash.DFlashQwen3Model._project_context_kv(
model, # type: ignore[arg-type]
model,
context_states,
num_ctx=2,
num_layers=2,
@@ -141,9 +141,9 @@ def test_dflash_drafter_window_reserves_bonus_token():
speculative_config=_dflash_speculative_config(NUM_SPECULATIVE_TOKENS),
)
# window = 4, so 96 fits (96 + 4 == 100) but 97 does not (97 + 4 == 101)
assert input_fits_in_drafter(dflash_runner, SimpleNamespace(max_seq_len=96)) # type: ignore[arg-type]
assert not input_fits_in_drafter(dflash_runner, SimpleNamespace(max_seq_len=97)) # type: ignore[arg-type]
assert not input_fits_in_drafter(dflash_runner, None) # type: ignore[arg-type] # No metadata.
assert input_fits_in_drafter(dflash_runner, SimpleNamespace(max_seq_len=96))
assert not input_fits_in_drafter(dflash_runner, SimpleNamespace(max_seq_len=97))
assert not input_fits_in_drafter(dflash_runner, None)
# Other drafters don't reserve the bonus token, so 97 fits (97 + 3 == 100).
plain_runner = SimpleNamespace(
@@ -151,4 +151,4 @@ def test_dflash_drafter_window_reserves_bonus_token():
effective_drafter_max_model_len=100,
speculative_config=SimpleNamespace(use_dflash=lambda: False),
)
assert input_fits_in_drafter(plain_runner, SimpleNamespace(max_seq_len=97)) # type: ignore[arg-type]
assert input_fits_in_drafter(plain_runner, SimpleNamespace(max_seq_len=97))
@@ -158,9 +158,7 @@ def test_wrapper_forwards_spec_step_idx():
hidden_states = torch.empty(0)
wrapper = object.__new__(DeepSeekV4MTP)
wrapper.model = SimpleNamespace( # type: ignore[assignment]
get_top_tokens=lambda *args: args
)
wrapper.model = SimpleNamespace(get_top_tokens=lambda *args: args)
assert DeepSeekV4MTP.get_top_tokens(wrapper, hidden_states, 2) == (hidden_states, 2)
assert DeepSeekV4MTP.get_top_tokens(wrapper, hidden_states) == (hidden_states, 0)
@@ -51,7 +51,7 @@ def _create_proposer(
target_parallel_config=ParallelConfig(),
method="extract_hidden_states",
num_speculative_tokens=num_speculative_tokens,
draft_model_config={ # type: ignore[arg-type]
draft_model_config={
"hf_config": {
"eagle_aux_hidden_state_layer_ids": layer_ids,
}
@@ -103,7 +103,7 @@ def test_proposer_initialization_missing_layer_ids():
target_parallel_config=ParallelConfig(),
method="extract_hidden_states",
num_speculative_tokens=1,
draft_model_config={ # type: ignore[arg-type]
draft_model_config={
"hf_config": {} # Missing eagle_aux_hidden_state_layer_ids
},
)
@@ -363,7 +363,7 @@ def test_extract_hidden_states_text_only_config_regression():
target_parallel_config=ParallelConfig(),
method="extract_hidden_states",
num_speculative_tokens=1,
draft_model_config={ # type: ignore[arg-type]
draft_model_config={
"hf_config": {
"eagle_aux_hidden_state_layer_ids": [1, 2, 3, 4],
}
@@ -450,7 +450,7 @@ def test_extract_hidden_states_speculative_config_vlm():
target_parallel_config=ParallelConfig(),
method="extract_hidden_states",
num_speculative_tokens=1,
draft_model_config={ # type: ignore[arg-type]
draft_model_config={
"hf_config": {
"eagle_aux_hidden_state_layer_ids": [1, 2],
}
+11 -11
View File
@@ -190,17 +190,17 @@ def test_runtime_length_keeps_trained_checkpoint_geometry(monkeypatch):
for slots in (1, 3):
spec.num_speculative_tokens = slots
head = LiLiCorr(
vllm_config=SimpleNamespace(speculative_config=spec) # type: ignore[arg-type]
vllm_config=SimpleNamespace(speculative_config=spec)
).lilicorr
assert head.slot_embedding.shape == (1, 1, 3, 1, 8)
assert head.relative_slot_bias.shape == (2, 7)
spec.draft_model_config.hf_config.dflash_config["lilicorr_enabled"] = False
with pytest.raises(ValueError, match="lilicorr_enabled"):
LiLiCorr(vllm_config=SimpleNamespace(speculative_config=spec)) # type: ignore[arg-type]
LiLiCorr(vllm_config=SimpleNamespace(speculative_config=spec))
spec.draft_model_config.hf_config.dflash_config["lilicorr_enabled"] = True
spec.num_speculative_tokens = 4
with pytest.raises(ValueError, match="trained block_size"):
LiLiCorr(vllm_config=SimpleNamespace(speculative_config=spec)) # type: ignore[arg-type]
LiLiCorr(vllm_config=SimpleNamespace(speculative_config=spec))
@pytest.mark.parametrize("tp_size", [1, 2])
@@ -269,8 +269,8 @@ def test_candidates_use_global_partition_and_exclude_padding(monkeypatch, tp_siz
)
monkeypatch.setattr(logits_processor, "_topk", lambda x, k: x.topk(k, dim=-1))
ids, values = logits_processor.LogitsProcessor.get_top_k_tokens(
fake, # type: ignore[arg-type]
lm_head, # type: ignore[arg-type]
fake,
lm_head,
torch.empty(2, 1),
2,
return_log_probs=True,
@@ -291,13 +291,13 @@ def test_context_anchor_is_last_committed_normalized_feature():
anchor_valid=torch.ones(4, dtype=torch.bool),
)
batch = SimpleNamespace(num_reqs=2, query_start_loc=torch.tensor([0, 2, 6]))
LiLiCorrSpeculator.prepare_context_anchor(spec, batch, torch.tensor([0, 2])) # type: ignore[arg-type]
LiLiCorrSpeculator.prepare_context_anchor(spec, batch, torch.tensor([0, 2]))
torch.testing.assert_close(spec.anchor_hidden[:2], norm(hidden[[1, 3]]))
assert spec.anchor_valid.tolist() == [True, True, False, False]
assert not spec.anchor_hidden[2:].any()
# A smaller reordered batch must not retain an old request's anchor.
batch = SimpleNamespace(num_reqs=1, query_start_loc=torch.tensor([0, 3]))
LiLiCorrSpeculator.prepare_context_anchor(spec, batch, torch.tensor([1])) # type: ignore[arg-type]
LiLiCorrSpeculator.prepare_context_anchor(spec, batch, torch.tensor([1]))
torch.testing.assert_close(spec.anchor_hidden[0], norm(hidden[1]))
assert not spec.anchor_hidden[1:].any()
@@ -321,7 +321,7 @@ def test_candidate_generation_routes_scores_and_adaptive_inputs(monkeypatch, lil
monkeypatch.setattr(DFlashSpeculator, "__init__", init_base)
cls = LiLiCorrSpeculator if lilicorr else DFlash2Speculator
spec = cls(None, torch.device("cpu")) # type: ignore[arg-type]
spec = cls(None, torch.device("cpu"))
hidden = torch.arange(36).float().view(9, 4)
spec._run_model = lambda *args: hidden
spec.sample_indices = torch.tensor([1, 2, 4, 5, 7, 8])
@@ -334,7 +334,7 @@ def test_candidate_generation_routes_scores_and_adaptive_inputs(monkeypatch, lil
spec.draft_logits = None
spec.use_fp64_gumbel = False
spec.enable_adaptive_verification = True
spec.input_buffers = SimpleNamespace(input_ids=torch.arange(9)) # type: ignore[assignment]
spec.input_buffers = SimpleNamespace(input_ids=torch.arange(9))
candidates = torch.arange(24).view(6, 4)
log_probs = candidates.float().log_softmax(-1)
scores = torch.randn(3, 2, 4, 4)
@@ -636,7 +636,7 @@ def owned_head_model(monkeypatch):
compilation_config=CompilationConfig(mode=CompilationMode.NONE),
)
):
model = LiLiCorrForCausalLM(vllm_config=vllm_config) # type: ignore[arg-type]
model = LiLiCorrForCausalLM(vllm_config=vllm_config)
return model, vllm_config
return build
@@ -746,7 +746,7 @@ def test_quantized_head_calls_methods_without_reading_packed_weights(monkeypatch
block_size=4,
rms_norm_eps=1e-6,
config=_config(hidden_size=8),
quant_config=quant_config, # type: ignore[arg-type]
quant_config=quant_config,
prefix="model.lilicorr",
)
with torch.no_grad():
@@ -53,7 +53,7 @@ def _make_proposer(
monkeypatch.setattr(llm_base_proposer, "AttentionGroup", _FakeAttentionGroup)
proposer = EagleProposer.__new__(EagleProposer)
proposer.vllm_config = None # type: ignore[assignment] # Patched backend discovery does not read config.
proposer.vllm_config = None
proposer.device = None
proposer._draft_attn_layer_names = set(layer_names)
proposer.kv_cache_gid = -1
@@ -85,7 +85,7 @@ def test_compute_probs_and_sample_next_token_uses_fp64_exponential_race():
def test_mtp_model_returns_tuple(architecture: str, expected: bool):
proposer = object.__new__(SpecDecodeBaseProposer)
proposer.method = "mtp"
proposer.draft_model_config = SimpleNamespace( # type: ignore[assignment] # Architecture-only config.
proposer.draft_model_config = SimpleNamespace(
hf_config=SimpleNamespace(architectures=[architecture])
)
@@ -700,7 +700,7 @@ def test_verify_rejects_unproposed_drafts():
first_pos = inputs["pos"].view(num_trials, K + 1)[:, 0]
prefill_len = first_pos + 1
rejection_sampler = object.__new__(RejectionSampler)
rejection_sampler.sampler = SimpleNamespace( # type: ignore[assignment]
rejection_sampler.sampler = SimpleNamespace(
apply_sampling_params=lambda logits, *args: logits,
sampling_states=SimpleNamespace(
temperature=SimpleNamespace(gpu=inputs["temperature"]),