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
@@ -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),
|
||||
),
|
||||
|
||||
@@ -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"))
|
||||
|
||||
@@ -652,7 +652,7 @@ def test_eonly_capture_preserves_outputs_across_replay_and_fallback(profile_only
|
||||
encoder.device = device
|
||||
encoder.cudagraph_manager = manager
|
||||
runner = object.__new__(MMEncoderModelRunner)
|
||||
runner.model_state = SimpleNamespace(encoder_runner=encoder) # type: ignore[assignment]
|
||||
runner.model_state = SimpleNamespace(encoder_runner=encoder)
|
||||
# No decoder manager is installed: capture must be encoder-only.
|
||||
with patch(
|
||||
"vllm.v1.worker.mm_encoder_model_runner.lock_workspace", wraps=lock_workspace
|
||||
@@ -673,7 +673,7 @@ def test_eonly_capture_preserves_outputs_across_replay_and_fallback(profile_only
|
||||
with patch(
|
||||
"vllm.v1.worker.gpu.ec_connector.get_ec_transfer", return_value=connector
|
||||
):
|
||||
ec = ActiveECConnector(SimpleNamespace(), cache) # type: ignore[arg-type]
|
||||
ec = ActiveECConnector(SimpleNamespace(), cache)
|
||||
scheduled = cast(
|
||||
SchedulerOutput,
|
||||
SimpleNamespace(
|
||||
@@ -716,7 +716,7 @@ def test_eonly_without_encoder_graph_skips_capture():
|
||||
encoder = object.__new__(EncoderRunner)
|
||||
encoder.cudagraph_manager = None
|
||||
runner = object.__new__(MMEncoderModelRunner)
|
||||
runner.model_state = SimpleNamespace(encoder_runner=encoder) # type: ignore[assignment]
|
||||
runner.model_state = SimpleNamespace(encoder_runner=encoder)
|
||||
assert runner.capture_model() == 0
|
||||
|
||||
|
||||
@@ -1023,7 +1023,7 @@ class TestInitInvariantValidation:
|
||||
vllm_config = _MockVllmConfig(token_budgets, max_mm_items)
|
||||
model = _MockModel(min_budget, max_budget)
|
||||
return EncoderCudaGraphManager(
|
||||
vllm_config=vllm_config, # type: ignore[arg-type]
|
||||
vllm_config=vllm_config,
|
||||
device=torch.device("cpu"),
|
||||
dtype=torch.float32,
|
||||
model=model,
|
||||
|
||||
@@ -61,7 +61,7 @@ async def test_run_eagle_dp(monkeypatch: pytest.MonkeyPatch, attn_backend: str):
|
||||
data_parallel_backend="mp", # ray takes more time
|
||||
trust_remote_code=True,
|
||||
max_model_len=16384,
|
||||
attention_config={"backend": attn_backend}, # type: ignore[arg-type]
|
||||
attention_config={"backend": attn_backend},
|
||||
)
|
||||
|
||||
eagle_engine_args = replace(
|
||||
|
||||
@@ -304,9 +304,9 @@ def test_wait_for_engine_startup_reports_watched_process_exit():
|
||||
wait_for_engine_startup(
|
||||
handshake_socket,
|
||||
[CoreEngine()],
|
||||
parallel_config, # type: ignore[arg-type]
|
||||
parallel_config,
|
||||
coordinated_dp=False,
|
||||
cache_config=None, # type: ignore[arg-type]
|
||||
cache_config=None,
|
||||
launch=launch,
|
||||
)
|
||||
finally:
|
||||
|
||||
@@ -126,7 +126,7 @@ def test_custom_executor_type_checking():
|
||||
model=MODEL,
|
||||
gpu_memory_utilization=0.2,
|
||||
max_model_len=8192,
|
||||
distributed_executor_backend=Mock, # type: ignore[arg-type]
|
||||
distributed_executor_backend=Mock,
|
||||
)
|
||||
LLMEngine.from_engine_args(engine_args)
|
||||
with pytest.raises(ValueError):
|
||||
@@ -134,7 +134,7 @@ def test_custom_executor_type_checking():
|
||||
model=MODEL,
|
||||
gpu_memory_utilization=0.2,
|
||||
max_model_len=8192,
|
||||
distributed_executor_backend=Mock, # type: ignore[arg-type]
|
||||
distributed_executor_backend=Mock,
|
||||
)
|
||||
AsyncLLM.from_engine_args(engine_args)
|
||||
|
||||
|
||||
@@ -480,7 +480,7 @@ def test_reset():
|
||||
|
||||
def test_prom_metrics_observes_manager_counter():
|
||||
prom_metrics = OffloadPromMetrics(
|
||||
vllm_config=_FakeVllmConfig(), # type: ignore[arg-type]
|
||||
vllm_config=_FakeVllmConfig(),
|
||||
metric_types={
|
||||
Gauge: _FakeMetric,
|
||||
Counter: _FakeMetric,
|
||||
@@ -506,7 +506,7 @@ def test_prom_metrics_observes_manager_counter():
|
||||
|
||||
def test_prom_metrics_observes_flat_transfer_metrics_and_legacy_metrics():
|
||||
prom_metrics = OffloadPromMetrics(
|
||||
vllm_config=_FakeVllmConfig(), # type: ignore[arg-type]
|
||||
vllm_config=_FakeVllmConfig(),
|
||||
metric_types={
|
||||
Gauge: _FakeMetric,
|
||||
Counter: _FakeMetric,
|
||||
@@ -568,7 +568,7 @@ def test_prom_metrics_observes_manager_gauge_and_histogram():
|
||||
return_value=_spec_cls_with_metric_definitions(metric_definitions),
|
||||
):
|
||||
prom_metrics = OffloadPromMetrics(
|
||||
vllm_config=_FakeVllmConfig(store_threshold=0), # type: ignore[arg-type]
|
||||
vllm_config=_FakeVllmConfig(store_threshold=0),
|
||||
metric_types={
|
||||
Gauge: _FakeMetric,
|
||||
Counter: _FakeMetric,
|
||||
@@ -612,7 +612,7 @@ def test_prom_metrics_lazily_observes_labeled_metric():
|
||||
return_value=_spec_cls_with_metric_definitions(metric_definitions),
|
||||
):
|
||||
prom_metrics = OffloadPromMetrics(
|
||||
vllm_config=_FakeVllmConfig(store_threshold=0), # type: ignore[arg-type]
|
||||
vllm_config=_FakeVllmConfig(store_threshold=0),
|
||||
metric_types={
|
||||
Gauge: _FakeMetric,
|
||||
Counter: _FakeMetric,
|
||||
@@ -651,7 +651,7 @@ def test_prom_metrics_rejects_wrong_label_count():
|
||||
return_value=_spec_cls_with_metric_definitions(metric_definitions),
|
||||
):
|
||||
prom_metrics = OffloadPromMetrics(
|
||||
vllm_config=_FakeVllmConfig(store_threshold=0), # type: ignore[arg-type]
|
||||
vllm_config=_FakeVllmConfig(store_threshold=0),
|
||||
metric_types={
|
||||
Gauge: _FakeMetric,
|
||||
Counter: _FakeMetric,
|
||||
@@ -672,7 +672,7 @@ def test_prom_metrics_rejects_wrong_label_count():
|
||||
|
||||
def test_prom_metrics_uses_configured_manager_metrics():
|
||||
prom_metrics = OffloadPromMetrics(
|
||||
vllm_config=_FakeVllmConfig(store_threshold=0), # type: ignore[arg-type]
|
||||
vllm_config=_FakeVllmConfig(store_threshold=0),
|
||||
metric_types={
|
||||
Gauge: _FakeMetric,
|
||||
Counter: _FakeMetric,
|
||||
@@ -693,7 +693,7 @@ def test_prom_metrics_registers_tiering_metrics_from_spec():
|
||||
"spec_name": "TieringOffloadingSpec",
|
||||
"secondary_tiers": [],
|
||||
},
|
||||
), # type: ignore[arg-type]
|
||||
),
|
||||
metric_types={
|
||||
Gauge: _FakeMetric,
|
||||
Counter: _FakeMetric,
|
||||
@@ -741,7 +741,7 @@ def test_aggregate_into_empty_stats():
|
||||
def test_prom_metrics_multi_engine_routing():
|
||||
"""Metrics are routed to the correct engine index."""
|
||||
prom_metrics = OffloadPromMetrics(
|
||||
vllm_config=_FakeVllmConfig(), # type: ignore[arg-type]
|
||||
vllm_config=_FakeVllmConfig(),
|
||||
metric_types={
|
||||
Gauge: _FakeMetric,
|
||||
Counter: _FakeMetric,
|
||||
@@ -767,7 +767,7 @@ def test_prom_metrics_multi_engine_routing():
|
||||
def test_prom_metrics_rejects_undeclared_metric():
|
||||
"""observe() asserts if a metric was never declared in metadata."""
|
||||
prom_metrics = OffloadPromMetrics(
|
||||
vllm_config=_FakeVllmConfig(store_threshold=0), # type: ignore[arg-type]
|
||||
vllm_config=_FakeVllmConfig(store_threshold=0),
|
||||
metric_types={
|
||||
Gauge: _FakeMetric,
|
||||
Counter: _FakeMetric,
|
||||
|
||||
@@ -1543,7 +1543,7 @@ def test_store_sending_thread_reports_job_when_the_preamble_raises():
|
||||
# every dequeue leaves through the same exit.
|
||||
thread = _make_store_sending_thread(MagicMock())
|
||||
req = _make_store_req("req-a", [b"a0", b"a1"])
|
||||
req.token_len_chunk = None # type: ignore[assignment]
|
||||
req.token_len_chunk = None
|
||||
|
||||
with contextlib.suppress(TypeError):
|
||||
_run_store_req(thread, req)
|
||||
|
||||
@@ -114,7 +114,7 @@ def get_default_xfer_telemetry(
|
||||
class AttributeDict(dict):
|
||||
__slots__ = ()
|
||||
__getattr__ = dict.__getitem__
|
||||
__setattr__ = dict.__setitem__ # type: ignore[assignment]
|
||||
__setattr__ = dict.__setitem__
|
||||
|
||||
# We can't instantiate nixlXferTelemetry because it's read only and
|
||||
# ray env does not have NIXL, so we must fake it
|
||||
|
||||
@@ -1256,7 +1256,7 @@ class TestPushWriterNegative:
|
||||
w = _StubWriterWorker.fresh()
|
||||
for bogus_rid in (123, None, 4.5, b"bytes-not-str"):
|
||||
payload = _registration_data("placeholder")
|
||||
payload["request_id"] = bogus_rid # type: ignore[assignment]
|
||||
payload["request_id"] = bogus_rid
|
||||
notif = PUSH_REG_NOTIF_PREFIX + msgspec.msgpack.encode(payload)
|
||||
w._handle_push_reg_notif(notif)
|
||||
assert w._pending_d_registrations == {}
|
||||
|
||||
@@ -349,10 +349,10 @@ class TestServeExternalRequests:
|
||||
mgr._failed_serve_ctxs = [ctx]
|
||||
sess_a = _RecordingSession()
|
||||
sess_b = _RecordingSession()
|
||||
mgr._sessions = {"a": sess_a, "b": sess_b} # type: ignore[assignment]
|
||||
mgr._sessions = {"a": sess_a, "b": sess_b}
|
||||
|
||||
parent = _RecordingParent()
|
||||
mgr.serve_external_requests(parent) # type: ignore[arg-type]
|
||||
mgr.serve_external_requests(parent)
|
||||
|
||||
# Failed serve released and queue cleared.
|
||||
assert parent.finished == ["p2p:peer:req-1:lu1"]
|
||||
@@ -364,10 +364,10 @@ class TestServeExternalRequests:
|
||||
def test_no_failed_serves_still_serves_sessions(self):
|
||||
mgr = _make_manager()
|
||||
sess = _RecordingSession()
|
||||
mgr._sessions = {"a": sess} # type: ignore[assignment]
|
||||
mgr._sessions = {"a": sess}
|
||||
|
||||
parent = _RecordingParent()
|
||||
mgr.serve_external_requests(parent) # type: ignore[arg-type]
|
||||
mgr.serve_external_requests(parent)
|
||||
|
||||
assert parent.finished == []
|
||||
assert sess.served_with == [parent]
|
||||
@@ -427,7 +427,7 @@ class TestSubmitStore:
|
||||
forwards directly to that session rather than re-buffering."""
|
||||
mgr = _make_manager()
|
||||
bound = _FakeSession(peer_id="10.0.0.1:8000", connected=True)
|
||||
mgr._kv_to_session["req-1"] = bound # type: ignore[assignment]
|
||||
mgr._kv_to_session["req-1"] = bound
|
||||
# Note: _sessions is intentionally untouched — this test isolates
|
||||
# the kv_request_id → session fast path.
|
||||
job = _job_metadata(
|
||||
@@ -495,7 +495,7 @@ class TestSubmitLoad:
|
||||
mgr = _make_manager()
|
||||
peer_id = "10.0.0.1:8000"
|
||||
existing = _FakeSession(peer_id=peer_id, connected=True)
|
||||
mgr._sessions[peer_id] = existing # type: ignore[assignment]
|
||||
mgr._sessions[peer_id] = existing
|
||||
job = _job_metadata(
|
||||
job_id=42,
|
||||
keys=[b"k1", b"k2"],
|
||||
@@ -581,7 +581,7 @@ class TestOnRequestFinished:
|
||||
(FetchMsg received) routes via _kv_to_session and pops the entry."""
|
||||
mgr = _make_manager()
|
||||
bound = _FakeSession(peer_id="some-peer:1", connected=True)
|
||||
mgr._kv_to_session["req-1"] = bound # type: ignore[assignment]
|
||||
mgr._kv_to_session["req-1"] = bound
|
||||
ctx = _req_context(kv_params=_remote_decoder_kv_params(kv_request_id="req-1"))
|
||||
mgr.on_request_finished(ctx)
|
||||
assert bound.finishes == ["req-1"]
|
||||
@@ -718,8 +718,8 @@ class TestGetFinished:
|
||||
def poll(self):
|
||||
return []
|
||||
|
||||
mgr._control = FakeControl() # type: ignore[assignment]
|
||||
mgr._data = None # type: ignore[assignment]
|
||||
mgr._control = FakeControl()
|
||||
mgr._data = None
|
||||
return mgr
|
||||
|
||||
def test_drains_finished_jobs(self):
|
||||
@@ -740,7 +740,7 @@ class TestGetFinished:
|
||||
pass
|
||||
|
||||
mgr = self._make()
|
||||
mgr._data = FakeData() # type: ignore[assignment]
|
||||
mgr._data = FakeData()
|
||||
dead = _FakeSession(
|
||||
peer_id="dead:1234",
|
||||
alive=False,
|
||||
@@ -749,7 +749,7 @@ class TestGetFinished:
|
||||
close_req_ids=["req-load"],
|
||||
close_stores=[10, 11],
|
||||
)
|
||||
mgr._sessions["dead:1234"] = dead # type: ignore[assignment]
|
||||
mgr._sessions["dead:1234"] = dead
|
||||
|
||||
results = list(mgr.get_finished_jobs())
|
||||
# 2 baseline + 1 failed load + 2 failed stores
|
||||
@@ -769,14 +769,14 @@ class TestGetFinished:
|
||||
pass
|
||||
|
||||
mgr = self._make()
|
||||
mgr._data = FakeData() # type: ignore[assignment]
|
||||
mgr._data = FakeData()
|
||||
dead = _FakeSession(
|
||||
peer_id="dead:1234",
|
||||
alive=False,
|
||||
connected=True,
|
||||
close_req_ids=["req-probe-1", "req-probe-2"],
|
||||
)
|
||||
mgr._sessions["dead:1234"] = dead # type: ignore[assignment]
|
||||
mgr._sessions["dead:1234"] = dead
|
||||
|
||||
list(mgr.get_finished_jobs())
|
||||
assert "dead:1234" not in mgr._sessions
|
||||
@@ -854,7 +854,7 @@ class TestHasPendingWork:
|
||||
"""The result is the same regardless of session state — there is
|
||||
no 'idle' branch."""
|
||||
mgr = _make_manager()
|
||||
mgr._sessions["peer:1"] = _FakeSession(peer_id="peer:1") # type: ignore[assignment]
|
||||
mgr._sessions["peer:1"] = _FakeSession(peer_id="peer:1")
|
||||
assert mgr.has_pending_work() is True
|
||||
|
||||
|
||||
@@ -919,12 +919,12 @@ class TestShutdownDrain:
|
||||
mgr = _make_manager()
|
||||
data = _ShutdownFakeData(still_queue=still_queue)
|
||||
control = _ShutdownFakeControl()
|
||||
mgr._data = data # type: ignore[assignment]
|
||||
mgr._control = control # type: ignore[assignment]
|
||||
mgr._data = data
|
||||
mgr._control = control
|
||||
if inflight_ids:
|
||||
session = _FakeSession(peer_id="peer:1", connected=True)
|
||||
session._server._inflight = {tid: object() for tid in inflight_ids}
|
||||
mgr._sessions["peer:1"] = session # type: ignore[assignment]
|
||||
mgr._sessions["peer:1"] = session
|
||||
return mgr, data, control
|
||||
|
||||
def test_shutdown_drains_inflight_via_wait_cancel(self):
|
||||
@@ -1148,10 +1148,10 @@ def _build_paired_managers() -> tuple[P2PSecondaryTierManager, P2PSecondaryTierM
|
||||
ctrl_b = _LoopbackControl(mgr_b._local_id)
|
||||
ctrl_a.pair(ctrl_b)
|
||||
|
||||
mgr_a._control = ctrl_a # type: ignore[assignment]
|
||||
mgr_b._control = ctrl_b # type: ignore[assignment]
|
||||
mgr_a._data = _FakeData(mgr_a._local_id) # type: ignore[assignment]
|
||||
mgr_b._data = _FakeData(mgr_b._local_id) # type: ignore[assignment]
|
||||
mgr_a._control = ctrl_a
|
||||
mgr_b._control = ctrl_b
|
||||
mgr_a._data = _FakeData(mgr_a._local_id)
|
||||
mgr_b._data = _FakeData(mgr_b._local_id)
|
||||
|
||||
return mgr_a, mgr_b
|
||||
|
||||
@@ -1334,7 +1334,7 @@ class TestAcceptNewPeers:
|
||||
mgr = _make_manager()
|
||||
peer_id = "10.0.0.1:8000"
|
||||
existing = _FakeSession(peer_id=peer_id, connected=True)
|
||||
mgr._sessions[peer_id] = existing # type: ignore[assignment]
|
||||
mgr._sessions[peer_id] = existing
|
||||
|
||||
new_conn = _RecordingConn(peer_id)
|
||||
mgr._accept_new_peers([new_conn])
|
||||
@@ -1365,7 +1365,7 @@ class TestAcceptNewPeers:
|
||||
pass
|
||||
|
||||
mgr = _make_manager()
|
||||
mgr._data = FakeData() # type: ignore[assignment]
|
||||
mgr._data = FakeData()
|
||||
peer_id = "10.0.0.1:8000"
|
||||
|
||||
# Real ControlConnection-shaped fake: send/close/peer_id only.
|
||||
@@ -1382,7 +1382,7 @@ class TestAcceptNewPeers:
|
||||
def close(self) -> None:
|
||||
self.alive = False
|
||||
|
||||
mgr._accept_new_peers([_Conn(peer_id)]) # type: ignore[arg-type]
|
||||
mgr._accept_new_peers([_Conn(peer_id)])
|
||||
|
||||
assert peer_id in mgr._sessions
|
||||
assert mgr._sessions[peer_id].connected is True
|
||||
@@ -1411,7 +1411,7 @@ class TestPollOnce:
|
||||
loads=[LoadResult(job_id=11, kv_request_id="req-11", success=True)],
|
||||
stores=[StoreResult(job_id=22, success=True)],
|
||||
)
|
||||
mgr._sessions[peer_alive] = alive # type: ignore[assignment]
|
||||
mgr._sessions[peer_alive] = alive
|
||||
|
||||
# Dead session whose pending close() jobs surface as failures.
|
||||
peer_dead = "10.0.0.3:9999"
|
||||
@@ -1423,7 +1423,7 @@ class TestPollOnce:
|
||||
close_req_ids=["req-33"],
|
||||
close_stores=[44],
|
||||
)
|
||||
mgr._sessions[peer_dead] = dead # type: ignore[assignment]
|
||||
mgr._sessions[peer_dead] = dead
|
||||
|
||||
class _Ctrl:
|
||||
def poll(self_inner):
|
||||
@@ -1433,8 +1433,8 @@ class TestPollOnce:
|
||||
def remove_remote_peer(self_inner, pid):
|
||||
pass
|
||||
|
||||
mgr._control = _Ctrl() # type: ignore[assignment]
|
||||
mgr._data = _Data() # type: ignore[assignment]
|
||||
mgr._control = _Ctrl()
|
||||
mgr._data = _Data()
|
||||
|
||||
mgr._poll_once()
|
||||
|
||||
@@ -1464,7 +1464,7 @@ class TestPollOnce:
|
||||
connected=True,
|
||||
new_fetch_ids=["req-1"],
|
||||
)
|
||||
mgr._sessions[peer] = sess # type: ignore[assignment]
|
||||
mgr._sessions[peer] = sess
|
||||
mgr._unbound_stores["req-1"] = [
|
||||
_UnboundStoreBatch(job_id=5, keys=[b"k1"], block_ids=[0]),
|
||||
_UnboundStoreBatch(job_id=6, keys=[b"k2"], block_ids=[1]),
|
||||
@@ -1474,7 +1474,7 @@ class TestPollOnce:
|
||||
def poll(self_inner):
|
||||
return []
|
||||
|
||||
mgr._control = _Ctrl() # type: ignore[assignment]
|
||||
mgr._control = _Ctrl()
|
||||
mgr._poll_once()
|
||||
|
||||
assert mgr._kv_to_session["req-1"] is sess
|
||||
@@ -1496,13 +1496,13 @@ class TestPollOnce:
|
||||
connected=True,
|
||||
new_fetch_ids=["req-fast"],
|
||||
)
|
||||
mgr._sessions[peer] = sess # type: ignore[assignment]
|
||||
mgr._sessions[peer] = sess
|
||||
|
||||
class _Ctrl:
|
||||
def poll(self_inner):
|
||||
return []
|
||||
|
||||
mgr._control = _Ctrl() # type: ignore[assignment]
|
||||
mgr._control = _Ctrl()
|
||||
mgr._poll_once()
|
||||
|
||||
assert mgr._kv_to_session["req-fast"] is sess
|
||||
@@ -1519,13 +1519,13 @@ class TestPollOnce:
|
||||
connected=True,
|
||||
loads=[LoadResult(job_id=5, kv_request_id="req-5", success=False)],
|
||||
)
|
||||
mgr._sessions[peer] = sess # type: ignore[assignment]
|
||||
mgr._sessions[peer] = sess
|
||||
|
||||
class _Ctrl:
|
||||
def poll(self_inner):
|
||||
return []
|
||||
|
||||
mgr._control = _Ctrl() # type: ignore[assignment]
|
||||
mgr._control = _Ctrl()
|
||||
|
||||
mgr._poll_once()
|
||||
|
||||
@@ -1549,26 +1549,26 @@ class TestDrainJobs:
|
||||
def test_returns_immediately_when_quiescent(self):
|
||||
"""No sessions and no inflight: drain_jobs returns without sleeping."""
|
||||
mgr = _make_manager()
|
||||
mgr._control = _DrainCtrl() # type: ignore[assignment]
|
||||
mgr._control = _DrainCtrl()
|
||||
|
||||
sleeps: list[float] = []
|
||||
# If drain_jobs sleeps when nothing is pending, that's a regression.
|
||||
import vllm.v1.kv_offload.tiering.p2p.manager as m
|
||||
|
||||
original_sleep = m.time.sleep
|
||||
m.time.sleep = lambda s: sleeps.append(s) # type: ignore[assignment]
|
||||
m.time.sleep = lambda s: sleeps.append(s)
|
||||
try:
|
||||
mgr.drain_jobs()
|
||||
finally:
|
||||
m.time.sleep = original_sleep # type: ignore[assignment]
|
||||
m.time.sleep = original_sleep
|
||||
|
||||
assert sleeps == []
|
||||
|
||||
def test_returns_when_session_has_no_inflight_or_inbound(self):
|
||||
"""A session with empty _inbound and _inflight does not block drain."""
|
||||
mgr = _make_manager()
|
||||
mgr._control = _DrainCtrl() # type: ignore[assignment]
|
||||
mgr._sessions["peer:1"] = _FakeSession(peer_id="peer:1") # type: ignore[assignment]
|
||||
mgr._control = _DrainCtrl()
|
||||
mgr._sessions["peer:1"] = _FakeSession(peer_id="peer:1")
|
||||
# Should return on the first iteration.
|
||||
mgr.drain_jobs()
|
||||
|
||||
@@ -1576,10 +1576,10 @@ class TestDrainJobs:
|
||||
"""A session that stays inflight past 5s triggers the warning, and
|
||||
once it clears the loop returns."""
|
||||
mgr = _make_manager()
|
||||
mgr._control = _DrainCtrl() # type: ignore[assignment]
|
||||
mgr._control = _DrainCtrl()
|
||||
sess = _FakeSession(peer_id="peer:1")
|
||||
sess._server._inflight = {1: object()} # non-empty
|
||||
mgr._sessions["peer:1"] = sess # type: ignore[assignment]
|
||||
mgr._sessions["peer:1"] = sess
|
||||
|
||||
# Synthetic monotonic clock: 100.0 for the start stamp, then 106.0
|
||||
# for the first elapsed-check (past the 5s warning threshold), then
|
||||
|
||||
@@ -288,17 +288,17 @@ def _make_session(
|
||||
session = P2PSession(
|
||||
peer_id=peer_id,
|
||||
local_id=local_id,
|
||||
transport=transport, # type: ignore[arg-type]
|
||||
transport=transport,
|
||||
local_block_len=transport.block_len,
|
||||
local_hash_seed=local_hash_seed,
|
||||
conn=conn, # type: ignore[arg-type]
|
||||
conn=conn,
|
||||
)
|
||||
return session, conn, transport
|
||||
|
||||
|
||||
def _serve(session: P2PSession, parent: FakeParent) -> None:
|
||||
"""Resolve enqueued inbound lookups, as the manager does each step."""
|
||||
session.serve_external_requests(parent) # type: ignore[arg-type]
|
||||
session.serve_external_requests(parent)
|
||||
|
||||
|
||||
def _activate(
|
||||
@@ -1951,7 +1951,7 @@ class TestFinishRequestServerSide:
|
||||
)
|
||||
session.poll()
|
||||
# Force write_blocks to fail on the next call.
|
||||
transport.write_blocks = lambda *a, **kw: None # type: ignore[assignment]
|
||||
transport.write_blocks = lambda *a, **kw: None # type: ignore[method-assign]
|
||||
|
||||
session.add_stored_blocks("req-1", [b"k1"], [0], job_id=42)
|
||||
|
||||
@@ -2057,7 +2057,7 @@ class TestFinishRequestServerSide:
|
||||
assert outbound.finishing is False
|
||||
|
||||
# Round 2: write_blocks fails for k2 while transfer_1 is still inflight.
|
||||
transport.write_blocks = lambda *a, **kw: None # type: ignore[assignment]
|
||||
transport.write_blocks = lambda *a, **kw: None # type: ignore[method-assign]
|
||||
session.add_stored_blocks("req-1", [b"k2"], [1], job_id=200)
|
||||
# No new transfer was registered.
|
||||
assert list(session._server._inflight.keys()) == [tid_1]
|
||||
@@ -2163,7 +2163,7 @@ class TestPendingSession:
|
||||
session = P2PSession(
|
||||
peer_id="peer:8000",
|
||||
local_id="local:9000",
|
||||
transport=transport, # type: ignore[arg-type]
|
||||
transport=transport,
|
||||
local_block_len=4096,
|
||||
local_hash_seed=_DEFAULT_HASH_SEED,
|
||||
conn=None,
|
||||
@@ -2183,13 +2183,13 @@ class TestPendingSession:
|
||||
session = P2PSession(
|
||||
peer_id="peer:8000",
|
||||
local_id="local:9000",
|
||||
transport=transport, # type: ignore[arg-type]
|
||||
transport=transport,
|
||||
local_block_len=4096,
|
||||
local_hash_seed=_DEFAULT_HASH_SEED,
|
||||
conn=None,
|
||||
)
|
||||
conn = FakeConnection(peer_id="peer:8000")
|
||||
session.attach_connection(conn) # type: ignore[arg-type]
|
||||
session.attach_connection(conn)
|
||||
assert conn._sent
|
||||
assert conn._sent[0][TYPE_KEY] == ConnectMsg.TYPE
|
||||
|
||||
@@ -2197,7 +2197,7 @@ class TestPendingSession:
|
||||
"""attach_connection on an already-connected session raises."""
|
||||
session, conn, _ = _make_session()
|
||||
with pytest.raises(ValueError, match="already connected"):
|
||||
session.attach_connection(FakeConnection()) # type: ignore[arg-type]
|
||||
session.attach_connection(FakeConnection())
|
||||
|
||||
def test_pending_close_returns_pending_stores(self):
|
||||
"""Closing a pending session reports buffered stores as failed."""
|
||||
@@ -2205,7 +2205,7 @@ class TestPendingSession:
|
||||
session = P2PSession(
|
||||
peer_id="peer:8000",
|
||||
local_id="local:9000",
|
||||
transport=transport, # type: ignore[arg-type]
|
||||
transport=transport,
|
||||
local_block_len=4096,
|
||||
local_hash_seed=_DEFAULT_HASH_SEED,
|
||||
conn=None,
|
||||
@@ -2313,7 +2313,7 @@ class TestAdversarial:
|
||||
def test_non_dict_message(self):
|
||||
session, conn, _ = _make_session()
|
||||
_activate(session, conn)
|
||||
conn._inbox.append(42) # type: ignore[arg-type]
|
||||
conn._inbox.append(42)
|
||||
result_ = session.poll()
|
||||
loads = result_.loads
|
||||
stores = result_.stores
|
||||
@@ -2402,7 +2402,7 @@ class TestDispatchErrorHandling:
|
||||
def _boom(*args, **kwargs):
|
||||
raise RuntimeError("simulated internal bug")
|
||||
|
||||
session._server.on_fetch = _boom # type: ignore[assignment]
|
||||
session._server.on_fetch = _boom
|
||||
conn.enqueue(
|
||||
{
|
||||
TYPE_KEY: FetchMsg.TYPE,
|
||||
@@ -2425,7 +2425,7 @@ class TestDispatchErrorHandling:
|
||||
def _boom(*args, **kwargs):
|
||||
raise RuntimeError("simulated internal bug")
|
||||
|
||||
session._server.on_fetch = _boom # type: ignore[assignment]
|
||||
session._server.on_fetch = _boom
|
||||
for _ in range(_MAX_CONSECUTIVE_DISPATCH_ERRORS):
|
||||
conn.enqueue(
|
||||
{
|
||||
@@ -2454,7 +2454,7 @@ class TestDispatchErrorHandling:
|
||||
# Alternate (boom, success) (_MAX-1) times: counter rises to 1
|
||||
# then resets to 0 each cycle, never reaching the threshold.
|
||||
for _ in range(_MAX_CONSECUTIVE_DISPATCH_ERRORS - 1):
|
||||
session._server.on_fetch = _boom # type: ignore[assignment]
|
||||
session._server.on_fetch = _boom
|
||||
conn.enqueue(
|
||||
{
|
||||
TYPE_KEY: FetchMsg.TYPE,
|
||||
@@ -2465,7 +2465,7 @@ class TestDispatchErrorHandling:
|
||||
}
|
||||
)
|
||||
session.poll()
|
||||
session._server.on_fetch = original_on_fetch # type: ignore[assignment]
|
||||
session._server.on_fetch = original_on_fetch
|
||||
# A benign no-op message (unknown type) dispatches cleanly
|
||||
# and resets the consecutive-error counter.
|
||||
conn.enqueue({TYPE_KEY: "unknown_for_test"})
|
||||
|
||||
@@ -340,7 +340,7 @@ def _make_v2_state(
|
||||
device=device,
|
||||
all_token_ids=SimpleNamespace(gpu=all_tokens),
|
||||
)
|
||||
state = DryState(_make_vllm_config(), req_states) # type: ignore[arg-type]
|
||||
state = DryState(_make_vllm_config(), req_states)
|
||||
if tokenizer is not None:
|
||||
# Re-resolve the default set now that a tokenizer is installed.
|
||||
state._tokenizer = tokenizer
|
||||
@@ -446,7 +446,7 @@ def test_spec_decode_is_refused_at_construction():
|
||||
)
|
||||
config = _make_vllm_config(speculative_config=SimpleNamespace())
|
||||
with pytest.raises(ValueError, match="speculative decoding"):
|
||||
DryState(config, req_states) # type: ignore[arg-type]
|
||||
DryState(config, req_states)
|
||||
|
||||
|
||||
def test_v2_draft_expanded_logits_raise():
|
||||
@@ -918,7 +918,7 @@ def test_loads_through_the_loader_by_fqcn():
|
||||
)
|
||||
procs = loader.build_custom_logits_processors(
|
||||
_make_vllm_config(),
|
||||
req_states, # type: ignore[arg-type]
|
||||
req_states,
|
||||
False,
|
||||
[DRY_FQCN],
|
||||
)
|
||||
|
||||
@@ -486,12 +486,12 @@ def test_prompt_logprob_token_ids_require_v2_model_runner():
|
||||
params = SamplingParams(prompt_logprob_token_ids=[1, 2])
|
||||
with patch.object(SamplingParams, "verify"):
|
||||
with pytest.raises(VLLMValidationError, match="V2 model runner"):
|
||||
InputProcessor._validate_params(processor, params, ("generate",)) # type: ignore[arg-type]
|
||||
InputProcessor._validate_params(processor, params, ("generate",))
|
||||
processor.vllm_config.use_v2_model_runner = True
|
||||
InputProcessor._validate_params(processor, params, ("generate",)) # type: ignore[arg-type]
|
||||
InputProcessor._validate_params(processor, params, ("generate",))
|
||||
processor.vllm_config.cache_config.kv_sharing_fast_prefill = True
|
||||
with pytest.raises(VLLMValidationError, match="fast-prefill"):
|
||||
InputProcessor._validate_params(processor, params, ("generate",)) # type: ignore[arg-type]
|
||||
InputProcessor._validate_params(processor, params, ("generate",))
|
||||
|
||||
|
||||
def test_none_logprobs(vllm_model, example_prompts):
|
||||
|
||||
@@ -105,7 +105,7 @@ def test_trace_decode_token_ids_rejects_speculative_decoding():
|
||||
with pytest.raises(ValueError, match="not supported with speculative decoding"):
|
||||
params._validate_trace_replay(
|
||||
_make_model_config(vocab_size=100),
|
||||
speculative_config=object(), # type: ignore[arg-type] # Only non-None presence is tested.
|
||||
speculative_config=object(),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ SLEEP_CYCLES = 50_000_000
|
||||
def _make_worker(
|
||||
kv_cache_config: KVCacheConfig | None, cpu_capacity_bytes: int
|
||||
) -> SimpleCPUOffloadWorker:
|
||||
return SimpleCPUOffloadWorker(None, kv_cache_config, cpu_capacity_bytes) # type: ignore[arg-type]
|
||||
return SimpleCPUOffloadWorker(None, kv_cache_config, cpu_capacity_bytes)
|
||||
|
||||
|
||||
def _make_backend() -> tuple[DmaCopyBackend, torch.Tensor, torch.Tensor]:
|
||||
@@ -121,7 +121,7 @@ def test_no_forward_step_completes_cpu_store(monkeypatch, use_v2):
|
||||
monkeypatch.setattr(f"{module}.get_forward_context", lambda: None)
|
||||
result = active.no_forward(output)
|
||||
else:
|
||||
result = KVConnectorModelRunnerMixin.kv_connector_no_forward(output, None) # type: ignore[arg-type]
|
||||
result = KVConnectorModelRunnerMixin.kv_connector_no_forward(output, None)
|
||||
completion = (
|
||||
result.kv_connector_output.kv_connector_worker_meta
|
||||
if result.kv_connector_output is not None
|
||||
@@ -283,7 +283,7 @@ def test_transfer_hooks_pass_wait_event_for_store_only():
|
||||
cpu_capacity_bytes=0,
|
||||
)
|
||||
recording = _RecordingBackend()
|
||||
worker._backend = recording # type: ignore[assignment]
|
||||
worker._backend = recording
|
||||
worker._connector_metadata = SimpleCPUOffloadMetadata(
|
||||
load_event=0,
|
||||
load_gpu_blocks=[0],
|
||||
|
||||
@@ -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]]] = {}
|
||||
|
||||
@@ -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],
|
||||
}
|
||||
|
||||
@@ -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"]),
|
||||
|
||||
@@ -48,9 +48,9 @@ def _validate(
|
||||
) -> StructuredOutputsParams:
|
||||
params = SamplingParams(structured_outputs=StructuredOutputsParams(grammar=grammar))
|
||||
params._validate_structured_outputs(
|
||||
_StubModelConfig(), # type: ignore[arg-type]
|
||||
_StubModelConfig(),
|
||||
StructuredOutputsConfig(backend=backend),
|
||||
tokenizer=tokenizer or object(), # type: ignore[arg-type]
|
||||
tokenizer=tokenizer or object(),
|
||||
)
|
||||
assert params.structured_outputs is not None
|
||||
return params.structured_outputs
|
||||
|
||||
@@ -51,7 +51,7 @@ def make_vllm_config() -> VllmConfig:
|
||||
config = VllmConfig(
|
||||
structured_outputs_config=StructuredOutputsConfig(backend="xgrammar"),
|
||||
)
|
||||
config.model_config = SimpleNamespace( # type: ignore[assignment]
|
||||
config.model_config = SimpleNamespace(
|
||||
hf_config=SimpleNamespace(model_type="plamo3")
|
||||
)
|
||||
return config
|
||||
@@ -73,7 +73,7 @@ def test_plamo3_python_tokenizer_compiles_and_accepts_structural_tag():
|
||||
tokenizer = Plamo3Tokenizer(["<eos>", *call_tokens])
|
||||
backend = XgrammarBackend(
|
||||
make_vllm_config(),
|
||||
tokenizer=tokenizer, # type: ignore[arg-type]
|
||||
tokenizer=tokenizer,
|
||||
vocab_size=len(tokenizer.get_vocab()),
|
||||
)
|
||||
tools = [
|
||||
@@ -107,7 +107,7 @@ def test_plamo3_grammar_matches_decoded_bytes(value):
|
||||
tokenizer = Plamo3Tokenizer(list(dict.fromkeys(["<eos>", value, *pieces])))
|
||||
backend = XgrammarBackend(
|
||||
make_vllm_config(),
|
||||
tokenizer=tokenizer, # type: ignore[arg-type]
|
||||
tokenizer=tokenizer,
|
||||
vocab_size=len(tokenizer.get_vocab()),
|
||||
)
|
||||
for tokens in ([value], pieces):
|
||||
|
||||
@@ -108,7 +108,7 @@ def _build_harness(
|
||||
)
|
||||
manager = StructuredOutputManager(vllm_config)
|
||||
if use_reasoner:
|
||||
manager.reasoner_cls = MockReasoner # type: ignore[assignment]
|
||||
manager.reasoner_cls = MockReasoner
|
||||
|
||||
sampling_params = SamplingParams(
|
||||
structured_outputs=structured_outputs
|
||||
|
||||
@@ -35,7 +35,7 @@ def test_structured_outputs_rejected_for_diffusion_models():
|
||||
)
|
||||
with pytest.raises(VLLMValidationError, match="not yet supported for diffusion"):
|
||||
params._validate_structured_outputs(
|
||||
_StubModelConfig(is_diffusion=True), # type: ignore[arg-type]
|
||||
_StubModelConfig(is_diffusion=True),
|
||||
StructuredOutputsConfig(),
|
||||
tokenizer=None,
|
||||
)
|
||||
@@ -45,7 +45,7 @@ def test_plain_request_allowed_for_diffusion_models():
|
||||
"""Requests without structured outputs are unaffected by the guard."""
|
||||
params = SamplingParams()
|
||||
params._validate_structured_outputs(
|
||||
_StubModelConfig(is_diffusion=True), # type: ignore[arg-type]
|
||||
_StubModelConfig(is_diffusion=True),
|
||||
StructuredOutputsConfig(),
|
||||
tokenizer=None,
|
||||
)
|
||||
@@ -71,9 +71,9 @@ def test_degenerate_structured_outputs_rejected(structured_outputs, match):
|
||||
params = SamplingParams(structured_outputs=structured_outputs)
|
||||
with pytest.raises(VLLMValidationError, match=match):
|
||||
params._validate_structured_outputs(
|
||||
_StubModelConfig(is_diffusion=False), # type: ignore[arg-type]
|
||||
_StubModelConfig(is_diffusion=False),
|
||||
StructuredOutputsConfig(),
|
||||
tokenizer=object(), # type: ignore[arg-type]
|
||||
tokenizer=object(),
|
||||
)
|
||||
|
||||
|
||||
@@ -97,9 +97,9 @@ def test_regex_with_nul_byte_rejected(regex):
|
||||
# (which would otherwise catch the error and fall back to another backend).
|
||||
with pytest.raises(VLLMValidationError, match="NUL"):
|
||||
params._validate_structured_outputs(
|
||||
_StubModelConfig(is_diffusion=False), # type: ignore[arg-type]
|
||||
_StubModelConfig(is_diffusion=False),
|
||||
StructuredOutputsConfig(),
|
||||
tokenizer=object(), # type: ignore[arg-type]
|
||||
tokenizer=object(),
|
||||
)
|
||||
|
||||
# The xgrammar backend also rejects it directly (defense in depth), before
|
||||
@@ -133,9 +133,9 @@ def test_unsupported_grammar_is_a_client_error(backend, structured_outputs):
|
||||
params = SamplingParams(structured_outputs=structured_outputs)
|
||||
with pytest.raises(VLLMClientError):
|
||||
params._validate_structured_outputs(
|
||||
_StubModelConfig(is_diffusion=False), # type: ignore[arg-type]
|
||||
_StubModelConfig(is_diffusion=False),
|
||||
StructuredOutputsConfig(backend=backend),
|
||||
tokenizer=object(), # type: ignore[arg-type]
|
||||
tokenizer=object(),
|
||||
)
|
||||
|
||||
|
||||
@@ -180,9 +180,9 @@ def test_auto_backend_falls_back_on_unsupported_schema(schema, expected_backend)
|
||||
"""`auto` falls back on rejection, so it must catch what the validators raise."""
|
||||
params = SamplingParams(structured_outputs=StructuredOutputsParams(json=schema))
|
||||
params._validate_structured_outputs(
|
||||
_StubModelConfig(is_diffusion=False), # type: ignore[arg-type]
|
||||
_StubModelConfig(is_diffusion=False),
|
||||
StructuredOutputsConfig(backend="auto"),
|
||||
tokenizer=object(), # type: ignore[arg-type]
|
||||
tokenizer=object(),
|
||||
)
|
||||
assert params.structured_outputs is not None
|
||||
assert params.structured_outputs._backend == expected_backend
|
||||
|
||||
@@ -135,7 +135,7 @@ def test_attention_checks_preserve_global_and_target_scoped_support():
|
||||
_TargetBackend,
|
||||
["target"],
|
||||
spec,
|
||||
0, # type: ignore[arg-type]
|
||||
0,
|
||||
)
|
||||
target_group.metadata_builders = [
|
||||
_FakeMetadataBuilder(AttentionCGSupport.ALWAYS) # type: ignore[list-item]
|
||||
@@ -144,7 +144,7 @@ def test_attention_checks_preserve_global_and_target_scoped_support():
|
||||
_DraftBackend,
|
||||
["draft"],
|
||||
spec,
|
||||
0, # type: ignore[arg-type]
|
||||
0,
|
||||
)
|
||||
draft_group.metadata_builders = [
|
||||
_FakeMetadataBuilder(AttentionCGSupport.UNIFORM_BATCH) # type: ignore[list-item]
|
||||
@@ -152,14 +152,14 @@ def test_attention_checks_preserve_global_and_target_scoped_support():
|
||||
groups = [[target_group, draft_group]]
|
||||
|
||||
# The runner-wide execution mode must still honor the drafter's limit.
|
||||
unfiltered = get_attn_cg_support(groups, None) # type: ignore[arg-type]
|
||||
unfiltered = get_attn_cg_support(groups, None)
|
||||
assert unfiltered.min_cg_support == AttentionCGSupport.UNIFORM_BATCH
|
||||
assert unfiltered.min_cg_attn_backend == "_DraftBackend"
|
||||
|
||||
# Adaptive verification validates only the target's varlen graphs.
|
||||
target_only = get_attn_cg_support(
|
||||
groups,
|
||||
None, # type: ignore[arg-type]
|
||||
None,
|
||||
checked_layer_names={"target"},
|
||||
)
|
||||
assert target_only.min_cg_support == AttentionCGSupport.ALWAYS
|
||||
@@ -176,7 +176,7 @@ def test_attention_checks_preserve_global_and_target_scoped_support():
|
||||
draft_group.layer_names.append("target")
|
||||
target_with_shared_group = get_attn_cg_support(
|
||||
groups,
|
||||
None, # type: ignore[arg-type]
|
||||
None,
|
||||
checked_layer_names={"target"},
|
||||
)
|
||||
assert target_with_shared_group.min_cg_support == AttentionCGSupport.UNIFORM_BATCH
|
||||
|
||||
@@ -39,9 +39,7 @@ def _make_connector(
|
||||
kv_role="kv_consumer",
|
||||
kv_buffer_device="cpu",
|
||||
)
|
||||
connector = ActiveKVConnector( # type: ignore[arg-type]
|
||||
SimpleNamespace(kv_transfer_config=kv_config), {}
|
||||
)
|
||||
connector = ActiveKVConnector(SimpleNamespace(kv_transfer_config=kv_config), {})
|
||||
events.clear()
|
||||
return connector
|
||||
|
||||
@@ -66,7 +64,7 @@ def test_load_start_phase(
|
||||
request_indices = torch.tensor([3, 1])
|
||||
request_ids = ["first", "second"]
|
||||
attn_metadata = {"layer": object()}
|
||||
connector.pre_forward( # type: ignore[arg-type]
|
||||
connector.pre_forward(
|
||||
output,
|
||||
request_state_indices=request_indices,
|
||||
request_ids=request_ids,
|
||||
@@ -85,7 +83,7 @@ def test_load_start_phase(
|
||||
assert kwargs["attn_metadata"] is attn_metadata
|
||||
|
||||
# A subsequent step without a forward must not reuse the prior batch.
|
||||
connector.no_forward(_scheduler_output(False)) # type: ignore[arg-type]
|
||||
connector.no_forward(_scheduler_output(False))
|
||||
assert connector.kv_connector.start_load_kv.call_count == 2
|
||||
assert connector.kv_connector.start_load_kv.call_args.kwargs == {}
|
||||
|
||||
@@ -94,6 +92,6 @@ def test_no_forward_starts_deferred_load_once(monkeypatch: pytest.MonkeyPatch):
|
||||
events: list[str] = []
|
||||
connector = _make_connector(monkeypatch, events)
|
||||
|
||||
connector.no_forward(_scheduler_output(False)) # type: ignore[arg-type]
|
||||
connector.no_forward(_scheduler_output(False))
|
||||
|
||||
assert events == ["handle", "bind", "start", "wait", "clear"]
|
||||
|
||||
@@ -75,7 +75,7 @@ def _make_worker(engine: _RecordingEngine | None) -> Worker:
|
||||
def test_reload_weights_sets_current_config():
|
||||
worker = _make_worker(None)
|
||||
model_runner = _RecordingModelRunner()
|
||||
worker.model_runner = model_runner # type: ignore[assignment]
|
||||
worker.model_runner = model_runner
|
||||
|
||||
Worker.reload_weights(worker)
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ def test_invalid_query_uses_raises():
|
||||
mode=LATE_INTERACTION_MODE_CACHE_QUERY,
|
||||
query_key="query-bad",
|
||||
)
|
||||
bad_meta.query_uses = "bad-int" # type: ignore[assignment]
|
||||
bad_meta.query_uses = "bad-int"
|
||||
bad_query_params = _make_pooling_params(bad_meta)
|
||||
|
||||
with pytest.raises(ValueError, match="must be an integer value"):
|
||||
|
||||
Reference in New Issue
Block a user