@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 6c036615dc
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 14, 05:30 UTC

[V0 Deprecation] Remove misc V0 tests (#25118)

Signed-off-by: Woosuk Kwon <woosuk.kwon@berkeley.edu>

Woosuk Kwon committed Sep 17, 2025 at 19:41 UTC 6c036615dc8ee8c27588491287cb49f2c2e2476a
2 files changed -190
tests/model_executor/test_logits_processor.py deleted
-98
@@ -1,98 +0,0 @@
1 -# SPDX-License-Identifier: Apache-2.0
2 -# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3 -
4 -import random
5 -from unittest.mock import patch
6 -
7 -import pytest
8 -import torch
9 -
10 -from vllm.model_executor.layers.logits_processor import LogitsProcessor
11 -from vllm.model_executor.sampling_metadata import SamplingMetadata
12 -from vllm.model_executor.utils import set_random_seed
13 -from vllm.sequence import SamplingParams, SequenceData, SequenceGroupMetadata
14 -from vllm.utils import is_pin_memory_available
15 -
16 -
17 -class MockLogitsProcessor(LogitsProcessor):
18 -
19 - def __init__(self, vocab_size: int, scale: float,
20 - fake_logits: torch.Tensor):
21 - super().__init__(vocab_size=vocab_size, scale=scale)
22 - self.fake_logits = fake_logits.clone()
23 -
24 - def forward(self, *args, **kwargs):
25 - with patch(
26 - "vllm.model_executor.layers.logits_processor._prune_hidden_states",
27 - lambda x, y: x
28 - ), patch(
29 - "vllm.model_executor.layers.logits_processor.LogitsProcessor._get_logits",
30 - lambda *args, **kwargs: self.fake_logits):
31 - return super().forward(*args, **kwargs)
32 -
33 -
34 -def _prepare_test(
35 - batch_size: int
36 -) -> tuple[torch.Tensor, torch.Tensor, MockLogitsProcessor]:
37 - vocab_size = 32000
38 - input_tensor = torch.rand((batch_size, 1024), dtype=torch.float16)
39 - fake_logits = torch.full((batch_size, vocab_size),
40 - 1e-2,
41 - dtype=input_tensor.dtype)
42 - logits_processor = MockLogitsProcessor(32000, 0.5, fake_logits)
43 - return input_tensor, fake_logits, logits_processor
44 -
45 -
46 -RANDOM_SEEDS = list(range(128))
47 -CUDA_DEVICES = [
48 - f"cuda:{i}" for i in range(1 if torch.cuda.device_count() == 1 else 2)
49 -]
50 -
51 -
52 -@pytest.mark.parametrize("seed", RANDOM_SEEDS)
53 -@pytest.mark.parametrize("device", CUDA_DEVICES)
54 -def test_logits_processors(seed: int, device: str):
55 - set_random_seed(seed)
56 - torch.set_default_device(device)
57 - batch_size = random.randint(1, 256)
58 - input_tensor, fake_logits, logits_processor = _prepare_test(batch_size)
59 -
60 - # This sample logits processor gives infinite score to the i-th token,
61 - # where i is the length of the input sequence.
62 - # We therefore expect the output token sequence to be [0, 1, 2, ...]
63 - def pick_ith(token_ids, logits):
64 - logits[len(token_ids)] = float("inf")
65 - return logits
66 -
67 - seq_group_metadata_list = []
68 - seq_lens = []
69 - for i in range(batch_size):
70 - seq_group_metadata_list.append(
71 - SequenceGroupMetadata(
72 - request_id=f"test_{i}",
73 - is_prompt=True,
74 - seq_data={0: SequenceData.from_seqs([1, 2, 3])},
75 - sampling_params=SamplingParams(temperature=0,
76 - logits_processors=[pick_ith]),
77 - block_tables={0: [1]},
78 - ))
79 - seq_lens.append(seq_group_metadata_list[-1].seq_data[0].get_len())
80 -
81 - sampling_metadata = SamplingMetadata.prepare(
82 - seq_group_metadata_list,
83 - seq_lens,
84 - query_lens=seq_lens,
85 - device=device,
86 - pin_memory=is_pin_memory_available())
87 - logits_processor_output = logits_processor(
88 - lm_head=None,
89 - hidden_states=input_tensor,
90 - sampling_metadata=sampling_metadata)
91 -
92 - assert torch.isinf(logits_processor_output[:, 0]).all()
93 -
94 - fake_logits *= logits_processor.scale
95 - torch.testing.assert_close(logits_processor_output[:, 1],
96 - fake_logits[:, 1],
97 - rtol=1e-4,
98 - atol=0.0)
tests/test_cache_block_hashing.py deleted
-92
@@ -1,92 +0,0 @@
1 -# SPDX-License-Identifier: Apache-2.0
2 -# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3 -"""Test hashing of cache blocks.
4 -
5 -Run `pytest tests/test_cache_block_hashing.py`.
6 -"""
7 -from typing import Optional
8 -
9 -import pytest
10 -
11 -from vllm.inputs import token_inputs
12 -from vllm.lora.request import LoRARequest
13 -from vllm.sequence import Sequence
14 -from vllm.transformers_utils.tokenizer import get_tokenizer
15 -
16 -# Make two prefixes with different first blocks.
17 -prefix_start = [("You are an expert"), ("You are a")]
18 -prefix_common = (
19 - " school principal, skilled in effectively managing "
20 - "faculty and staff. Draft 10-15 questions for a potential first grade "
21 - "Head Teacher for my K-12, all-girls', independent school that emphasizes "
22 - "community, joyful discovery, and life-long learning. The candidate is "
23 - "coming in for a first-round panel interview for a 8th grade Math "
24 - "teaching role. They have 5 years of previous teaching experience "
25 - "as an assistant teacher at a co-ed, public school with experience "
26 - "in middle school math teaching. Based on this, fulfill "
27 - "the following: ")
28 -prefixes = [start + prefix_common for start in prefix_start]
29 -
30 -# Sample prompts.
31 -sample_prompts = [
32 - "Hello, my name is", "The president of the United States is",
33 - "The capital of France is", "The future of AI is"
34 -]
35 -
36 -
37 -# Helper function.
38 -def flatten_2d(li):
39 - return [lss for ls in li for lss in ls]
40 -
41 -
42 -@pytest.mark.parametrize("model", ["facebook/opt-125m"])
43 -@pytest.mark.parametrize("block_size", [16])
44 -@pytest.mark.parametrize("max_num_seqs", [256])
45 -@pytest.mark.parametrize("concurrent_lora_int_ids",
46 - [[None], [1], [None, 1], [None, 1, 2], [1, 2]])
47 -def test_auto_prefix_caching(model: str, block_size: int, max_num_seqs: int,
48 - concurrent_lora_int_ids: list[Optional[int]]):
49 -
50 - tokenizer = get_tokenizer("facebook/opt-125m")
51 -
52 - hashes: list[list[list[int]]] = []
53 -
54 - for prefix in prefixes:
55 - for lora_int_id in concurrent_lora_int_ids:
56 - lora_request = None
57 -
58 - if lora_int_id is not None:
59 - lora_request = LoRARequest(
60 - f"example_lora_{lora_int_id}",
61 - lora_int_id,
62 - f"example/path/to/lora_{lora_int_id}",
63 - )
64 -
65 - hashes.append([])
66 - prompts = [prefix + prompt for prompt in sample_prompts]
67 - for seq_id, prompt in enumerate(prompts):
68 - hashes[-1].append([])
69 - prompt_token_ids = tokenizer.encode(prompt)
70 - seq = Sequence(seq_id,
71 - inputs=token_inputs(prompt_token_ids,
72 - prompt=prompt),
73 - block_size=block_size,
74 - eos_token_id=tokenizer.eos_token_id,
75 - lora_request=lora_request)
76 -
77 - num_blocks = len(prompt_token_ids) // block_size
78 - for idx in range(num_blocks):
79 - hashes[-1][-1].append(seq.hash_of_block(idx))
80 -
81 - # Check that hashes made with two prefixes with different first blocks are
82 - # different everywhere.
83 - for hash0, hash1 in zip(flatten_2d(hashes[0]), flatten_2d(hashes[1])):
84 - assert (hash0 != hash1)
85 -
86 - # Check that hashes of different prompts made with the same prefix are the
87 - # same until the hashes that contain the prompt.
88 - for hash_pref in hashes:
89 - same_hashes = [tuple(h[:-1]) for h in hash_pref]
90 - different_hashes = [h[-1] for h in hash_pref]
91 - assert (len(set(same_hashes)) == 1)
92 - assert (len(set(different_hashes)) == len(different_hashes))