Files
vLLM/tests/distributed/test_kv_cache_events.py
MOVZXandHinata 5aa2ac64f8 [Mini-VLLM] Remove LoRA, plugins, speech-to-text and scale-out surfaces
Production runs one static model behind the OpenAI-compatible API. Every
adapter path and non-OpenAI HTTP surface is unreachable there.

- Delete the LoRA stack: vllm/lora, LoRARequest on the engine wire, the
  scheduler, worker, cudagraph and MoE plumbing, LoRA metrics, the lora
  CLI group, and the LoRA tests.
- Drop the plugin loader in vllm/plugins. Platform resolution is now
  CUDA-only and the general/stat-logger plugin hooks are gone.
- Delete the speech-to-text and realtime entrypoints, the scale-out
  render routes, and vllm/config/speech_to_text.py. GenerationTask is
  generate-only.
- Cut DecodeBenchConnector and the disagg-prefill doc and image. The
  Multi, Offloading and Example connectors stay; production uses the
  CPU KV offload tier.
- Delete the ROCm-only fused KDA chunk kernel (2346 lines) with its CMake
  arch gate, declarations and op registrations. The CUDA build never
  defined the guard and no Python caller existed.
- Delete the orphan Mistral and Pixtral chat fixtures and examples/.
- Fix _check_model: removing the LoRA early return made every request
  fail with "The model ... does not exist. Valid aliases: ...".

Verified on an RTX 3090: import sweep reports 1242 modules with 7 known
optional-dependency failures; a live server answers chat, completions,
responses, tokenize and detokenize with zero log errors and 404 for the
removed surfaces; collection yields 8558 tests with the 3 pre-existing
errors; ruff adds no new finding; the incremental _C build succeeds.

Co-authored-by: Hinata <hinata@idihore.id>
Signed-off-by: MOVZX <movzx@yahoo.com>
2026-10-19 21:06:19 +07:00

241 lines
7.6 KiB
Python

# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from typing import Any
import msgspec
import pytest
from vllm.distributed.kv_events import BlockRemoved, BlockStored
# Minimal ExternalBlockHash for testing (bytes are a valid ExternalBlockHash).
_FAKE_HASH: bytes = b"\xab" * 32
class _LegacyBlockStored(
msgspec.Struct,
omit_defaults=True, # type: ignore[call-arg]
gc=False, # type: ignore[call-arg]
tag="BlockStored", # type: ignore[call-arg]
):
"""BlockStored wire schema before locality was added."""
block_hashes: list[bytes]
parent_block_hash: bytes | None
token_ids: list[int]
block_size: int
medium: str | None
extra_keys: list[tuple[Any, ...] | None] | None = None
group_idx: int | None = None
kv_cache_spec_kind: str | None = None
kv_cache_spec_sliding_window: int | None = None
class _LegacyBlockRemoved(
msgspec.Struct,
omit_defaults=True, # type: ignore[call-arg]
gc=False, # type: ignore[call-arg]
tag="BlockRemoved", # type: ignore[call-arg]
):
"""BlockRemoved wire schema before locality was added."""
block_hashes: list[bytes]
medium: str | None
group_idx: int | None = None
class _PreSessionBlockStored(
msgspec.Struct,
omit_defaults=True, # type: ignore[call-arg]
gc=False, # type: ignore[call-arg]
tag="BlockStored", # type: ignore[call-arg]
):
"""BlockStored wire schema before session_id was added."""
block_hashes: list[bytes]
parent_block_hash: bytes | None
token_ids: list[int]
block_size: int
medium: str | None
extra_keys: list[tuple[Any, ...] | None] | None = None
group_idx: int | None = None
kv_cache_spec_kind: str | None = None
kv_cache_spec_sliding_window: int | None = None
locality: str | None = None
def _make_block_stored(
group_idx: int | None = None,
kv_cache_spec_sliding_window: int | None = None,
locality: str | None = None,
session_id: str | None = None,
) -> BlockStored:
return BlockStored(
block_hashes=[_FAKE_HASH],
parent_block_hash=None,
token_ids=[1, 2, 3, 4],
block_size=4,
medium="GPU",
group_idx=group_idx,
kv_cache_spec_sliding_window=kv_cache_spec_sliding_window,
locality=locality,
session_id=session_id,
)
def _make_block_removed(
group_idx: int | None = None,
locality: str | None = None,
) -> BlockRemoved:
return BlockRemoved(
block_hashes=[_FAKE_HASH],
medium="GPU",
group_idx=group_idx,
locality=locality,
)
def test_block_stored_default_group_idx_is_none():
"""group_idx defaults to None when not provided."""
event = _make_block_stored()
assert event.group_idx is None
def test_block_removed_default_group_idx_is_none():
"""group_idx defaults to None when not provided."""
event = _make_block_removed()
assert event.group_idx is None
@pytest.mark.parametrize("group_idx", [1, 2, 3])
def test_block_stored_hash_differs_by_group_idx(group_idx: int):
"""BlockStored events that differ only in group_idx must hash differently."""
other_group_idx = group_idx + 1
event_a = _make_block_stored(group_idx=group_idx)
event_b = _make_block_stored(group_idx=other_group_idx)
assert hash(event_a) != hash(event_b)
def test_block_stored_hash_same_for_equal_group_idx():
"""Two BlockStored events with identical fields produce the same hash."""
event_a = _make_block_stored(group_idx=1)
event_b = _make_block_stored(group_idx=1)
assert hash(event_a) == hash(event_b)
def test_block_stored_hash_differs_by_session_id():
event_a = _make_block_stored(session_id="session-a")
event_b = _make_block_stored(session_id="session-b")
assert hash(event_a) != hash(event_b)
@pytest.mark.parametrize("group_idx", [1, 2, 3])
def test_block_removed_hash_differs_by_group_idx(group_idx: int):
"""BlockRemoved events that differ only in group_idx must hash differently."""
other_group_idx = group_idx + 1
event_a = _make_block_removed(group_idx=group_idx)
event_b = _make_block_removed(group_idx=other_group_idx)
assert hash(event_a) != hash(event_b)
def test_block_removed_hash_same_for_equal_group_idx():
"""Two BlockRemoved events with identical fields produce the same hash."""
event_a = _make_block_removed(group_idx=1)
event_b = _make_block_removed(group_idx=1)
assert hash(event_a) == hash(event_b)
def test_block_stored_hash_differs_by_sliding_window():
event_a = _make_block_stored(group_idx=1, kv_cache_spec_sliding_window=128)
event_b = _make_block_stored(group_idx=1, kv_cache_spec_sliding_window=256)
assert hash(event_a) != hash(event_b)
@pytest.mark.parametrize(
("event_a", "event_b"),
[
(
_make_block_stored(locality="LOCAL"),
_make_block_stored(locality="REMOTE"),
),
(
_make_block_removed(locality="LOCAL"),
_make_block_removed(locality="REMOTE"),
),
],
)
def test_event_hash_differs_by_locality(
event_a: BlockStored | BlockRemoved,
event_b: BlockStored | BlockRemoved,
):
assert hash(event_a) != hash(event_b)
def test_block_stored_locality_is_wire_compatible():
legacy = _LegacyBlockStored(
block_hashes=[_FAKE_HASH],
parent_block_hash=None,
token_ids=[1, 2, 3, 4],
block_size=4,
medium="GPU",
group_idx=2,
kv_cache_spec_sliding_window=128,
)
legacy_payload = msgspec.msgpack.encode(legacy)
assert (
msgspec.msgpack.encode(
_make_block_stored(
group_idx=2,
kv_cache_spec_sliding_window=128,
)
)
== legacy_payload
)
assert msgspec.msgpack.decode(legacy_payload, type=BlockStored).locality is None
new_payload = msgspec.msgpack.encode(_make_block_stored(locality="LOCAL"))
assert msgspec.msgpack.decode(new_payload)["locality"] == "LOCAL"
assert msgspec.msgpack.decode(new_payload, type=_LegacyBlockStored).medium == "GPU"
def test_block_removed_locality_is_wire_compatible():
legacy = _LegacyBlockRemoved(block_hashes=[_FAKE_HASH], medium="GPU")
legacy_payload = msgspec.msgpack.encode(legacy)
assert msgspec.msgpack.encode(_make_block_removed()) == legacy_payload
assert msgspec.msgpack.decode(legacy_payload, type=BlockRemoved).locality is None
new_payload = msgspec.msgpack.encode(_make_block_removed(locality="REMOTE"))
assert msgspec.msgpack.decode(new_payload)["locality"] == "REMOTE"
assert msgspec.msgpack.decode(new_payload, type=_LegacyBlockRemoved).medium == "GPU"
def test_block_stored_session_id_is_wire_compatible():
pre_session = _PreSessionBlockStored(
block_hashes=[_FAKE_HASH],
parent_block_hash=None,
token_ids=[1, 2, 3, 4],
block_size=4,
medium="GPU",
group_idx=2,
kv_cache_spec_sliding_window=128,
locality="LOCAL",
)
pre_session_payload = msgspec.msgpack.encode(pre_session)
assert (
msgspec.msgpack.encode(
_make_block_stored(
group_idx=2,
kv_cache_spec_sliding_window=128,
locality="LOCAL",
)
)
== pre_session_payload
)
assert (
msgspec.msgpack.decode(pre_session_payload, type=BlockStored).session_id is None
)
new_payload = msgspec.msgpack.encode(_make_block_stored(session_id="session-1"))
assert msgspec.msgpack.decode(new_payload)["session_id"] == "session-1"
assert (
msgspec.msgpack.decode(new_payload, type=_PreSessionBlockStored).medium == "GPU"
)