@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 9513290032
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 15, 19:45 UTC

[Misc] Upgrade to Python 3.9 typing for additional directories (#14492)

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

Cyrus Leung committed Mar 9, 2025 at 01:35 UTC 951329003203ba34f52b82ed12bcf91b349c2fa2
12 files changed +78 -78
pyproject.toml
-5
@@ -75,11 +75,8 @@ exclude = [
75 "vllm/distributed/**/*.py" = ["UP006", "UP035"]
76 "vllm/engine/**/*.py" = ["UP006", "UP035"]
77 "vllm/executor/**/*.py" = ["UP006", "UP035"]
78 -"vllm/inputs/**/*.py" = ["UP006", "UP035"]
79 -"vllm/logging_utils/**/*.py" = ["UP006", "UP035"]
78 "vllm/lora/**/*.py" = ["UP006", "UP035"]
79 "vllm/model_executor/**/*.py" = ["UP006", "UP035"]
82 -"vllm/multimodal/**/*.py" = ["UP006", "UP035"]
80 "vllm/platforms/**/*.py" = ["UP006", "UP035"]
81 "vllm/plugins/**/*.py" = ["UP006", "UP035"]
82 "vllm/profiler/**/*.py" = ["UP006", "UP035"]
@@ -87,9 +84,7 @@ exclude = [
84 "vllm/spec_decode/**/*.py" = ["UP006", "UP035"]
85 "vllm/transformers_utils/**/*.py" = ["UP006", "UP035"]
86 "vllm/triton_utils/**/*.py" = ["UP006", "UP035"]
90 -"vllm/usage/**/*.py" = ["UP006", "UP035"]
87 "vllm/vllm_flash_attn/**/*.py" = ["UP006", "UP035"]
92 -"vllm/assets/**/*.py" = ["UP006", "UP035"]
88 "vllm/worker/**/*.py" = ["UP006", "UP035"]
89
90 [tool.ruff.lint]
vllm/assets/video.py
+3 -3
@@ -2,7 +2,7 @@
2
3 from dataclasses import dataclass
4 from functools import lru_cache
5 -from typing import List, Literal
5 +from typing import Literal
6
7 import cv2
8 import numpy as np
@@ -58,7 +58,7 @@ def video_to_ndarrays(path: str, num_frames: int = -1) -> npt.NDArray:
58
59
60 def video_to_pil_images_list(path: str,
61 - num_frames: int = -1) -> List[Image.Image]:
61 + num_frames: int = -1) -> list[Image.Image]:
62 frames = video_to_ndarrays(path, num_frames)
63 return [
64 Image.fromarray(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB))
@@ -72,7 +72,7 @@ class VideoAsset:
72 num_frames: int = -1
73
74 @property
75 - def pil_images(self) -> List[Image.Image]:
75 + def pil_images(self) -> list[Image.Image]:
76 video_path = download_video_asset(self.name)
77 ret = video_to_pil_images_list(video_path, self.num_frames)
78 return ret
vllm/inputs/data.py
+27 -27
@@ -1,9 +1,9 @@
1 # SPDX-License-Identifier: Apache-2.0
2
3 +from collections.abc import Iterable
4 from dataclasses import dataclass
5 from functools import cached_property
5 -from typing import (TYPE_CHECKING, Any, Dict, Generic, Iterable, List, Literal,
6 - Optional, Tuple, Union, cast)
6 +from typing import TYPE_CHECKING, Any, Generic, Literal, Optional, Union, cast
7
8 import torch
9 from typing_extensions import NotRequired, TypedDict, TypeVar, assert_never
@@ -26,7 +26,7 @@ class TextPrompt(TypedDict):
26 if the model supports it.
27 """
28
29 - mm_processor_kwargs: NotRequired[Dict[str, Any]]
29 + mm_processor_kwargs: NotRequired[dict[str, Any]]
30 """
31 Optional multi-modal processor kwargs to be forwarded to the
32 multimodal input mapper & processor. Note that if multiple modalities
@@ -38,10 +38,10 @@ class TextPrompt(TypedDict):
38 class TokensPrompt(TypedDict):
39 """Schema for a tokenized prompt."""
40
41 - prompt_token_ids: List[int]
41 + prompt_token_ids: list[int]
42 """A list of token IDs to pass to the model."""
43
44 - token_type_ids: NotRequired[List[int]]
44 + token_type_ids: NotRequired[list[int]]
45 """A list of token type IDs to pass to the cross encoder model."""
46
47 multi_modal_data: NotRequired["MultiModalDataDict"]
@@ -50,7 +50,7 @@ class TokensPrompt(TypedDict):
50 if the model supports it.
51 """
52
53 - mm_processor_kwargs: NotRequired[Dict[str, Any]]
53 + mm_processor_kwargs: NotRequired[dict[str, Any]]
54 """
55 Optional multi-modal processor kwargs to be forwarded to the
56 multimodal input mapper & processor. Note that if multiple modalities
@@ -115,7 +115,7 @@ class ExplicitEncoderDecoderPrompt(TypedDict, Generic[_T1_co, _T2_co]):
115
116 decoder_prompt: Optional[_T2_co]
117
118 - mm_processor_kwargs: NotRequired[Dict[str, Any]]
118 + mm_processor_kwargs: NotRequired[dict[str, Any]]
119
120
121 PromptType = Union[SingletonPrompt, ExplicitEncoderDecoderPrompt]
@@ -136,10 +136,10 @@ class TokenInputs(TypedDict):
136 type: Literal["token"]
137 """The type of inputs."""
138
139 - prompt_token_ids: List[int]
139 + prompt_token_ids: list[int]
140 """The token IDs of the prompt."""
141
142 - token_type_ids: NotRequired[List[int]]
142 + token_type_ids: NotRequired[list[int]]
143 """The token type IDs of the prompt."""
144
145 prompt: NotRequired[str]
@@ -164,12 +164,12 @@ class TokenInputs(TypedDict):
164 Placeholder ranges for the multi-modal data.
165 """
166
167 - multi_modal_hashes: NotRequired[List[str]]
167 + multi_modal_hashes: NotRequired[list[str]]
168 """
169 The hashes of the multi-modal data.
170 """
171
172 - mm_processor_kwargs: NotRequired[Dict[str, Any]]
172 + mm_processor_kwargs: NotRequired[dict[str, Any]]
173 """
174 Optional multi-modal processor kwargs to be forwarded to the
175 multimodal input mapper & processor. Note that if multiple modalities
@@ -179,14 +179,14 @@ class TokenInputs(TypedDict):
179
180
181 def token_inputs(
182 - prompt_token_ids: List[int],
183 - token_type_ids: Optional[List[int]] = None,
182 + prompt_token_ids: list[int],
183 + token_type_ids: Optional[list[int]] = None,
184 prompt: Optional[str] = None,
185 multi_modal_data: Optional["MultiModalDataDict"] = None,
186 multi_modal_inputs: Optional["MultiModalKwargs"] = None,
187 - multi_modal_hashes: Optional[List[str]] = None,
187 + multi_modal_hashes: Optional[list[str]] = None,
188 multi_modal_placeholders: Optional["MultiModalPlaceholderDict"] = None,
189 - mm_processor_kwargs: Optional[Dict[str, Any]] = None,
189 + mm_processor_kwargs: Optional[dict[str, Any]] = None,
190 ) -> TokenInputs:
191 """Construct :class:`TokenInputs` from optional values."""
192 inputs = TokenInputs(type="token", prompt_token_ids=prompt_token_ids)
@@ -255,7 +255,7 @@ class SingletonInputsAdapter:
255 assert_never(inputs) # type: ignore[arg-type]
256
257 @cached_property
258 - def prompt_token_ids(self) -> List[int]:
258 + def prompt_token_ids(self) -> list[int]:
259 inputs = self.inputs
260
261 if inputs["type"] == "token" or inputs["type"] == "multimodal":
@@ -264,7 +264,7 @@ class SingletonInputsAdapter:
264 assert_never(inputs) # type: ignore[arg-type]
265
266 @cached_property
267 - def token_type_ids(self) -> List[int]:
267 + def token_type_ids(self) -> list[int]:
268 inputs = self.inputs
269
270 if inputs["type"] == "token" or inputs["type"] == "multimodal":
@@ -294,7 +294,7 @@ class SingletonInputsAdapter:
294 assert_never(inputs) # type: ignore[arg-type]
295
296 @cached_property
297 - def multi_modal_inputs(self) -> Union[Dict, "MultiModalKwargs"]:
297 + def multi_modal_inputs(self) -> Union[dict, "MultiModalKwargs"]:
298 inputs = self.inputs
299
300 if inputs["type"] == "token":
@@ -306,7 +306,7 @@ class SingletonInputsAdapter:
306 assert_never(inputs) # type: ignore[arg-type]
307
308 @cached_property
309 - def multi_modal_hashes(self) -> List[str]:
309 + def multi_modal_hashes(self) -> list[str]:
310 inputs = self.inputs
311
312 if inputs["type"] == "token":
@@ -331,7 +331,7 @@ class SingletonInputsAdapter:
331 assert_never(inputs) # type: ignore[arg-type]
332
333 @cached_property
334 - def mm_processor_kwargs(self) -> Dict[str, Any]:
334 + def mm_processor_kwargs(self) -> dict[str, Any]:
335 inputs = self.inputs
336
337 if inputs["type"] == "token":
@@ -355,7 +355,7 @@ _T2 = TypeVar("_T2", bound=SingletonPrompt, default=SingletonPrompt)
355 def build_explicit_enc_dec_prompt(
356 encoder_prompt: _T1,
357 decoder_prompt: Optional[_T2],
358 - mm_processor_kwargs: Optional[Dict[str, Any]] = None,
358 + mm_processor_kwargs: Optional[dict[str, Any]] = None,
359 ) -> ExplicitEncoderDecoderPrompt[_T1, _T2]:
360 if mm_processor_kwargs is None:
361 mm_processor_kwargs = {}
@@ -368,9 +368,9 @@ def build_explicit_enc_dec_prompt(
368 def zip_enc_dec_prompts(
369 enc_prompts: Iterable[_T1],
370 dec_prompts: Iterable[Optional[_T2]],
371 - mm_processor_kwargs: Optional[Union[Iterable[Dict[str, Any]],
372 - Dict[str, Any]]] = None,
373 -) -> List[ExplicitEncoderDecoderPrompt[_T1, _T2]]:
371 + mm_processor_kwargs: Optional[Union[Iterable[dict[str, Any]],
372 + dict[str, Any]]] = None,
373 +) -> list[ExplicitEncoderDecoderPrompt[_T1, _T2]]:
374 """
375 Zip encoder and decoder prompts together into a list of
376 :class:`ExplicitEncoderDecoderPrompt` instances.
@@ -380,12 +380,12 @@ def zip_enc_dec_prompts(
380 provided, it will be zipped with the encoder/decoder prompts.
381 """
382 if mm_processor_kwargs is None:
383 - mm_processor_kwargs = cast(Dict[str, Any], {})
383 + mm_processor_kwargs = cast(dict[str, Any], {})
384 if isinstance(mm_processor_kwargs, dict):
385 return [
386 build_explicit_enc_dec_prompt(
387 encoder_prompt, decoder_prompt,
388 - cast(Dict[str, Any], mm_processor_kwargs))
388 + cast(dict[str, Any], mm_processor_kwargs))
389 for (encoder_prompt,
390 decoder_prompt) in zip(enc_prompts, dec_prompts)
391 ]
@@ -399,7 +399,7 @@ def zip_enc_dec_prompts(
399
400 def to_enc_dec_tuple_list(
401 enc_dec_prompts: Iterable[ExplicitEncoderDecoderPrompt[_T1, _T2]],
402 -) -> List[Tuple[_T1, Optional[_T2]]]:
402 +) -> list[tuple[_T1, Optional[_T2]]]:
403 return [(enc_dec_prompt["encoder_prompt"],
404 enc_dec_prompt["decoder_prompt"])
405 for enc_dec_prompt in enc_dec_prompts]
vllm/inputs/parse.py
+9 -8
@@ -1,6 +1,7 @@
1 # SPDX-License-Identifier: Apache-2.0
2
3 -from typing import List, Literal, Sequence, TypedDict, Union, cast, overload
3 +from collections.abc import Sequence
4 +from typing import Literal, TypedDict, Union, cast, overload
5
6 from typing_extensions import TypeIs
7
@@ -17,24 +18,24 @@ class ParsedText(TypedDict):
18
19
20 class ParsedTokens(TypedDict):
20 - content: List[int]
21 + content: list[int]
22 is_tokens: Literal[True]
23
24
25 @overload
26 def parse_and_batch_prompt(
26 - prompt: Union[str, List[str]]) -> Sequence[ParsedText]:
27 + prompt: Union[str, list[str]]) -> Sequence[ParsedText]:
28 ...
29
30
31 @overload
32 def parse_and_batch_prompt(
32 - prompt: Union[List[int], List[List[int]]]) -> Sequence[ParsedTokens]:
33 + prompt: Union[list[int], list[list[int]]]) -> Sequence[ParsedTokens]:
34 ...
35
36
37 def parse_and_batch_prompt(
37 - prompt: Union[str, List[str], List[int], List[List[int]]],
38 + prompt: Union[str, list[str], list[int], list[list[int]]],
39 ) -> Union[Sequence[ParsedText], Sequence[ParsedTokens]]:
40 if isinstance(prompt, str):
41 # case 1: a string
@@ -46,16 +47,16 @@ def parse_and_batch_prompt(
47
48 if is_list_of(prompt, str):
49 # case 2: array of strings
49 - prompt = cast(List[str], prompt)
50 + prompt = cast(list[str], prompt)
51 return [
52 ParsedText(content=elem, is_tokens=False) for elem in prompt
53 ]
54 if is_list_of(prompt, int):
55 # case 3: array of tokens
55 - prompt = cast(List[int], prompt)
56 + prompt = cast(list[int], prompt)
57 return [ParsedTokens(content=prompt, is_tokens=True)]
58 if is_list_of(prompt, list):
58 - prompt = cast(List[List[int]], prompt)
59 + prompt = cast(list[list[int]], prompt)
60 if len(prompt[0]) == 0:
61 raise ValueError("please provide at least one prompt")
62
vllm/inputs/preprocess.py
+12 -11
@@ -1,7 +1,8 @@
1 # SPDX-License-Identifier: Apache-2.0
2
3 import asyncio
4 -from typing import List, Mapping, Optional, Tuple, Union, cast
4 +from collections.abc import Mapping
5 +from typing import Optional, Union, cast
6
7 from typing_extensions import assert_never
8
@@ -92,7 +93,7 @@ class InputPreprocessor:
93
94 return dec_start_token_id
95
95 - def _get_default_enc_dec_decoder_prompt(self) -> List[int]:
96 + def _get_default_enc_dec_decoder_prompt(self) -> list[int]:
97 '''
98 Specifically for encoder/decoder models:
99 generate a default decoder prompt for when
@@ -130,8 +131,8 @@ class InputPreprocessor:
131
132 def _prepare_decoder_input_ids_for_generation(
133 self,
133 - decoder_input_ids: Optional[List[int]],
134 - ) -> List[int]:
134 + decoder_input_ids: Optional[list[int]],
135 + ) -> list[int]:
136 """
137 Prepares `decoder_input_ids` for generation with encoder-decoder models.
138
@@ -168,9 +169,9 @@ class InputPreprocessor:
169
170 def _apply_prompt_adapter(
171 self,
171 - prompt_token_ids: List[int],
172 + prompt_token_ids: list[int],
173 prompt_adapter_request: Optional[PromptAdapterRequest],
173 - ) -> List[int]:
174 + ) -> list[int]:
175 if prompt_adapter_request:
176 prompt_token_ids = (
177 [0] * prompt_adapter_request.prompt_adapter_num_virtual_tokens
@@ -183,7 +184,7 @@ class InputPreprocessor:
184 prompt: str,
185 request_id: str,
186 lora_request: Optional[LoRARequest],
186 - ) -> List[int]:
187 + ) -> list[int]:
188 """
189 Apply the model's tokenizer to a text prompt, returning the
190 corresponding token IDs.
@@ -211,7 +212,7 @@ class InputPreprocessor:
212 prompt: str,
213 request_id: str,
214 lora_request: Optional[LoRARequest],
214 - ) -> List[int]:
215 + ) -> list[int]:
216 """Async version of :meth:`_tokenize_prompt`."""
217 tokenizer = self.get_tokenizer_group()
218 add_special_tokens = None
@@ -250,7 +251,7 @@ class InputPreprocessor:
251
252 def _process_multimodal(
253 self,
253 - prompt: Union[str, List[int]],
254 + prompt: Union[str, list[int]],
255 mm_data: MultiModalDataDict,
256 mm_processor_kwargs: Optional[Mapping[str, object]],
257 lora_request: Optional[LoRARequest],
@@ -280,7 +281,7 @@ class InputPreprocessor:
281
282 async def _process_multimodal_async(
283 self,
283 - prompt: Union[str, List[int]],
284 + prompt: Union[str, list[int]],
285 mm_data: MultiModalDataDict,
286 mm_processor_kwargs: Optional[Mapping[str, object]],
287 lora_request: Optional[LoRARequest],
@@ -511,7 +512,7 @@ class InputPreprocessor:
512 self,
513 inputs: SingletonInputs,
514 decoder_inputs_to_override: Optional[SingletonInputs] = None,
514 - ) -> Tuple[SingletonInputs, SingletonInputs]:
515 + ) -> tuple[SingletonInputs, SingletonInputs]:
516 """
517 For encoder/decoder models only:
518 Separate Encoder/Decoder inputs from a MultiModalEncDecInputs
vllm/inputs/registry.py
+3 -2
@@ -2,9 +2,10 @@
2
3 import functools
4 from collections import UserDict
5 +from collections.abc import Mapping
6 from dataclasses import dataclass
6 -from typing import (TYPE_CHECKING, Any, Callable, Mapping, NamedTuple,
7 - Optional, Protocol, Union)
7 +from typing import (TYPE_CHECKING, Any, Callable, NamedTuple, Optional,
8 + Protocol, Union)
9
10 from torch import nn
11 from transformers import BatchFeature, PretrainedConfig, ProcessorMixin
vllm/multimodal/base.py
+4 -3
@@ -2,9 +2,10 @@
2
3 from abc import ABC, abstractmethod
4 from collections import defaultdict
5 +from collections.abc import Sequence
6 from pathlib import Path
7 from typing import (TYPE_CHECKING, Any, Callable, Generic, NamedTuple,
7 - Optional, Sequence, Tuple, Type, TypeVar, Union)
8 + Optional, TypeVar, Union)
9
10 from torch import nn
11
@@ -39,7 +40,7 @@ model. This does not include tokens that correspond to the input text.
40 """
41
42 _T = TypeVar("_T")
42 -N = TypeVar("N", bound=Type[nn.Module])
43 +N = TypeVar("N", bound=type[nn.Module])
44
45
46 class MultiModalPlugin(ABC):
@@ -274,7 +275,7 @@ class MultiModalPlaceholderMap:
275 @classmethod
276 def from_seq_group(
277 cls, seq_group: "SequenceGroupMetadata", positions: range
277 - ) -> Tuple[Optional[MultiModalDataDict], dict[str,
278 + ) -> tuple[Optional[MultiModalDataDict], dict[str,
279 "MultiModalPlaceholderMap"]]:
280 """
281 Returns the multi-modal items that intersect with the portion of a
vllm/multimodal/hasher.py
+2 -1
@@ -1,7 +1,8 @@
1 # SPDX-License-Identifier: Apache-2.0
2
3 import pickle
4 -from typing import TYPE_CHECKING, Iterable, Mapping, Optional
4 +from collections.abc import Iterable, Mapping
5 +from typing import TYPE_CHECKING, Optional
6
7 import numpy as np
8 import torch
vllm/multimodal/image.py
+2 -2
@@ -3,7 +3,7 @@
3 import base64
4 from io import BytesIO
5 from pathlib import Path
6 -from typing import TYPE_CHECKING, Any, Dict, Optional
6 +from typing import TYPE_CHECKING, Any, Optional
7
8 import torch
9 from PIL import Image
@@ -31,7 +31,7 @@ class ImagePlugin(MultiModalPlugin):
31 def _get_hf_image_processor(
32 self,
33 model_config: "ModelConfig",
34 - mm_processor_kwargs: Optional[Dict[str, Any]] = None,
34 + mm_processor_kwargs: Optional[dict[str, Any]] = None,
35 ):
36 if mm_processor_kwargs is None:
37 mm_processor_kwargs = {}
vllm/multimodal/registry.py
+7 -7
@@ -2,9 +2,9 @@
2
3 import functools
4 from collections import UserDict
5 +from collections.abc import Mapping, Sequence
6 from dataclasses import dataclass
6 -from typing import (TYPE_CHECKING, Any, Dict, Generic, Mapping, Optional,
7 - Protocol, Sequence, Type, TypeVar)
7 +from typing import TYPE_CHECKING, Any, Generic, Optional, Protocol, TypeVar
8
9 import torch.nn as nn
10
@@ -29,7 +29,7 @@ if TYPE_CHECKING:
29
30 logger = init_logger(__name__)
31
32 -N = TypeVar("N", bound=Type[nn.Module])
32 +N = TypeVar("N", bound=type[nn.Module])
33 _I = TypeVar("_I", bound=BaseProcessingInfo)
34 _I_co = TypeVar("_I_co", bound=BaseProcessingInfo, covariant=True)
35
@@ -83,13 +83,13 @@ class _ProcessorFactories(Generic[_I]):
83 return self.processor(info, dummy_inputs_builder, cache=cache)
84
85
86 -class _MultiModalLimits(UserDict["ModelConfig", Dict[str, int]]):
86 +class _MultiModalLimits(UserDict["ModelConfig", dict[str, int]]):
87 """
88 Wraps `_limits_by_model` for a more informative error message
89 when attempting to access a model that does not exist.
90 """
91
92 - def __getitem__(self, key: "ModelConfig") -> Dict[str, int]:
92 + def __getitem__(self, key: "ModelConfig") -> dict[str, int]:
93 try:
94 return super().__getitem__(key)
95 except KeyError as exc:
@@ -170,7 +170,7 @@ class MultiModalRegistry:
170 self,
171 model_config: "ModelConfig",
172 data: MultiModalDataDict,
173 - mm_processor_kwargs: Optional[Dict[str, Any]] = None,
173 + mm_processor_kwargs: Optional[dict[str, Any]] = None,
174 ) -> MultiModalKwargs:
175 """
176 Apply an input mapper to the data passed to the model.
@@ -184,7 +184,7 @@ class MultiModalRegistry:
184 Note:
185 This should be called after :meth:`init_mm_limits_per_prompt`.
186 """
187 - merged_dict: Dict[str, NestedTensors] = {}
187 + merged_dict = dict[str, NestedTensors]()
188
189 for data_key, data_value in data.items():
190 plugin = self._get_plugin(data_key)
vllm/multimodal/video.py
+2 -2
@@ -4,7 +4,7 @@ import base64
4 from functools import partial
5 from io import BytesIO
6 from pathlib import Path
7 -from typing import TYPE_CHECKING, Any, Dict, Optional
7 +from typing import TYPE_CHECKING, Any, Optional
8
9 import numpy as np
10 import numpy.typing as npt
@@ -39,7 +39,7 @@ class VideoPlugin(ImagePlugin):
39 def _get_hf_video_processor(
40 self,
41 model_config: "ModelConfig",
42 - mm_processor_kwargs: Optional[Dict[str, Any]] = None,
42 + mm_processor_kwargs: Optional[dict[str, Any]] = None,
43 ):
44 if mm_processor_kwargs is None:
45 mm_processor_kwargs = {}
vllm/usage/usage_lib.py
+7 -7
@@ -9,7 +9,7 @@ import time
9 from enum import Enum
10 from pathlib import Path
11 from threading import Thread
12 -from typing import Any, Dict, Optional, Union
12 +from typing import Any, Optional, Union
13 from uuid import uuid4
14
15 import cpuinfo
@@ -27,7 +27,7 @@ _USAGE_STATS_DO_NOT_TRACK_PATH = os.path.join(_config_home, "do_not_track")
27 _USAGE_STATS_ENABLED = None
28 _USAGE_STATS_SERVER = envs.VLLM_USAGE_STATS_SERVER
29
30 -_GLOBAL_RUNTIME_DATA: Dict[str, Union[str, int, bool]] = {}
30 +_GLOBAL_RUNTIME_DATA = dict[str, Union[str, int, bool]]()
31
32 _USAGE_ENV_VARS_TO_COLLECT = [
33 "VLLM_USE_MODELSCOPE",
@@ -150,7 +150,7 @@ class UsageMessage:
150 def report_usage(self,
151 model_architecture: str,
152 usage_context: UsageContext,
153 - extra_kvs: Optional[Dict[str, Any]] = None) -> None:
153 + extra_kvs: Optional[dict[str, Any]] = None) -> None:
154 t = Thread(target=self._report_usage_worker,
155 args=(model_architecture, usage_context, extra_kvs or {}),
156 daemon=True)
@@ -158,13 +158,13 @@ class UsageMessage:
158
159 def _report_usage_worker(self, model_architecture: str,
160 usage_context: UsageContext,
161 - extra_kvs: Dict[str, Any]) -> None:
161 + extra_kvs: dict[str, Any]) -> None:
162 self._report_usage_once(model_architecture, usage_context, extra_kvs)
163 self._report_continous_usage()
164
165 def _report_usage_once(self, model_architecture: str,
166 usage_context: UsageContext,
167 - extra_kvs: Dict[str, Any]) -> None:
167 + extra_kvs: dict[str, Any]) -> None:
168 # Platform information
169 from vllm.platforms import current_platform
170 if current_platform.is_cuda_alike():
@@ -227,7 +227,7 @@ class UsageMessage:
227 self._write_to_file(data)
228 self._send_to_server(data)
229
230 - def _send_to_server(self, data: Dict[str, Any]) -> None:
230 + def _send_to_server(self, data: dict[str, Any]) -> None:
231 try:
232 global_http_client = global_http_connection.get_sync_client()
233 global_http_client.post(_USAGE_STATS_SERVER, json=data)
@@ -235,7 +235,7 @@ class UsageMessage:
235 # silently ignore unless we are using debug log
236 logging.debug("Failed to send usage data to server")
237
238 - def _write_to_file(self, data: Dict[str, Any]) -> None:
238 + def _write_to_file(self, data: dict[str, Any]) -> None:
239 os.makedirs(os.path.dirname(_USAGE_STATS_JSON_PATH), exist_ok=True)
240 Path(_USAGE_STATS_JSON_PATH).touch(exist_ok=True)
241 with open(_USAGE_STATS_JSON_PATH, "a") as f: