@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 2f17117606
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

[mypy] Fix wrong type annotations related to tuple (#25660)

Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>

Cyrus Leung committed Sep 25, 2025 at 21:00 UTC 2f17117606950a379b3b53babb97d19e2fabd93a
9 files changed +25 -20
benchmarks/kernels/benchmark_lora.py
+4 -4
@@ -79,9 +79,9 @@ def make_rand_lora_weight_tensor(
79
80
81 def make_rand_tensors(
82 - a_shape: tuple[int],
83 - b_shape: tuple[int],
84 - c_shape: tuple[int],
82 + a_shape: tuple[int, ...],
83 + b_shape: tuple[int, ...],
84 + c_shape: tuple[int, ...],
85 a_dtype: torch.dtype,
86 b_dtype: torch.dtype,
87 c_dtype: torch.dtype,
@@ -243,7 +243,7 @@ class OpType(Enum):
243 lora_rank: int,
244 num_loras: int,
245 num_slices: int,
246 - ) -> tuple[tuple[int], tuple[int], tuple[int]]:
246 + ) -> tuple[tuple[int, ...], tuple[int, ...], tuple[int, ...]]:
247 """
248 Given num_slices, return the shapes of the A, B, and C matrices
249 in A x B = C, for the op_type
tests/engine/test_arg_utils.py
+3
@@ -50,8 +50,11 @@ def test_is_type(type_hint, type, expected):
50
51 @pytest.mark.parametrize(("type_hints", "type", "expected"), [
52 ({float, int}, int, True),
53 + ({int, tuple}, int, True),
54 ({int, tuple[int]}, int, True),
55 + ({int, tuple[int, ...]}, int, True),
56 ({int, tuple[int]}, float, False),
57 + ({int, tuple[int, ...]}, float, False),
58 ({str, Literal["x", "y"]}, Literal, True),
59 ])
60 def test_contains_type(type_hints, type, expected):
tests/kernels/core/test_pos_encoding.py
+1 -1
@@ -60,7 +60,7 @@ TENSORS_SHAPES_FN = [
60 @torch.inference_mode()
61 def test_rotary_embedding(
62 is_neox_style: bool,
63 - tensor_shape_fn: Callable[[int, int, int, int], tuple[int]],
63 + tensor_shape_fn: Callable[[int, int, int, int], tuple[int, ...]],
64 batch_size: int,
65 seq_len: int,
66 num_heads: int,
tests/kernels/test_onednn.py
+2 -2
@@ -165,7 +165,7 @@ def onednn_gemm_test_helper(primitive_cache_size: int,
165 def test_onednn_int8_scaled_gemm(
166 n: int,
167 k: int,
168 - m_list: tuple[int],
168 + m_list: tuple[int, ...],
169 per_tensor_a_scale: bool,
170 per_tensor_b_scale: bool,
171 use_bias: bool,
@@ -196,7 +196,7 @@ def test_onednn_int8_scaled_gemm(
196 def test_onednn_gemm(
197 n: int,
198 k: int,
199 - m_list: tuple[int],
199 + m_list: tuple[int, ...],
200 use_bias: bool,
201 use_stride: bool,
202 dtype: torch.dtype,
tests/models/multimodal/generation/vlm_utils/types.py
+6 -6
@@ -101,7 +101,7 @@ class VLMTestInfo(NamedTuple):
101 # Function for converting ImageAssets to image embeddings;
102 # We need to define this explicitly for embedding tests
103 convert_assets_to_embeddings: Optional[Callable[[ImageTestAssets],
104 - torch.Tensor]] = None
104 + list[torch.Tensor]]] = None
105
106 # Exposed options for vLLM runner; we change these in a several tests,
107 # but the defaults are derived from VllmRunner & the engine defaults
@@ -137,12 +137,12 @@ class VLMTestInfo(NamedTuple):
137 # Default expandable params per test; these defaults can be overridden in
138 # instances of this object; the complete set of test cases for the model
139 # is all combinations of .models + all fields below
140 - max_tokens: Union[int, tuple[int]] = 128
141 - num_logprobs: Union[int, tuple[int]] = 5
142 - dtype: Union[str, Union[list[str], tuple[str, ...]]] = "auto"
143 - distributed_executor_backend: Optional[Union[str, Iterable[str]]] = None
140 + max_tokens: int = 128
141 + num_logprobs: int = 5
142 + dtype: str = "auto"
143 + distributed_executor_backend: Optional[str] = None
144 # Only expanded in video tests
145 - num_video_frames: Union[int, tuple[int]] = 16
145 + num_video_frames: int = 16
146
147 # Fixed image sizes / image size factors; most tests use image_size_factors
148 # The values provided for these two fields will be stacked and expanded
tests/v1/sample/test_sampler.py
+5 -3
@@ -72,8 +72,10 @@ def _create_allowed_token_ids(
72
73
74 def _create_bad_words_token_ids(
75 - batch_size: int, vocab_size: int,
76 - bad_words_lengths: list[tuple[int]]) -> dict[int, list[list[int]]]:
75 + batch_size: int,
76 + vocab_size: int,
77 + bad_words_lengths: tuple[int, ...],
78 +) -> dict[int, list[list[int]]]:
79 bad_words_token_ids = {}
80 for batch_idx in range(batch_size):
81 token_ids_single_batch = []
@@ -402,7 +404,7 @@ def test_sampler_allowed_token_ids(device: str, batch_size: int,
404 @pytest.mark.parametrize("batch_size", [1, 2, 32])
405 @pytest.mark.parametrize("bad_words_lengths", [(1, ), (1, 3), (2, 2)])
406 def test_sampler_bad_words(device: str, batch_size: int,
405 - bad_words_lengths: list[tuple[int]]):
407 + bad_words_lengths: tuple[int, ...]):
408 """
409 Test to verify that when the bad words restriction is present, tokens
410 are penalized based on their match with the bad words.
tests/v1/spec_decode/test_eagle.py
+1 -1
@@ -30,7 +30,7 @@ eagle3_dir = "yuhuili/EAGLE3-LLaMA3.1-Instruct-8B"
30 def _create_proposer(
31 method: str,
32 num_speculative_tokens: int,
33 - speculative_token_tree: Optional[list[tuple[int]]] = None,
33 + speculative_token_tree: Optional[list[tuple[int, ...]]] = None,
34 ) -> EagleProposer:
35 model_config = ModelConfig(model=model_dir,
36 runner="generate",
vllm/distributed/device_communicators/ray_communicator.py
+1 -1
@@ -178,7 +178,7 @@ class RayPPCommunicator(Communicator):
178
179 def recv(
180 self,
181 - shape: tuple[int],
181 + shape: tuple[int, ...],
182 dtype: "torch.dtype",
183 peer_rank: int,
184 allocator: TorchTensorAllocator,
vllm/logits_process.py
+2 -2
@@ -1,6 +1,6 @@
1 # SPDX-License-Identifier: Apache-2.0
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3 -
3 +from collections.abc import Sequence
4 from typing import Callable, Union
5
6 import torch
@@ -55,7 +55,7 @@ class NoBadWordsLogitsProcessor:
55
56 def __call__(
57 self,
58 - past_tokens_ids: Union[list[int], tuple[int]],
58 + past_tokens_ids: Sequence[int],
59 logits: torch.FloatTensor,
60 ) -> torch.Tensor:
61 if self.word_bias is None: